diff --git a/packages/dynamite/dynamite/lib/src/builder/built_object_serializer.dart b/packages/dynamite/dynamite/lib/src/builder/built_object_serializer.dart index 35e5c8f00ef..06ef137fa0c 100644 --- a/packages/dynamite/dynamite/lib/src/builder/built_object_serializer.dart +++ b/packages/dynamite/dynamite/lib/src/builder/built_object_serializer.dart @@ -3,6 +3,7 @@ import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; import 'package:source_helper/source_helper.dart'; @@ -11,7 +12,7 @@ Spec buildBuiltClassSerializer( State state, String identifier, openapi.OpenAPI spec, - openapi.Schema schema, + json_schema.ObjectSchema schema, ) => Class( (b) => b @@ -136,7 +137,7 @@ Iterable deserializeProperty( State state, String identifier, openapi.OpenAPI spec, - openapi.Schema schema, + json_schema.ObjectSchema schema, ) sync* { for (final property in schema.properties!.entries) { final propertyName = property.key; @@ -168,7 +169,7 @@ Iterable serializePropertyNullable( State state, String identifier, openapi.OpenAPI spec, - openapi.Schema schema, + json_schema.ObjectSchema schema, ) sync* { for (final property in schema.properties!.entries) { final propertyName = property.key; @@ -203,7 +204,7 @@ Iterable serializeProperty( State state, String identifier, openapi.OpenAPI spec, - openapi.Schema schema, + json_schema.ObjectSchema schema, ) sync* { for (final property in schema.properties!.entries) { final propertyName = property.key; diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index c0405f25f40..6ef45fd9cd3 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -10,6 +10,7 @@ import 'package:dynamite/src/helpers/docs.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/logger.dart'; import 'package:dynamite/src/helpers/pattern_check.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; import 'package:uri/uri.dart'; @@ -487,7 +488,7 @@ return ${allocate(responseType)}.fromRawResponse(_rawResponse); spec, state, identifierBuilder.toString(), - openapi.Schema( + json_schema.ObjectSchema( (b) => b ..properties.replace( response.headers!.map( diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart index ab15d3a96f7..ead10ced8fb 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_enum.dart @@ -5,6 +5,7 @@ import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/docs.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; import 'package:source_helper/source_helper.dart'; @@ -13,7 +14,7 @@ TypeResult resolveEnum( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, + json_schema.JsonSchema schema, TypeResult subResult, { bool nullable = false, }) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart index 38c03f346c4..24e52286f02 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_interface.dart @@ -7,6 +7,7 @@ import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/docs.dart'; import 'package:dynamite/src/helpers/dynamite.dart'; import 'package:dynamite/src/helpers/pattern_check.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -14,7 +15,7 @@ Spec buildInterface( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, { + json_schema.JsonSchema schema, { bool isHeader = false, bool nullable = false, }) { @@ -31,9 +32,9 @@ Spec buildInterface( final defaults = StringBuffer(); final validators = BlockBuilder(); - if (schema case openapi.Schema(:final allOf) when allOf != null) { + if (schema case json_schema.JsonSchema(:final allOf) when allOf != null) { for (final schema in allOf) { - if (schema case openapi.Schema(properties: != null)) { + if (schema case json_schema.ObjectSchema(properties: != null)) { _generateProperties( schema, spec, @@ -73,7 +74,7 @@ Spec buildInterface( } } else { _generateProperties( - schema, + schema as json_schema.ObjectSchema, spec, state, identifier, @@ -135,7 +136,7 @@ Spec buildInterface( } void _generateProperties( - openapi.Schema schema, + json_schema.ObjectSchema schema, openapi.OpenAPI spec, State state, String identifier, @@ -192,7 +193,7 @@ void _generateProperty( ClassBuilder b, String propertyName, TypeResult result, - openapi.Schema schema, + json_schema.JsonSchema schema, StringSink defaults, BlockBuilder validators, ) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart index 8ffa8cfdc06..600bc0b13b4 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_object.dart @@ -1,6 +1,7 @@ import 'package:dynamite/src/builder/resolve_interface.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/built_value.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -8,7 +9,7 @@ TypeResultObject resolveObject( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, { + json_schema.JsonSchema schema, { bool nullable = false, bool isHeader = false, }) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_ofs.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_ofs.dart index 51d09f56dbf..2667137c0ce 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_ofs.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_ofs.dart @@ -4,6 +4,7 @@ import 'package:collection/collection.dart'; import 'package:dynamite/src/builder/resolve_type.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/docs.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -11,36 +12,41 @@ TypeResult resolveSomeOf( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, { + json_schema.JsonSchema schema, { bool nullable = false, }) { - final subResults = schema.ofs! - .mapIndexed( - (index, s) => resolveType( - spec, - state, - '$identifier$index', - s, - nullable: true, - ), - ) - .toBuiltSet(); + BuiltSet resolveSubTypes(BuiltList ofs) { + return ofs.mapIndexed((index, schema) { + return resolveType( + spec, + state, + '$identifier$index', + schema, + nullable: true, + ); + }).toBuiltSet(); + } TypeResultSomeOf result; - if (schema.oneOf != null) { - result = TypeResultOneOf( - identifier, - nullable: nullable, - subTypes: subResults, - ); - } else if (schema.anyOf != null) { - result = TypeResultAnyOf( - identifier, - nullable: nullable, - subTypes: subResults, - ); - } else { - throw StateError('allOf should be handled with inheritance'); + switch (schema) { + case json_schema.JsonSchema(:final oneOf) when oneOf != null: + final subResults = resolveSubTypes(oneOf); + + result = TypeResultOneOf( + identifier, + nullable: nullable, + subTypes: subResults, + ); + case json_schema.JsonSchema(:final anyOf) when anyOf != null: + final subResults = resolveSubTypes(anyOf); + + result = TypeResultAnyOf( + identifier, + nullable: nullable, + subTypes: subResults, + ); + default: + throw StateError('allOf should be handled with inheritance'); } if (state.resolvedTypes.add(result) && !result.isSingleValue) { diff --git a/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart b/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart index 2d27f2b185f..5d5794e3b46 100644 --- a/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart +++ b/packages/dynamite/dynamite/lib/src/builder/resolve_type.dart @@ -4,6 +4,7 @@ import 'package:dynamite/src/builder/resolve_object.dart'; import 'package:dynamite/src/builder/resolve_ofs.dart'; import 'package:dynamite/src/builder/state.dart'; import 'package:dynamite/src/helpers/dart_helpers.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; import 'package:dynamite/src/models/type_result.dart'; @@ -14,7 +15,7 @@ TypeResult resolveType( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, { + json_schema.JsonSchema schema, { bool nullable = false, }) { final result = _resolveType( @@ -33,11 +34,11 @@ TypeResult _resolveType( openapi.OpenAPI spec, State state, String identifier, - openapi.Schema schema, { + json_schema.JsonSchema schema, { bool nullable = false, }) { switch (schema) { - case openapi.Schema($enum: != null): + case json_schema.JsonSchema($enum: != null): final subResult = resolveType( spec, state, @@ -57,7 +58,7 @@ TypeResult _resolveType( nullable: nullable, ); - case openapi.Schema(allOf: != null): + case json_schema.JsonSchema(allOf: != null): return resolveObject( spec, state, @@ -66,13 +67,13 @@ TypeResult _resolveType( nullable: nullable, ); - case openapi.Schema(ref: null, ofs: null, type: null): + case json_schema.GenericSchema(ref: null, allOf: null, anyOf: null, oneOf: null): return TypeResultBase( 'JsonObject', nullable: nullable, ); - case openapi.Schema(ref: != null): + case json_schema.JsonSchema(ref: != null): final name = schema.ref!.fragment.split('/').last; final subResult = resolveType( spec, @@ -84,7 +85,7 @@ TypeResult _resolveType( return subResult.asTypeDef; - case openapi.Schema(anyOf: != null) || openapi.Schema(oneOf: != null): + case json_schema.JsonSchema(anyOf: != null) || json_schema.JsonSchema(oneOf: != null): return resolveSomeOf( spec, state, @@ -93,7 +94,7 @@ TypeResult _resolveType( nullable: nullable, ); - case openapi.Schema(isContentString: true): + case json_schema.StringSchema(isContentString: true): final subResult = resolveType( spec, state, @@ -107,43 +108,43 @@ TypeResult _resolveType( nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.boolean): + case json_schema.BooleanSchema(): return TypeResultBase( 'bool', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.integer): + case json_schema.IntegerSchema(): return TypeResultBase( 'int', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.number, format: 'float' || 'double'): + case json_schema.NumberSchema(format: 'float' || 'double'): return TypeResultBase( 'double', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.number): + case json_schema.NumberSchema(): return TypeResultBase( 'num', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.string, format: 'binary'): + case json_schema.StringSchema(format: 'binary'): return TypeResultBase( 'Uint8List', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.string): + case json_schema.StringSchema(): return TypeResultBase( 'String', nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.array): + case json_schema.ArraySchema(): final TypeResult subResult; if (schema.maxItems == 0) { subResult = TypeResultBase('Never'); @@ -164,7 +165,7 @@ TypeResult _resolveType( nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.object, properties: null): + case json_schema.ObjectSchema(properties: null): if (schema.additionalProperties == null) { return TypeResultBase( 'JsonObject', @@ -184,15 +185,14 @@ TypeResult _resolveType( ); } - case openapi.Schema(type: openapi.SchemaType.object, :final properties) - when properties != null && properties.isEmpty: + case json_schema.ObjectSchema(:final properties) when properties != null && properties.isEmpty: return TypeResultMap( 'BuiltMap', TypeResultBase('JsonObject'), nullable: nullable, ); - case openapi.Schema(type: openapi.SchemaType.object): + case json_schema.ObjectSchema(): return resolveObject( spec, state, diff --git a/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart b/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart index 6fa365f0014..19c940df4e0 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/dynamite.dart @@ -1,19 +1,20 @@ // ignore_for_file: avoid_positional_boolean_parameters import 'package:dynamite/src/helpers/dart_helpers.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema; import 'package:dynamite/src/models/openapi.dart' as openapi; String clientName(String tag) => '\$${toDartName(tag, className: true)}Client'; bool isDartParameterNullable( bool required, - openapi.Schema? schema, + json_schema.JsonSchema? schema, ) => (!required && schema?.$default == null) || (schema?.nullable ?? false); bool isRequired( bool required, - openapi.Schema? schema, + json_schema.JsonSchema? schema, ) => required && schema?.$default == null; diff --git a/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart b/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart index 8be3a98a9e5..af7944ebbd4 100644 --- a/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart +++ b/packages/dynamite/dynamite/lib/src/helpers/pattern_check.dart @@ -1,50 +1,51 @@ import 'package:code_builder/code_builder.dart'; -import 'package:dynamite/src/models/openapi.dart' as openapi; -import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/json_schema.dart'; Iterable buildPatternCheck( - openapi.Schema schema, + Validator schema, String value, String name, ) sync* { - switch (schema.type) { - case SchemaType.string: - if (schema.pattern != null) { + switch (schema) { + case StringValidator(): + if (schema case StringValidator(:final pattern) when pattern != null) { yield refer('checkPattern', 'package:dynamite_runtime/utils.dart').call([ refer(value).asA(refer('String?')), - refer('RegExp').call([literalString(schema.pattern!, raw: true)]), + refer('RegExp').call([literalString(pattern.pattern, raw: true)]), literalString(name), ]); } - if (schema.minLength != null) { + if (schema case StringValidator(:final minLength) when minLength != null) { yield refer('checkMinLength', 'package:dynamite_runtime/utils.dart').call([ refer(value).asA(refer('String?')), - literalNum(schema.minLength!), + literalNum(minLength), literalString(name), ]); } - if (schema.maxLength != null) { + if (schema case StringValidator(:final maxLength) when maxLength != null) { yield refer('checkMaxLength', 'package:dynamite_runtime/utils.dart').call([ refer(value).asA(refer('String?')), - literalNum(schema.maxLength!), + literalNum(maxLength), literalString(name), ]); } - case SchemaType.array: - if (schema.minItems != null) { + + case ArrayValidator(): + if (schema case ArrayValidator(:final minItems) when minItems != null) { yield refer('checkMinItems', 'package:dynamite_runtime/utils.dart').call([ refer(value).nullSafeProperty('length'), - literalNum(schema.minItems!), + literalNum(minItems), literalString(name), ]); } - if (schema.maxItems != null) { + if (schema case ArrayValidator(:final maxItems) when maxItems != null) { yield refer('checkMaxItems', 'package:dynamite_runtime/utils.dart').call([ refer(value).nullSafeProperty('length'), - literalNum(schema.maxItems!), + literalNum(maxItems), literalString(name), ]); } + default: break; } diff --git a/packages/dynamite/dynamite/lib/src/models/json_schema.dart b/packages/dynamite/dynamite/lib/src/models/json_schema.dart new file mode 100644 index 00000000000..50d16ec9892 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/json_schema.dart @@ -0,0 +1,36 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:dynamite/src/models/json_schema.dart'; +import 'package:dynamite/src/models/openapi/discriminator.dart' show Discriminator; + +export 'json_schema/schema.dart'; +export 'json_schema/validators.dart'; + +part 'json_schema.g.dart'; + +@SerializersFor([ + JsonSchema, + GenericSchema, + BooleanSchema, + IntegerSchema, + NumberSchema, + StringSchema, + ArraySchema, + ObjectSchema, + NullSchema, + JsonSchemaType, +]) +final Serializers serializers = (_$serializers.toBuilder() + ..add(JsonSchema.serializer) + ..addBuilderFactory( + const FullType(BuiltMap, [ + FullType(String), + FullType(BuiltList, [FullType(String)]), + ]), + MapBuilder>.new, + ) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const SchemaPlugin())) + .build(); diff --git a/packages/dynamite/dynamite/lib/src/models/json_schema.g.dart b/packages/dynamite/dynamite/lib/src/models/json_schema.g.dart new file mode 100644 index 00000000000..f04108a2c47 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/json_schema.g.dart @@ -0,0 +1,60 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'json_schema.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializers _$serializers = (Serializers().toBuilder() + ..add(ArraySchema.serializer) + ..add(BooleanSchema.serializer) + ..add(Discriminator.serializer) + ..add(GenericSchema.serializer) + ..add(IntegerSchema.serializer) + ..add(JsonSchemaType.serializer) + ..add(NullSchema.serializer) + ..add(NumberSchema.serializer) + ..add(ObjectSchema.serializer) + ..add(StringSchema.serializer) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltSet, [FullType(String)]), () => SetBuilder()) + ..addBuilderFactory( + const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]), () => MapBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonSchema)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) + ..addBuilderFactory(const FullType(BuiltSet, [FullType(String)]), () => SetBuilder()) + ..addBuilderFactory( + const FullType(BuiltMap, [FullType(String), FullType(String)]), () => MapBuilder())) + .build(); + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/dynamite/dynamite/lib/src/models/json_schema/schema.dart b/packages/dynamite/dynamite/lib/src/models/json_schema/schema.dart new file mode 100644 index 00000000000..4a6c4d8a06b --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/json_schema/schema.dart @@ -0,0 +1,406 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/serializer.dart'; +import 'package:dynamite/src/helpers/default_value.dart'; +import 'package:dynamite/src/helpers/docs.dart'; +import 'package:dynamite/src/helpers/logger.dart'; +import 'package:dynamite/src/models/exceptions.dart'; +import 'package:dynamite/src/models/json_schema/validators.dart'; +import 'package:dynamite/src/models/openapi.dart'; +import 'package:meta/meta.dart'; +import 'package:rfc_6901/rfc_6901.dart'; + +part 'schema.g.dart'; + +@BuiltValue(instantiable: false) +abstract interface class JsonSchema with Validator { + @BuiltValueField(wireName: r'$id') + Uri? get id; + + @BuiltValueField(wireName: r'$ref') + Uri? get ref; + + BuiltList? get oneOf; + + BuiltList? get anyOf; + + BuiltList? get allOf; + + @BuiltValueField(compare: false) + String? get description; + + bool get deprecated; + + /// https://json-schema.org/understanding-json-schema/reference/type + JsonSchemaType? get type; + + @BuiltValueField(wireName: 'default') + @protected + JsonObject? get rawDefault; + + @BuiltValueField(wireName: 'enum') + BuiltList? get $enum; + + Discriminator? get discriminator; + + bool get nullable; + + JsonSchema rebuild(void Function(JsonSchemaBuilder) updates); + JsonSchemaBuilder toBuilder(); + + static Serializer get serializer => _JsonSchemaSerializer(); + + @BuiltValueHook(finalizeBuilder: true) + static void _defaults(JsonSchemaBuilder b) { + b + ..deprecated ??= false + ..nullable ??= false; + } +} + +extension SchemaExtension on JsonSchema { + String? get formattedDescription => formatDescription(description); + + String? get $default => encodeDefault(rawDefault); + + String? get defaultDescription => encodeDefault(rawDefault, constant: false); + + JsonSchema resolveRef(Map json) { + if (ref == null) { + throw StateError(r'Referenced schema can only be resolved when a $ref is present'); + } + + final rootID = json[r'$id'] as String?; + + final Uri uri; + if (rootID != null) { + uri = Uri.parse(rootID).resolveUri(ref!); + } else { + uri = ref!; + } + + // Only relative references are supported. + final value = JsonPointer(uri.fragment).read(json); + var schema = serializers.deserializeWith(JsonSchema.serializer, value)!; + if (schema.id == null) { + schema = schema.rebuild((b) { + b.id = uri; + }); + } + + return schema; + } +} + +abstract class GenericSchema + with Validator, NumberValidator, StringValidator, ArrayValidator, ObjectValidator + implements JsonSchema, Built { + factory GenericSchema([void Function(GenericSchemaBuilder) updates]) = _$GenericSchema; + const GenericSchema._(); + + static Serializer get serializer => _$genericSchemaSerializer; + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(GenericSchemaBuilder b) { + if (b.type != null) { + throw StateError('Schema type does not match the SchemaType'); + } + + b.uniqueItems ??= false; + + JsonSchema._defaults(b); + } +} + +abstract class BooleanSchema implements JsonSchema, Built { + factory BooleanSchema([void Function(BooleanSchemaBuilder) updates]) = _$BooleanSchema; + const BooleanSchema._(); + + static Serializer get serializer => _$booleanSchemaSerializer; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(BooleanSchemaBuilder b) { + b.type = JsonSchemaType.boolean; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(BooleanSchemaBuilder b) { + if (b.type != JsonSchemaType.boolean) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + } +} + +abstract class IntegerSchema with NumberValidator implements JsonSchema, Built { + factory IntegerSchema([void Function(IntegerSchemaBuilder) updates]) = _$IntegerSchema; + IntegerSchema._(); + + static Serializer get serializer => _$integerSchemaSerializer; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(IntegerSchemaBuilder b) { + b.type = JsonSchemaType.integer; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(IntegerSchemaBuilder b) { + if (b.type != JsonSchemaType.integer) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + + const allowedIntegerFormats = [null, 'int32', 'int64']; + if (!allowedIntegerFormats.contains(b.format)) { + throw OpenAPISpecError('Format "${b.format}" is not allowed for integer. Use one of $allowedIntegerFormats.'); + } else if (b.format != null) { + dynamiteLog.integerPrecision(); + } + } +} + +abstract class NumberSchema with NumberValidator implements JsonSchema, Built { + factory NumberSchema([void Function(NumberSchemaBuilder) updates]) = _$NumberSchema; + const NumberSchema._(); + + static Serializer get serializer => _$numberSchemaSerializer; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(NumberSchemaBuilder b) { + b.type = JsonSchemaType.number; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(NumberSchemaBuilder b) { + if (b.type != JsonSchemaType.number) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + + const allowedNumberFormats = [null, 'float', 'double']; + if (!allowedNumberFormats.contains(b.format)) { + throw OpenAPISpecError('Format "${b.format}" is not allowed for number. Use one of $allowedNumberFormats.'); + } + } +} + +abstract class StringSchema with StringValidator implements JsonSchema, Built { + factory StringSchema([void Function(StringSchemaBuilder) updates]) = _$StringSchema; + const StringSchema._(); + + static Serializer get serializer => _$stringSchemaSerializer; + + String? get contentMediaType; + + JsonSchema? get contentSchema; + + @memoized + bool get isContentString => type == JsonSchemaType.string && contentMediaType != null && contentSchema != null; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(StringSchemaBuilder b) { + b.type = JsonSchemaType.string; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(StringSchemaBuilder b) { + if (b.type != JsonSchemaType.string) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + } +} + +abstract class ArraySchema with ArrayValidator implements JsonSchema, Built { + factory ArraySchema([void Function(ArraySchemaBuilder) updates]) = _$ArraySchema; + const ArraySchema._(); + + static Serializer get serializer => _$arraySchemaSerializer; + + JsonSchema? get items; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(ArraySchemaBuilder b) { + b.type = JsonSchemaType.array; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(ArraySchemaBuilder b) { + if (b.type != JsonSchemaType.array) { + throw StateError('Schema type does not match the SchemaType'); + } + + b.uniqueItems ??= false; + + JsonSchema._defaults(b); + } +} + +abstract class ObjectSchema with ObjectValidator implements JsonSchema, Built { + factory ObjectSchema([void Function(ObjectSchemaBuilder) updates]) = _$ObjectSchema; + const ObjectSchema._(); + + static Serializer get serializer => _$objectSchemaSerializer; + + BuiltMap? get properties; + + JsonSchema? get additionalProperties; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(ObjectSchemaBuilder b) { + b.type = JsonSchemaType.object; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(ObjectSchemaBuilder b) { + if (b.type != JsonSchemaType.object) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + } +} + +abstract class NullSchema implements JsonSchema, Built { + factory NullSchema([void Function(NullSchemaBuilder) updates]) = _$NullSchema; + const NullSchema._(); + + static Serializer get serializer => _$nullSchemaSerializer; + + @BuiltValueHook(initializeBuilder: true) + static void _initialize(NullSchemaBuilder b) { + b.type = JsonSchemaType.$null; + } + + @BuiltValueHook(finalizeBuilder: true) + static void _finalize(NullSchemaBuilder b) { + if (b.type != JsonSchemaType.$null) { + throw StateError('Schema type does not match the SchemaType'); + } + + JsonSchema._defaults(b); + } +} + +class JsonSchemaType extends EnumClass { + const JsonSchemaType._(super.name); + + static const JsonSchemaType boolean = _$schemaTypeBoolean; + static const JsonSchemaType integer = _$schemaTypeInteger; + static const JsonSchemaType number = _$schemaTypeNumber; + static const JsonSchemaType string = _$schemaTypeString; + static const JsonSchemaType array = _$schemaTypeArray; + static const JsonSchemaType object = _$schemaTypeObject; + @BuiltValueEnumConst(wireName: 'null') + static const JsonSchemaType $null = _$nullTypeObject; + + static BuiltSet get values => _$jsonSchemaTypeValues; + + static JsonSchemaType valueOf(String name) => _$jsonSchemaType(name); + + static Serializer get serializer => _$jsonSchemaTypeSerializer; +} + +/// A Schema value can be either a json boolean or object. +/// +/// https://json-schema.org/understanding-json-schema/basics +class SchemaPlugin implements SerializerPlugin { + const SchemaPlugin(); + + @override + Object? afterDeserialize(Object? object, FullType specifiedType) => object; + + @override + Object? afterSerialize(Object? object, FullType specifiedType) => object; + + @override + Object? beforeDeserialize(Object? object, FullType specifiedType) { + if (specifiedType.root != JsonSchema) { + return object; + } + + switch (object) { + case null: + return null; + + case bool _: + if (object) { + // An empty list in BuiltValue it equivalent to the empty json object. + return []; + } else { + throw UnsupportedError('The never matching schema is not yet supported.'); + } + + default: + return object; + } + } + + @override + Object? beforeSerialize(Object? object, FullType specifiedType) => object; +} + +class _JsonSchemaSerializer extends StructuredSerializer { + _JsonSchemaSerializer(); + + @override + final Iterable types = const [JsonSchema]; + + @override + final String wireName = 'JsonSchema'; + + static final _schemaTypeToType = { + null: GenericSchema.serializer, + JsonSchemaType.boolean: BooleanSchema.serializer, + JsonSchemaType.integer: IntegerSchema.serializer, + JsonSchemaType.number: NumberSchema.serializer, + JsonSchemaType.string: StringSchema.serializer, + JsonSchemaType.array: ArraySchema.serializer, + JsonSchemaType.object: ObjectSchema.serializer, + JsonSchemaType.$null: NullSchema.serializer, + }; + + @override + JsonSchema deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + if (key == 'type') { + break; + } + } + + final value = iterator.current; + final type = serializers.deserializeWith( + JsonSchemaType.serializer, + value, + ); + + return serializers.deserializeWith( + _schemaTypeToType[type]!, + serialized, + )!; + } + + @override + Iterable serialize( + Serializers serializers, + JsonSchema object, { + FullType specifiedType = FullType.unspecified, + }) { + return serializers.serializeWith( + _schemaTypeToType[object.type]!, + object, + )! as Iterable; + } +} diff --git a/packages/dynamite/dynamite/lib/src/models/json_schema/schema.g.dart b/packages/dynamite/dynamite/lib/src/models/json_schema/schema.g.dart new file mode 100644 index 00000000000..01e66bd12b0 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/json_schema/schema.g.dart @@ -0,0 +1,4255 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'schema.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +const JsonSchemaType _$schemaTypeBoolean = JsonSchemaType._('boolean'); +const JsonSchemaType _$schemaTypeInteger = JsonSchemaType._('integer'); +const JsonSchemaType _$schemaTypeNumber = JsonSchemaType._('number'); +const JsonSchemaType _$schemaTypeString = JsonSchemaType._('string'); +const JsonSchemaType _$schemaTypeArray = JsonSchemaType._('array'); +const JsonSchemaType _$schemaTypeObject = JsonSchemaType._('object'); +const JsonSchemaType _$nullTypeObject = JsonSchemaType._('\$null'); + +JsonSchemaType _$jsonSchemaType(String name) { + switch (name) { + case 'boolean': + return _$schemaTypeBoolean; + case 'integer': + return _$schemaTypeInteger; + case 'number': + return _$schemaTypeNumber; + case 'string': + return _$schemaTypeString; + case 'array': + return _$schemaTypeArray; + case 'object': + return _$schemaTypeObject; + case '\$null': + return _$nullTypeObject; + default: + throw ArgumentError(name); + } +} + +final BuiltSet _$jsonSchemaTypeValues = BuiltSet(const [ + _$schemaTypeBoolean, + _$schemaTypeInteger, + _$schemaTypeNumber, + _$schemaTypeString, + _$schemaTypeArray, + _$schemaTypeObject, + _$nullTypeObject, +]); + +Serializer _$genericSchemaSerializer = _$GenericSchemaSerializer(); +Serializer _$booleanSchemaSerializer = _$BooleanSchemaSerializer(); +Serializer _$integerSchemaSerializer = _$IntegerSchemaSerializer(); +Serializer _$numberSchemaSerializer = _$NumberSchemaSerializer(); +Serializer _$stringSchemaSerializer = _$StringSchemaSerializer(); +Serializer _$arraySchemaSerializer = _$ArraySchemaSerializer(); +Serializer _$objectSchemaSerializer = _$ObjectSchemaSerializer(); +Serializer _$nullSchemaSerializer = _$NullSchemaSerializer(); +Serializer _$jsonSchemaTypeSerializer = _$JsonSchemaTypeSerializer(); + +class _$GenericSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [GenericSchema, _$GenericSchema]; + @override + final String wireName = 'GenericSchema'; + + @override + Iterable serialize(Serializers serializers, GenericSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + 'uniqueItems', + serializers.serialize(object.uniqueItems, specifiedType: const FullType(bool)), + 'required', + serializers.serialize(object.required, specifiedType: const FullType(BuiltSet, [FullType(String)])), + ]; + Object? value; + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.multipleOf; + if (value != null) { + result + ..add('multipleOf') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.maximum; + if (value != null) { + result + ..add('maximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMaximum; + if (value != null) { + result + ..add('exclusiveMaximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.minimum; + if (value != null) { + result + ..add('minimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMinimum; + if (value != null) { + result + ..add('exclusiveMinimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.maxLength; + if (value != null) { + result + ..add('maxLength') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minLength; + if (value != null) { + result + ..add('minLength') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.pattern; + if (value != null) { + result + ..add('pattern') + ..add(serializers.serialize(value, specifiedType: const FullType(RegExp))); + } + value = object.maxItems; + if (value != null) { + result + ..add('maxItems') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minItems; + if (value != null) { + result + ..add('minItems') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.maxContains; + if (value != null) { + result + ..add('maxContains') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minContains; + if (value != null) { + result + ..add('minContains') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.maxProperties; + if (value != null) { + result + ..add('maxProperties') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minProperties; + if (value != null) { + result + ..add('minProperties') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.dependentRequired; + if (value != null) { + result + ..add('dependentRequired') + ..add(serializers.serialize(value, + specifiedType: const FullType(Map, [ + FullType(String), + FullType(BuiltSet, [FullType(String)]) + ]))); + } + return result; + } + + @override + GenericSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = GenericSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'multipleOf': + result.multipleOf = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'maximum': + result.maximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMaximum': + result.exclusiveMaximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'minimum': + result.minimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMinimum': + result.exclusiveMinimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'maxLength': + result.maxLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minLength': + result.minLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'pattern': + result.pattern = serializers.deserialize(value, specifiedType: const FullType(RegExp)) as RegExp?; + break; + case 'maxItems': + result.maxItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minItems': + result.minItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'uniqueItems': + result.uniqueItems = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'maxContains': + result.maxContains = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minContains': + result.minContains = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'maxProperties': + result.maxProperties = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minProperties': + result.minProperties = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'required': + result.required.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltSet, [FullType(String)]))! as BuiltSet); + break; + case 'dependentRequired': + result.dependentRequired = serializers.deserialize(value, + specifiedType: const FullType(Map, [ + FullType(String), + FullType(BuiltSet, [FullType(String)]) + ])) as Map>?; + break; + } + } + + return result.build(); + } +} + +class _$BooleanSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [BooleanSchema, _$BooleanSchema]; + @override + final String wireName = 'BooleanSchema'; + + @override + Iterable serialize(Serializers serializers, BooleanSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + return result; + } + + @override + BooleanSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = BooleanSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$IntegerSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [IntegerSchema, _$IntegerSchema]; + @override + final String wireName = 'IntegerSchema'; + + @override + Iterable serialize(Serializers serializers, IntegerSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.multipleOf; + if (value != null) { + result + ..add('multipleOf') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.maximum; + if (value != null) { + result + ..add('maximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMaximum; + if (value != null) { + result + ..add('exclusiveMaximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.minimum; + if (value != null) { + result + ..add('minimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMinimum; + if (value != null) { + result + ..add('exclusiveMinimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + return result; + } + + @override + IntegerSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = IntegerSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'multipleOf': + result.multipleOf = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'maximum': + result.maximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMaximum': + result.exclusiveMaximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'minimum': + result.minimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMinimum': + result.exclusiveMinimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + } + } + + return result.build(); + } +} + +class _$NumberSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [NumberSchema, _$NumberSchema]; + @override + final String wireName = 'NumberSchema'; + + @override + Iterable serialize(Serializers serializers, NumberSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.multipleOf; + if (value != null) { + result + ..add('multipleOf') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.maximum; + if (value != null) { + result + ..add('maximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMaximum; + if (value != null) { + result + ..add('exclusiveMaximum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.minimum; + if (value != null) { + result + ..add('minimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + value = object.exclusiveMinimum; + if (value != null) { + result + ..add('exclusiveMinimum') + ..add(serializers.serialize(value, specifiedType: const FullType(num))); + } + return result; + } + + @override + NumberSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = NumberSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'multipleOf': + result.multipleOf = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'maximum': + result.maximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMaximum': + result.exclusiveMaximum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'minimum': + result.minimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + case 'exclusiveMinimum': + result.exclusiveMinimum = serializers.deserialize(value, specifiedType: const FullType(num)) as num?; + break; + } + } + + return result.build(); + } +} + +class _$StringSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [StringSchema, _$StringSchema]; + @override + final String wireName = 'StringSchema'; + + @override + Iterable serialize(Serializers serializers, StringSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.contentMediaType; + if (value != null) { + result + ..add('contentMediaType') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.contentSchema; + if (value != null) { + result + ..add('contentSchema') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); + } + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.maxLength; + if (value != null) { + result + ..add('maxLength') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minLength; + if (value != null) { + result + ..add('minLength') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.pattern; + if (value != null) { + result + ..add('pattern') + ..add(serializers.serialize(value, specifiedType: const FullType(RegExp))); + } + return result; + } + + @override + StringSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = StringSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'contentMediaType': + result.contentMediaType = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'contentSchema': + result.contentSchema = + serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; + break; + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'maxLength': + result.maxLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minLength': + result.minLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'pattern': + result.pattern = serializers.deserialize(value, specifiedType: const FullType(RegExp)) as RegExp?; + break; + } + } + + return result.build(); + } +} + +class _$ArraySchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [ArraySchema, _$ArraySchema]; + @override + final String wireName = 'ArraySchema'; + + @override + Iterable serialize(Serializers serializers, ArraySchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + 'uniqueItems', + serializers.serialize(object.uniqueItems, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.items; + if (value != null) { + result + ..add('items') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); + } + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.maxItems; + if (value != null) { + result + ..add('maxItems') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minItems; + if (value != null) { + result + ..add('minItems') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.maxContains; + if (value != null) { + result + ..add('maxContains') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minContains; + if (value != null) { + result + ..add('minContains') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + return result; + } + + @override + ArraySchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ArraySchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'items': + result.items = serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; + break; + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'maxItems': + result.maxItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minItems': + result.minItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'uniqueItems': + result.uniqueItems = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'maxContains': + result.maxContains = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minContains': + result.minContains = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + } + } + + return result.build(); + } +} + +class _$ObjectSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectSchema, _$ObjectSchema]; + @override + final String wireName = 'ObjectSchema'; + + @override + Iterable serialize(Serializers serializers, ObjectSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + 'required', + serializers.serialize(object.required, specifiedType: const FullType(BuiltSet, [FullType(String)])), + ]; + Object? value; + value = object.properties; + if (value != null) { + result + ..add('properties') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]))); + } + value = object.additionalProperties; + if (value != null) { + result + ..add('additionalProperties') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); + } + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.maxProperties; + if (value != null) { + result + ..add('maxProperties') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.minProperties; + if (value != null) { + result + ..add('minProperties') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.dependentRequired; + if (value != null) { + result + ..add('dependentRequired') + ..add(serializers.serialize(value, + specifiedType: const FullType(Map, [ + FullType(String), + FullType(BuiltSet, [FullType(String)]) + ]))); + } + return result; + } + + @override + ObjectSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'properties': + result.properties.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]))!); + break; + case 'additionalProperties': + result.additionalProperties = + serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; + break; + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'maxProperties': + result.maxProperties = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'minProperties': + result.minProperties = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; + break; + case 'required': + result.required.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltSet, [FullType(String)]))! as BuiltSet); + break; + case 'dependentRequired': + result.dependentRequired = serializers.deserialize(value, + specifiedType: const FullType(Map, [ + FullType(String), + FullType(BuiltSet, [FullType(String)]) + ])) as Map>?; + break; + } + } + + return result.build(); + } +} + +class _$NullSchemaSerializer implements StructuredSerializer { + @override + final Iterable types = const [NullSchema, _$NullSchema]; + @override + final String wireName = 'NullSchema'; + + @override + Iterable serialize(Serializers serializers, NullSchema object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'deprecated', + serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), + 'nullable', + serializers.serialize(object.nullable, specifiedType: const FullType(bool)), + ]; + Object? value; + value = object.id; + if (value != null) { + result + ..add('\$id') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.ref; + if (value != null) { + result + ..add('\$ref') + ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); + } + value = object.oneOf; + if (value != null) { + result + ..add('oneOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.anyOf; + if (value != null) { + result + ..add('anyOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.allOf; + if (value != null) { + result + ..add('allOf') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))); + } + value = object.description; + if (value != null) { + result + ..add('description') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + value = object.type; + if (value != null) { + result + ..add('type') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchemaType))); + } + value = object.rawDefault; + if (value != null) { + result + ..add('default') + ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); + } + value = object.$enum; + if (value != null) { + result + ..add('enum') + ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); + } + value = object.discriminator; + if (value != null) { + result + ..add('discriminator') + ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); + } + value = object.format; + if (value != null) { + result + ..add('format') + ..add(serializers.serialize(value, specifiedType: const FullType(String))); + } + return result; + } + + @override + NullSchema deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = NullSchemaBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '\$id': + result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case '\$ref': + result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; + break; + case 'oneOf': + result.oneOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'anyOf': + result.anyOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'allOf': + result.allOf.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonSchema)]))! as BuiltList); + break; + case 'description': + result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + case 'deprecated': + result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'type': + result.type = + serializers.deserialize(value, specifiedType: const FullType(JsonSchemaType)) as JsonSchemaType?; + break; + case 'default': + result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; + break; + case 'enum': + result.$enum.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); + break; + case 'discriminator': + result.discriminator + .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); + break; + case 'nullable': + result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'format': + result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$JsonSchemaTypeSerializer implements PrimitiveSerializer { + static const Map _toWire = { + '\$null': 'null', + }; + static const Map _fromWire = { + 'null': '\$null', + }; + + @override + final Iterable types = const [JsonSchemaType]; + @override + final String wireName = 'JsonSchemaType'; + + @override + Object serialize(Serializers serializers, JsonSchemaType object, {FullType specifiedType = FullType.unspecified}) => + _toWire[object.name] ?? object.name; + + @override + JsonSchemaType deserialize(Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) => + JsonSchemaType.valueOf(_fromWire[serialized] ?? (serialized is String ? serialized : '')); +} + +abstract mixin class JsonSchemaBuilder { + void replace(JsonSchema other); + void update(void Function(JsonSchemaBuilder) updates); + Uri? get id; + set id(Uri? id); + + Uri? get ref; + set ref(Uri? ref); + + ListBuilder get oneOf; + set oneOf(ListBuilder? oneOf); + + ListBuilder get anyOf; + set anyOf(ListBuilder? anyOf); + + ListBuilder get allOf; + set allOf(ListBuilder? allOf); + + String? get description; + set description(String? description); + + bool? get deprecated; + set deprecated(bool? deprecated); + + JsonSchemaType? get type; + set type(JsonSchemaType? type); + + JsonObject? get rawDefault; + set rawDefault(JsonObject? rawDefault); + + ListBuilder get $enum; + set $enum(ListBuilder? $enum); + + DiscriminatorBuilder get discriminator; + set discriminator(DiscriminatorBuilder? discriminator); + + bool? get nullable; + set nullable(bool? nullable); + + String? get format; + set format(String? format); +} + +class _$GenericSchema extends GenericSchema { + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final num? multipleOf; + @override + final num? maximum; + @override + final num? exclusiveMaximum; + @override + final num? minimum; + @override + final num? exclusiveMinimum; + @override + final int? maxLength; + @override + final int? minLength; + @override + final RegExp? pattern; + @override + final int? maxItems; + @override + final int? minItems; + @override + final bool uniqueItems; + @override + final int? maxContains; + @override + final int? minContains; + @override + final int? maxProperties; + @override + final int? minProperties; + @override + final BuiltSet required; + @override + final Map>? dependentRequired; + + factory _$GenericSchema([void Function(GenericSchemaBuilder)? updates]) => + (GenericSchemaBuilder()..update(updates))._build(); + + _$GenericSchema._( + {this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.multipleOf, + this.maximum, + this.exclusiveMaximum, + this.minimum, + this.exclusiveMinimum, + this.maxLength, + this.minLength, + this.pattern, + this.maxItems, + this.minItems, + required this.uniqueItems, + this.maxContains, + this.minContains, + this.maxProperties, + this.minProperties, + required this.required, + this.dependentRequired}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'GenericSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'GenericSchema', 'nullable'); + BuiltValueNullFieldError.checkNotNull(uniqueItems, r'GenericSchema', 'uniqueItems'); + BuiltValueNullFieldError.checkNotNull(required, r'GenericSchema', 'required'); + } + + @override + GenericSchema rebuild(void Function(GenericSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + GenericSchemaBuilder toBuilder() => GenericSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GenericSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + multipleOf == other.multipleOf && + maximum == other.maximum && + exclusiveMaximum == other.exclusiveMaximum && + minimum == other.minimum && + exclusiveMinimum == other.exclusiveMinimum && + maxLength == other.maxLength && + minLength == other.minLength && + pattern == other.pattern && + maxItems == other.maxItems && + minItems == other.minItems && + uniqueItems == other.uniqueItems && + maxContains == other.maxContains && + minContains == other.minContains && + maxProperties == other.maxProperties && + minProperties == other.minProperties && + required == other.required && + dependentRequired == other.dependentRequired; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, multipleOf.hashCode); + _$hash = $jc(_$hash, maximum.hashCode); + _$hash = $jc(_$hash, exclusiveMaximum.hashCode); + _$hash = $jc(_$hash, minimum.hashCode); + _$hash = $jc(_$hash, exclusiveMinimum.hashCode); + _$hash = $jc(_$hash, maxLength.hashCode); + _$hash = $jc(_$hash, minLength.hashCode); + _$hash = $jc(_$hash, pattern.hashCode); + _$hash = $jc(_$hash, maxItems.hashCode); + _$hash = $jc(_$hash, minItems.hashCode); + _$hash = $jc(_$hash, uniqueItems.hashCode); + _$hash = $jc(_$hash, maxContains.hashCode); + _$hash = $jc(_$hash, minContains.hashCode); + _$hash = $jc(_$hash, maxProperties.hashCode); + _$hash = $jc(_$hash, minProperties.hashCode); + _$hash = $jc(_$hash, required.hashCode); + _$hash = $jc(_$hash, dependentRequired.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GenericSchema') + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('multipleOf', multipleOf) + ..add('maximum', maximum) + ..add('exclusiveMaximum', exclusiveMaximum) + ..add('minimum', minimum) + ..add('exclusiveMinimum', exclusiveMinimum) + ..add('maxLength', maxLength) + ..add('minLength', minLength) + ..add('pattern', pattern) + ..add('maxItems', maxItems) + ..add('minItems', minItems) + ..add('uniqueItems', uniqueItems) + ..add('maxContains', maxContains) + ..add('minContains', minContains) + ..add('maxProperties', maxProperties) + ..add('minProperties', minProperties) + ..add('required', required) + ..add('dependentRequired', dependentRequired)) + .toString(); + } +} + +class GenericSchemaBuilder implements Builder, JsonSchemaBuilder { + _$GenericSchema? _$v; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + num? _multipleOf; + num? get multipleOf => _$this._multipleOf; + set multipleOf(covariant num? multipleOf) => _$this._multipleOf = multipleOf; + + num? _maximum; + num? get maximum => _$this._maximum; + set maximum(covariant num? maximum) => _$this._maximum = maximum; + + num? _exclusiveMaximum; + num? get exclusiveMaximum => _$this._exclusiveMaximum; + set exclusiveMaximum(covariant num? exclusiveMaximum) => _$this._exclusiveMaximum = exclusiveMaximum; + + num? _minimum; + num? get minimum => _$this._minimum; + set minimum(covariant num? minimum) => _$this._minimum = minimum; + + num? _exclusiveMinimum; + num? get exclusiveMinimum => _$this._exclusiveMinimum; + set exclusiveMinimum(covariant num? exclusiveMinimum) => _$this._exclusiveMinimum = exclusiveMinimum; + + int? _maxLength; + int? get maxLength => _$this._maxLength; + set maxLength(covariant int? maxLength) => _$this._maxLength = maxLength; + + int? _minLength; + int? get minLength => _$this._minLength; + set minLength(covariant int? minLength) => _$this._minLength = minLength; + + RegExp? _pattern; + RegExp? get pattern => _$this._pattern; + set pattern(covariant RegExp? pattern) => _$this._pattern = pattern; + + int? _maxItems; + int? get maxItems => _$this._maxItems; + set maxItems(covariant int? maxItems) => _$this._maxItems = maxItems; + + int? _minItems; + int? get minItems => _$this._minItems; + set minItems(covariant int? minItems) => _$this._minItems = minItems; + + bool? _uniqueItems; + bool? get uniqueItems => _$this._uniqueItems; + set uniqueItems(covariant bool? uniqueItems) => _$this._uniqueItems = uniqueItems; + + int? _maxContains; + int? get maxContains => _$this._maxContains; + set maxContains(covariant int? maxContains) => _$this._maxContains = maxContains; + + int? _minContains; + int? get minContains => _$this._minContains; + set minContains(covariant int? minContains) => _$this._minContains = minContains; + + int? _maxProperties; + int? get maxProperties => _$this._maxProperties; + set maxProperties(covariant int? maxProperties) => _$this._maxProperties = maxProperties; + + int? _minProperties; + int? get minProperties => _$this._minProperties; + set minProperties(covariant int? minProperties) => _$this._minProperties = minProperties; + + SetBuilder? _required; + SetBuilder get required => _$this._required ??= SetBuilder(); + set required(covariant SetBuilder? required) => _$this._required = required; + + Map>? _dependentRequired; + Map>? get dependentRequired => _$this._dependentRequired; + set dependentRequired(covariant Map>? dependentRequired) => + _$this._dependentRequired = dependentRequired; + + GenericSchemaBuilder(); + + GenericSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _multipleOf = $v.multipleOf; + _maximum = $v.maximum; + _exclusiveMaximum = $v.exclusiveMaximum; + _minimum = $v.minimum; + _exclusiveMinimum = $v.exclusiveMinimum; + _maxLength = $v.maxLength; + _minLength = $v.minLength; + _pattern = $v.pattern; + _maxItems = $v.maxItems; + _minItems = $v.minItems; + _uniqueItems = $v.uniqueItems; + _maxContains = $v.maxContains; + _minContains = $v.minContains; + _maxProperties = $v.maxProperties; + _minProperties = $v.minProperties; + _required = $v.required.toBuilder(); + _dependentRequired = $v.dependentRequired; + _$v = null; + } + return this; + } + + @override + void replace(covariant GenericSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GenericSchema; + } + + @override + void update(void Function(GenericSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GenericSchema build() => _build(); + + _$GenericSchema _build() { + GenericSchema._finalize(this); + _$GenericSchema _$result; + try { + _$result = _$v ?? + _$GenericSchema._( + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'GenericSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'GenericSchema', 'nullable'), + format: format, + multipleOf: multipleOf, + maximum: maximum, + exclusiveMaximum: exclusiveMaximum, + minimum: minimum, + exclusiveMinimum: exclusiveMinimum, + maxLength: maxLength, + minLength: minLength, + pattern: pattern, + maxItems: maxItems, + minItems: minItems, + uniqueItems: BuiltValueNullFieldError.checkNotNull(uniqueItems, r'GenericSchema', 'uniqueItems'), + maxContains: maxContains, + minContains: minContains, + maxProperties: maxProperties, + minProperties: minProperties, + required: required.build(), + dependentRequired: dependentRequired); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + + _$failedField = 'required'; + required.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'GenericSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$BooleanSchema extends BooleanSchema { + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + + factory _$BooleanSchema([void Function(BooleanSchemaBuilder)? updates]) => + (BooleanSchemaBuilder()..update(updates))._build(); + + _$BooleanSchema._( + {this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'BooleanSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'BooleanSchema', 'nullable'); + } + + @override + BooleanSchema rebuild(void Function(BooleanSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + BooleanSchemaBuilder toBuilder() => BooleanSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is BooleanSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'BooleanSchema') + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format)) + .toString(); + } +} + +class BooleanSchemaBuilder implements Builder, JsonSchemaBuilder { + _$BooleanSchema? _$v; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + BooleanSchemaBuilder() { + BooleanSchema._initialize(this); + } + + BooleanSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _$v = null; + } + return this; + } + + @override + void replace(covariant BooleanSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$BooleanSchema; + } + + @override + void update(void Function(BooleanSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + BooleanSchema build() => _build(); + + _$BooleanSchema _build() { + BooleanSchema._finalize(this); + _$BooleanSchema _$result; + try { + _$result = _$v ?? + _$BooleanSchema._( + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'BooleanSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'BooleanSchema', 'nullable'), + format: format); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'BooleanSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$IntegerSchema extends IntegerSchema { + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final num? multipleOf; + @override + final num? maximum; + @override + final num? exclusiveMaximum; + @override + final num? minimum; + @override + final num? exclusiveMinimum; + + factory _$IntegerSchema([void Function(IntegerSchemaBuilder)? updates]) => + (IntegerSchemaBuilder()..update(updates))._build(); + + _$IntegerSchema._( + {this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.multipleOf, + this.maximum, + this.exclusiveMaximum, + this.minimum, + this.exclusiveMinimum}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'IntegerSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'IntegerSchema', 'nullable'); + } + + @override + IntegerSchema rebuild(void Function(IntegerSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + IntegerSchemaBuilder toBuilder() => IntegerSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is IntegerSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + multipleOf == other.multipleOf && + maximum == other.maximum && + exclusiveMaximum == other.exclusiveMaximum && + minimum == other.minimum && + exclusiveMinimum == other.exclusiveMinimum; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, multipleOf.hashCode); + _$hash = $jc(_$hash, maximum.hashCode); + _$hash = $jc(_$hash, exclusiveMaximum.hashCode); + _$hash = $jc(_$hash, minimum.hashCode); + _$hash = $jc(_$hash, exclusiveMinimum.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'IntegerSchema') + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('multipleOf', multipleOf) + ..add('maximum', maximum) + ..add('exclusiveMaximum', exclusiveMaximum) + ..add('minimum', minimum) + ..add('exclusiveMinimum', exclusiveMinimum)) + .toString(); + } +} + +class IntegerSchemaBuilder implements Builder, JsonSchemaBuilder { + _$IntegerSchema? _$v; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + num? _multipleOf; + num? get multipleOf => _$this._multipleOf; + set multipleOf(covariant num? multipleOf) => _$this._multipleOf = multipleOf; + + num? _maximum; + num? get maximum => _$this._maximum; + set maximum(covariant num? maximum) => _$this._maximum = maximum; + + num? _exclusiveMaximum; + num? get exclusiveMaximum => _$this._exclusiveMaximum; + set exclusiveMaximum(covariant num? exclusiveMaximum) => _$this._exclusiveMaximum = exclusiveMaximum; + + num? _minimum; + num? get minimum => _$this._minimum; + set minimum(covariant num? minimum) => _$this._minimum = minimum; + + num? _exclusiveMinimum; + num? get exclusiveMinimum => _$this._exclusiveMinimum; + set exclusiveMinimum(covariant num? exclusiveMinimum) => _$this._exclusiveMinimum = exclusiveMinimum; + + IntegerSchemaBuilder() { + IntegerSchema._initialize(this); + } + + IntegerSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _multipleOf = $v.multipleOf; + _maximum = $v.maximum; + _exclusiveMaximum = $v.exclusiveMaximum; + _minimum = $v.minimum; + _exclusiveMinimum = $v.exclusiveMinimum; + _$v = null; + } + return this; + } + + @override + void replace(covariant IntegerSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$IntegerSchema; + } + + @override + void update(void Function(IntegerSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + IntegerSchema build() => _build(); + + _$IntegerSchema _build() { + IntegerSchema._finalize(this); + _$IntegerSchema _$result; + try { + _$result = _$v ?? + _$IntegerSchema._( + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'IntegerSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'IntegerSchema', 'nullable'), + format: format, + multipleOf: multipleOf, + maximum: maximum, + exclusiveMaximum: exclusiveMaximum, + minimum: minimum, + exclusiveMinimum: exclusiveMinimum); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'IntegerSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$NumberSchema extends NumberSchema { + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final num? multipleOf; + @override + final num? maximum; + @override + final num? exclusiveMaximum; + @override + final num? minimum; + @override + final num? exclusiveMinimum; + + factory _$NumberSchema([void Function(NumberSchemaBuilder)? updates]) => + (NumberSchemaBuilder()..update(updates))._build(); + + _$NumberSchema._( + {this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.multipleOf, + this.maximum, + this.exclusiveMaximum, + this.minimum, + this.exclusiveMinimum}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'NumberSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'NumberSchema', 'nullable'); + } + + @override + NumberSchema rebuild(void Function(NumberSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + NumberSchemaBuilder toBuilder() => NumberSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is NumberSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + multipleOf == other.multipleOf && + maximum == other.maximum && + exclusiveMaximum == other.exclusiveMaximum && + minimum == other.minimum && + exclusiveMinimum == other.exclusiveMinimum; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, multipleOf.hashCode); + _$hash = $jc(_$hash, maximum.hashCode); + _$hash = $jc(_$hash, exclusiveMaximum.hashCode); + _$hash = $jc(_$hash, minimum.hashCode); + _$hash = $jc(_$hash, exclusiveMinimum.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'NumberSchema') + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('multipleOf', multipleOf) + ..add('maximum', maximum) + ..add('exclusiveMaximum', exclusiveMaximum) + ..add('minimum', minimum) + ..add('exclusiveMinimum', exclusiveMinimum)) + .toString(); + } +} + +class NumberSchemaBuilder implements Builder, JsonSchemaBuilder { + _$NumberSchema? _$v; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + num? _multipleOf; + num? get multipleOf => _$this._multipleOf; + set multipleOf(covariant num? multipleOf) => _$this._multipleOf = multipleOf; + + num? _maximum; + num? get maximum => _$this._maximum; + set maximum(covariant num? maximum) => _$this._maximum = maximum; + + num? _exclusiveMaximum; + num? get exclusiveMaximum => _$this._exclusiveMaximum; + set exclusiveMaximum(covariant num? exclusiveMaximum) => _$this._exclusiveMaximum = exclusiveMaximum; + + num? _minimum; + num? get minimum => _$this._minimum; + set minimum(covariant num? minimum) => _$this._minimum = minimum; + + num? _exclusiveMinimum; + num? get exclusiveMinimum => _$this._exclusiveMinimum; + set exclusiveMinimum(covariant num? exclusiveMinimum) => _$this._exclusiveMinimum = exclusiveMinimum; + + NumberSchemaBuilder() { + NumberSchema._initialize(this); + } + + NumberSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _multipleOf = $v.multipleOf; + _maximum = $v.maximum; + _exclusiveMaximum = $v.exclusiveMaximum; + _minimum = $v.minimum; + _exclusiveMinimum = $v.exclusiveMinimum; + _$v = null; + } + return this; + } + + @override + void replace(covariant NumberSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$NumberSchema; + } + + @override + void update(void Function(NumberSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + NumberSchema build() => _build(); + + _$NumberSchema _build() { + NumberSchema._finalize(this); + _$NumberSchema _$result; + try { + _$result = _$v ?? + _$NumberSchema._( + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'NumberSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'NumberSchema', 'nullable'), + format: format, + multipleOf: multipleOf, + maximum: maximum, + exclusiveMaximum: exclusiveMaximum, + minimum: minimum, + exclusiveMinimum: exclusiveMinimum); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'NumberSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$StringSchema extends StringSchema { + @override + final String? contentMediaType; + @override + final JsonSchema? contentSchema; + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final int? maxLength; + @override + final int? minLength; + @override + final RegExp? pattern; + bool? __isContentString; + + factory _$StringSchema([void Function(StringSchemaBuilder)? updates]) => + (StringSchemaBuilder()..update(updates))._build(); + + _$StringSchema._( + {this.contentMediaType, + this.contentSchema, + this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.maxLength, + this.minLength, + this.pattern}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'StringSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'StringSchema', 'nullable'); + } + + @override + bool get isContentString => __isContentString ??= super.isContentString; + + @override + StringSchema rebuild(void Function(StringSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + StringSchemaBuilder toBuilder() => StringSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is StringSchema && + contentMediaType == other.contentMediaType && + contentSchema == other.contentSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + maxLength == other.maxLength && + minLength == other.minLength && + pattern == other.pattern; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, contentMediaType.hashCode); + _$hash = $jc(_$hash, contentSchema.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, maxLength.hashCode); + _$hash = $jc(_$hash, minLength.hashCode); + _$hash = $jc(_$hash, pattern.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'StringSchema') + ..add('contentMediaType', contentMediaType) + ..add('contentSchema', contentSchema) + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('maxLength', maxLength) + ..add('minLength', minLength) + ..add('pattern', pattern)) + .toString(); + } +} + +class StringSchemaBuilder implements Builder, JsonSchemaBuilder { + _$StringSchema? _$v; + + String? _contentMediaType; + String? get contentMediaType => _$this._contentMediaType; + set contentMediaType(covariant String? contentMediaType) => _$this._contentMediaType = contentMediaType; + + JsonSchema? _contentSchema; + JsonSchema? get contentSchema => _$this._contentSchema; + set contentSchema(covariant JsonSchema? contentSchema) => _$this._contentSchema = contentSchema; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + int? _maxLength; + int? get maxLength => _$this._maxLength; + set maxLength(covariant int? maxLength) => _$this._maxLength = maxLength; + + int? _minLength; + int? get minLength => _$this._minLength; + set minLength(covariant int? minLength) => _$this._minLength = minLength; + + RegExp? _pattern; + RegExp? get pattern => _$this._pattern; + set pattern(covariant RegExp? pattern) => _$this._pattern = pattern; + + StringSchemaBuilder() { + StringSchema._initialize(this); + } + + StringSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _contentMediaType = $v.contentMediaType; + _contentSchema = $v.contentSchema; + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _maxLength = $v.maxLength; + _minLength = $v.minLength; + _pattern = $v.pattern; + _$v = null; + } + return this; + } + + @override + void replace(covariant StringSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$StringSchema; + } + + @override + void update(void Function(StringSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + StringSchema build() => _build(); + + _$StringSchema _build() { + StringSchema._finalize(this); + _$StringSchema _$result; + try { + _$result = _$v ?? + _$StringSchema._( + contentMediaType: contentMediaType, + contentSchema: contentSchema, + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'StringSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'StringSchema', 'nullable'), + format: format, + maxLength: maxLength, + minLength: minLength, + pattern: pattern); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'StringSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$ArraySchema extends ArraySchema { + @override + final JsonSchema? items; + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final int? maxItems; + @override + final int? minItems; + @override + final bool uniqueItems; + @override + final int? maxContains; + @override + final int? minContains; + + factory _$ArraySchema([void Function(ArraySchemaBuilder)? updates]) => + (ArraySchemaBuilder()..update(updates))._build(); + + _$ArraySchema._( + {this.items, + this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.maxItems, + this.minItems, + required this.uniqueItems, + this.maxContains, + this.minContains}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'ArraySchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'ArraySchema', 'nullable'); + BuiltValueNullFieldError.checkNotNull(uniqueItems, r'ArraySchema', 'uniqueItems'); + } + + @override + ArraySchema rebuild(void Function(ArraySchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + ArraySchemaBuilder toBuilder() => ArraySchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ArraySchema && + items == other.items && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + maxItems == other.maxItems && + minItems == other.minItems && + uniqueItems == other.uniqueItems && + maxContains == other.maxContains && + minContains == other.minContains; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, items.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, maxItems.hashCode); + _$hash = $jc(_$hash, minItems.hashCode); + _$hash = $jc(_$hash, uniqueItems.hashCode); + _$hash = $jc(_$hash, maxContains.hashCode); + _$hash = $jc(_$hash, minContains.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ArraySchema') + ..add('items', items) + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('maxItems', maxItems) + ..add('minItems', minItems) + ..add('uniqueItems', uniqueItems) + ..add('maxContains', maxContains) + ..add('minContains', minContains)) + .toString(); + } +} + +class ArraySchemaBuilder implements Builder, JsonSchemaBuilder { + _$ArraySchema? _$v; + + JsonSchema? _items; + JsonSchema? get items => _$this._items; + set items(covariant JsonSchema? items) => _$this._items = items; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + int? _maxItems; + int? get maxItems => _$this._maxItems; + set maxItems(covariant int? maxItems) => _$this._maxItems = maxItems; + + int? _minItems; + int? get minItems => _$this._minItems; + set minItems(covariant int? minItems) => _$this._minItems = minItems; + + bool? _uniqueItems; + bool? get uniqueItems => _$this._uniqueItems; + set uniqueItems(covariant bool? uniqueItems) => _$this._uniqueItems = uniqueItems; + + int? _maxContains; + int? get maxContains => _$this._maxContains; + set maxContains(covariant int? maxContains) => _$this._maxContains = maxContains; + + int? _minContains; + int? get minContains => _$this._minContains; + set minContains(covariant int? minContains) => _$this._minContains = minContains; + + ArraySchemaBuilder() { + ArraySchema._initialize(this); + } + + ArraySchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _items = $v.items; + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _maxItems = $v.maxItems; + _minItems = $v.minItems; + _uniqueItems = $v.uniqueItems; + _maxContains = $v.maxContains; + _minContains = $v.minContains; + _$v = null; + } + return this; + } + + @override + void replace(covariant ArraySchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ArraySchema; + } + + @override + void update(void Function(ArraySchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ArraySchema build() => _build(); + + _$ArraySchema _build() { + ArraySchema._finalize(this); + _$ArraySchema _$result; + try { + _$result = _$v ?? + _$ArraySchema._( + items: items, + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'ArraySchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'ArraySchema', 'nullable'), + format: format, + maxItems: maxItems, + minItems: minItems, + uniqueItems: BuiltValueNullFieldError.checkNotNull(uniqueItems, r'ArraySchema', 'uniqueItems'), + maxContains: maxContains, + minContains: minContains); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'ArraySchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$ObjectSchema extends ObjectSchema { + @override + final BuiltMap? properties; + @override + final JsonSchema? additionalProperties; + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + @override + final int? maxProperties; + @override + final int? minProperties; + @override + final BuiltSet required; + @override + final Map>? dependentRequired; + + factory _$ObjectSchema([void Function(ObjectSchemaBuilder)? updates]) => + (ObjectSchemaBuilder()..update(updates))._build(); + + _$ObjectSchema._( + {this.properties, + this.additionalProperties, + this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format, + this.maxProperties, + this.minProperties, + required this.required, + this.dependentRequired}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'ObjectSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'ObjectSchema', 'nullable'); + BuiltValueNullFieldError.checkNotNull(required, r'ObjectSchema', 'required'); + } + + @override + ObjectSchema rebuild(void Function(ObjectSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectSchemaBuilder toBuilder() => ObjectSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectSchema && + properties == other.properties && + additionalProperties == other.additionalProperties && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format && + maxProperties == other.maxProperties && + minProperties == other.minProperties && + required == other.required && + dependentRequired == other.dependentRequired; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, properties.hashCode); + _$hash = $jc(_$hash, additionalProperties.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jc(_$hash, maxProperties.hashCode); + _$hash = $jc(_$hash, minProperties.hashCode); + _$hash = $jc(_$hash, required.hashCode); + _$hash = $jc(_$hash, dependentRequired.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectSchema') + ..add('properties', properties) + ..add('additionalProperties', additionalProperties) + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format) + ..add('maxProperties', maxProperties) + ..add('minProperties', minProperties) + ..add('required', required) + ..add('dependentRequired', dependentRequired)) + .toString(); + } +} + +class ObjectSchemaBuilder implements Builder, JsonSchemaBuilder { + _$ObjectSchema? _$v; + + MapBuilder? _properties; + MapBuilder get properties => _$this._properties ??= MapBuilder(); + set properties(covariant MapBuilder? properties) => _$this._properties = properties; + + JsonSchema? _additionalProperties; + JsonSchema? get additionalProperties => _$this._additionalProperties; + set additionalProperties(covariant JsonSchema? additionalProperties) => + _$this._additionalProperties = additionalProperties; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + int? _maxProperties; + int? get maxProperties => _$this._maxProperties; + set maxProperties(covariant int? maxProperties) => _$this._maxProperties = maxProperties; + + int? _minProperties; + int? get minProperties => _$this._minProperties; + set minProperties(covariant int? minProperties) => _$this._minProperties = minProperties; + + SetBuilder? _required; + SetBuilder get required => _$this._required ??= SetBuilder(); + set required(covariant SetBuilder? required) => _$this._required = required; + + Map>? _dependentRequired; + Map>? get dependentRequired => _$this._dependentRequired; + set dependentRequired(covariant Map>? dependentRequired) => + _$this._dependentRequired = dependentRequired; + + ObjectSchemaBuilder() { + ObjectSchema._initialize(this); + } + + ObjectSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _properties = $v.properties?.toBuilder(); + _additionalProperties = $v.additionalProperties; + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _maxProperties = $v.maxProperties; + _minProperties = $v.minProperties; + _required = $v.required.toBuilder(); + _dependentRequired = $v.dependentRequired; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectSchema; + } + + @override + void update(void Function(ObjectSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectSchema build() => _build(); + + _$ObjectSchema _build() { + ObjectSchema._finalize(this); + _$ObjectSchema _$result; + try { + _$result = _$v ?? + _$ObjectSchema._( + properties: _properties?.build(), + additionalProperties: additionalProperties, + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'ObjectSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'ObjectSchema', 'nullable'), + format: format, + maxProperties: maxProperties, + minProperties: minProperties, + required: required.build(), + dependentRequired: dependentRequired); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'properties'; + _properties?.build(); + + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + + _$failedField = 'required'; + required.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'ObjectSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$NullSchema extends NullSchema { + @override + final Uri? id; + @override + final Uri? ref; + @override + final BuiltList? oneOf; + @override + final BuiltList? anyOf; + @override + final BuiltList? allOf; + @override + final String? description; + @override + final bool deprecated; + @override + final JsonSchemaType? type; + @override + final JsonObject? rawDefault; + @override + final BuiltList? $enum; + @override + final Discriminator? discriminator; + @override + final bool nullable; + @override + final String? format; + + factory _$NullSchema([void Function(NullSchemaBuilder)? updates]) => (NullSchemaBuilder()..update(updates))._build(); + + _$NullSchema._( + {this.id, + this.ref, + this.oneOf, + this.anyOf, + this.allOf, + this.description, + required this.deprecated, + this.type, + this.rawDefault, + this.$enum, + this.discriminator, + required this.nullable, + this.format}) + : super._() { + BuiltValueNullFieldError.checkNotNull(deprecated, r'NullSchema', 'deprecated'); + BuiltValueNullFieldError.checkNotNull(nullable, r'NullSchema', 'nullable'); + } + + @override + NullSchema rebuild(void Function(NullSchemaBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + NullSchemaBuilder toBuilder() => NullSchemaBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is NullSchema && + id == other.id && + ref == other.ref && + oneOf == other.oneOf && + anyOf == other.anyOf && + allOf == other.allOf && + deprecated == other.deprecated && + type == other.type && + rawDefault == other.rawDefault && + $enum == other.$enum && + discriminator == other.discriminator && + nullable == other.nullable && + format == other.format; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, ref.hashCode); + _$hash = $jc(_$hash, oneOf.hashCode); + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jc(_$hash, allOf.hashCode); + _$hash = $jc(_$hash, deprecated.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jc(_$hash, rawDefault.hashCode); + _$hash = $jc(_$hash, $enum.hashCode); + _$hash = $jc(_$hash, discriminator.hashCode); + _$hash = $jc(_$hash, nullable.hashCode); + _$hash = $jc(_$hash, format.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'NullSchema') + ..add('id', id) + ..add('ref', ref) + ..add('oneOf', oneOf) + ..add('anyOf', anyOf) + ..add('allOf', allOf) + ..add('description', description) + ..add('deprecated', deprecated) + ..add('type', type) + ..add('rawDefault', rawDefault) + ..add('\$enum', $enum) + ..add('discriminator', discriminator) + ..add('nullable', nullable) + ..add('format', format)) + .toString(); + } +} + +class NullSchemaBuilder implements Builder, JsonSchemaBuilder { + _$NullSchema? _$v; + + Uri? _id; + Uri? get id => _$this._id; + set id(covariant Uri? id) => _$this._id = id; + + Uri? _ref; + Uri? get ref => _$this._ref; + set ref(covariant Uri? ref) => _$this._ref = ref; + + ListBuilder? _oneOf; + ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); + set oneOf(covariant ListBuilder? oneOf) => _$this._oneOf = oneOf; + + ListBuilder? _anyOf; + ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); + set anyOf(covariant ListBuilder? anyOf) => _$this._anyOf = anyOf; + + ListBuilder? _allOf; + ListBuilder get allOf => _$this._allOf ??= ListBuilder(); + set allOf(covariant ListBuilder? allOf) => _$this._allOf = allOf; + + String? _description; + String? get description => _$this._description; + set description(covariant String? description) => _$this._description = description; + + bool? _deprecated; + bool? get deprecated => _$this._deprecated; + set deprecated(covariant bool? deprecated) => _$this._deprecated = deprecated; + + JsonSchemaType? _type; + JsonSchemaType? get type => _$this._type; + set type(covariant JsonSchemaType? type) => _$this._type = type; + + JsonObject? _rawDefault; + JsonObject? get rawDefault => _$this._rawDefault; + set rawDefault(covariant JsonObject? rawDefault) => _$this._rawDefault = rawDefault; + + ListBuilder? _$enum; + ListBuilder get $enum => _$this._$enum ??= ListBuilder(); + set $enum(covariant ListBuilder? $enum) => _$this._$enum = $enum; + + DiscriminatorBuilder? _discriminator; + DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); + set discriminator(covariant DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; + + bool? _nullable; + bool? get nullable => _$this._nullable; + set nullable(covariant bool? nullable) => _$this._nullable = nullable; + + String? _format; + String? get format => _$this._format; + set format(covariant String? format) => _$this._format = format; + + NullSchemaBuilder() { + NullSchema._initialize(this); + } + + NullSchemaBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _ref = $v.ref; + _oneOf = $v.oneOf?.toBuilder(); + _anyOf = $v.anyOf?.toBuilder(); + _allOf = $v.allOf?.toBuilder(); + _description = $v.description; + _deprecated = $v.deprecated; + _type = $v.type; + _rawDefault = $v.rawDefault; + _$enum = $v.$enum?.toBuilder(); + _discriminator = $v.discriminator?.toBuilder(); + _nullable = $v.nullable; + _format = $v.format; + _$v = null; + } + return this; + } + + @override + void replace(covariant NullSchema other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$NullSchema; + } + + @override + void update(void Function(NullSchemaBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + NullSchema build() => _build(); + + _$NullSchema _build() { + NullSchema._finalize(this); + _$NullSchema _$result; + try { + _$result = _$v ?? + _$NullSchema._( + id: id, + ref: ref, + oneOf: _oneOf?.build(), + anyOf: _anyOf?.build(), + allOf: _allOf?.build(), + description: description, + deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'NullSchema', 'deprecated'), + type: type, + rawDefault: rawDefault, + $enum: _$enum?.build(), + discriminator: _discriminator?.build(), + nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'NullSchema', 'nullable'), + format: format); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneOf'; + _oneOf?.build(); + _$failedField = 'anyOf'; + _anyOf?.build(); + _$failedField = 'allOf'; + _allOf?.build(); + + _$failedField = '\$enum'; + _$enum?.build(); + _$failedField = 'discriminator'; + _discriminator?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'NullSchema', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/dynamite/dynamite/lib/src/models/json_schema/validators.dart b/packages/dynamite/dynamite/lib/src/models/json_schema/validators.dart new file mode 100644 index 00000000000..72a51cf8f62 --- /dev/null +++ b/packages/dynamite/dynamite/lib/src/models/json_schema/validators.dart @@ -0,0 +1,225 @@ +import 'package:built_collection/built_collection.dart'; + +/// https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-8 +mixin Validator { + /// https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-7 + String? get format; +} + +/// Validates a [num]. +/// +/// ### Multiples +/// {@template NumberValidator.multiples} +/// Numbers can be restricted to a multiple of a given number, using the [multipleOf] keyword. +/// +/// It may be set to any positive number. +/// The multiple can be a floating point number. +/// {@endtemplate} +/// +/// ### Range +/// {@template NumberValidator.range} +/// Ranges of numbers are specified using a combination of the [minimum] and [maximum] keywords, +/// (or [exclusiveMinimum] and [exclusiveMaximum] for expressing exclusive range). +/// +/// If x is the value being validated, the following must hold true: +/// ```md +/// x ≥ minimum +/// x > exclusiveMinimum +/// x ≤ maximum +/// x < exclusiveMaximum +/// ``` +/// While you can specify both of [minimum] and [exclusiveMinimum] or both of [maximum] and +/// [exclusiveMaximum], it doesn't really make sense to do so. +/// {@endtemplate} +/// +/// See: +/// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2 +/// * https://json-schema.org/understanding-json-schema/reference/numeric +mixin NumberValidator implements Validator { + /// {@macro NumberValidator.multiples} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2.1 + /// * https://json-schema.org/understanding-json-schema/reference/numeric#multiples + num? get multipleOf; + + /// {@macro NumberValidator.range} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2.2 + /// * https://json-schema.org/understanding-json-schema/reference/numeric#range + num? get maximum; + + /// {@macro NumberValidator.range} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2.3 + /// * https://json-schema.org/understanding-json-schema/reference/numeric#range + num? get exclusiveMaximum; + + /// {@macro NumberValidator.range} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2.4 + /// * https://json-schema.org/understanding-json-schema/reference/numeric#range + num? get minimum; + + /// {@macro NumberValidator.range} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.2.5 + /// * https://json-schema.org/understanding-json-schema/reference/numeric#range + num? get exclusiveMinimum; +} + +/// Validates a [String]. +/// +/// ### Length +/// {@template StringValidator.length} +/// The length of a string can be constrained using the [minLength] and [maxLength] keywords. +/// For both keywords, the value must be a non-negative number. +/// {@endtemplate} +/// +/// ### Regular Expressions +/// {@template StringValidator.regularExpressions} +/// The [pattern] keyword is used to restrict a string to a particular regular expression. +/// The regular expression syntax is the one defined in JavaScript ([ECMA 262](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/) specifically) with Unicode support. +/// See [Regular Expressions](https://json-schema.org/understanding-json-schema/reference/regular_expressions) for more information. +/// ```md +/// When defining the regular expressions, it's important to note that the string is considered valid if the expression matches anywhere within the string. +/// For example, the regular expression `"p"` will match any string with a `p` in it, such as `"apple"` not just a string that is simply `"p"`. +/// Therefore, it is usually less confusing, as a matter of course, to surround the regular expression in `^...$`, for example, `"^p$"`, unless there is a good reason not to do so. +/// ``` +/// {@endtemplate} +/// +/// See: +/// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.3 +/// * https://json-schema.org/understanding-json-schema/reference/string +mixin StringValidator implements Validator { + /// {@macro StringValidator.length} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.3.1 + /// * https://json-schema.org/understanding-json-schema/reference/string#length + int? get maxLength; + + /// {@macro StringValidator.length} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.3.2 + /// * https://json-schema.org/understanding-json-schema/reference/string#length + int? get minLength; + + /// {@macro StringValidator.regularExpressions} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.3.3 + /// * https://json-schema.org/understanding-json-schema/reference/string#regexp + RegExp? get pattern; +} + +/// Validates an [Iterable]. +/// +/// ### Items +/// {@template ArrayValidator.length} +/// The length of the array can be specified using the [minItems] and [maxItems] keywords. +/// The value of each keyword must be a non-negative number. +/// These keywords work whether doing list validation or tuple-validation. +/// {@endtemplate} +/// +/// ### Uniqueness +/// {@template ArrayValidator.uniqueItems} +/// A schema can ensure that each of the items in an array is unique. Simply set the [uniqueItems] keyword to `true`. +/// {@endtemplate} +/// +/// ### minContains / maxContains +/// {@template ArrayValidator.contains} +/// [minContains] and [maxContains] can be used with contains to further specify how many times a schema matches a contains constraint. +/// These keywords can be any non-negative number including zero. +/// {@endtemplate} +/// +/// See: +/// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4 +/// * https://json-schema.org/understanding-json-schema/reference/array +mixin ArrayValidator implements Validator { + /// {@macro ArrayValidator.length} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4.1 + /// * https://json-schema.org/understanding-json-schema/reference/array#length + int? get maxItems; + + /// {@macro ArrayValidator.length} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4.2 + /// * https://json-schema.org/understanding-json-schema/reference/array#length + int? get minItems; + + /// {@macro ArrayValidator.uniqueItems} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4.3 + /// * https://json-schema.org/understanding-json-schema/reference/array#uniqueItems + bool get uniqueItems; + + /// {@macro ArrayValidator.contains} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4.4 + /// * https://json-schema.org/understanding-json-schema/reference/array#mincontains-maxcontains + int? get maxContains; + + /// {@macro ArrayValidator.contains} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.4.5 + /// * https://json-schema.org/understanding-json-schema/reference/array#mincontains-maxcontains + int? get minContains; +} + +/// Validates an [Object]. +/// +/// ### Required +/// {@template ObjectValidator.required} +/// By default, the properties defined by the `properties` keyword are not required. However, +/// one can provide a list of required properties using the [required] keyword. +/// +/// The [required] keyword takes an array of zero or more strings. Each of these strings must be unique. +/// {@endtemplate} +/// +/// ### Size +/// {@template ObjectValidator.size} +/// The number of properties on an object can be restricted using the [minProperties] and [maxProperties] keywords. +/// Each of these must be a non-negative integer. +/// {@endtemplate} +/// +/// See: +/// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.5 +/// * https://json-schema.org/understanding-json-schema/reference/object +mixin ObjectValidator implements Validator { + /// {@macro ObjectValidator.size} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.5.1 + /// * https://json-schema.org/understanding-json-schema/reference/object#size + int? get maxProperties; + + /// {@macro ObjectValidator.size} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.5.2 + /// * https://json-schema.org/understanding-json-schema/reference/object#size + int? get minProperties; + + /// {@macro ObjectValidator.required} + /// + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.5.3 + /// * https://json-schema.org/understanding-json-schema/reference/object#required + BuiltSet get required; + + /// See: + /// * https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.5.4 + Map>? get dependentRequired; +} diff --git a/packages/dynamite/dynamite/lib/src/models/openapi.dart b/packages/dynamite/dynamite/lib/src/models/openapi.dart index 4e4c827a482..ad69fab25db 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi.dart @@ -1,7 +1,8 @@ import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; import 'package:built_value/serializer.dart'; import 'package:built_value/standard_json_plugin.dart'; +import 'package:dynamite/src/models/json_schema.dart' as json_schema show serializers; +import 'package:dynamite/src/models/json_schema.dart' hide serializers; import 'package:dynamite/src/models/openapi/components.dart'; import 'package:dynamite/src/models/openapi/contact.dart'; import 'package:dynamite/src/models/openapi/discriminator.dart'; @@ -15,7 +16,6 @@ import 'package:dynamite/src/models/openapi/parameter.dart'; import 'package:dynamite/src/models/openapi/path_item.dart'; import 'package:dynamite/src/models/openapi/request_body.dart'; import 'package:dynamite/src/models/openapi/response.dart'; -import 'package:dynamite/src/models/openapi/schema.dart'; import 'package:dynamite/src/models/openapi/security_scheme.dart'; import 'package:dynamite/src/models/openapi/server.dart'; import 'package:dynamite/src/models/openapi/server_variable.dart'; @@ -33,7 +33,6 @@ export 'openapi/parameter.dart'; export 'openapi/path_item.dart'; export 'openapi/request_body.dart'; export 'openapi/response.dart'; -export 'openapi/schema.dart'; export 'openapi/security_scheme.dart'; export 'openapi/server.dart'; export 'openapi/server_variable.dart'; @@ -55,20 +54,13 @@ part 'openapi.g.dart'; PathItem, RequestBody, Response, - Schema, SecurityScheme, Server, ServerVariable, Tag, ]) final Serializers serializers = (_$serializers.toBuilder() - ..addBuilderFactory( - const FullType(BuiltMap, [ - FullType(String), - FullType(BuiltList, [FullType(String)]), - ]), - MapBuilder>.new, - ) + ..merge(json_schema.serializers) ..addPlugin(StandardJsonPlugin()) ..addPlugin(const SchemaPlugin())) .build(); diff --git a/packages/dynamite/dynamite/lib/src/models/openapi.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi.g.dart index 981c211e094..3614f5dc8ed 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi.g.dart @@ -22,20 +22,11 @@ Serializers _$serializers = (Serializers().toBuilder() ..add(PathItem.serializer) ..add(RequestBody.serializer) ..add(Response.serializer) - ..add(Schema.serializer) - ..add(SchemaType.serializer) ..add(SecurityScheme.serializer) ..add(Server.serializer) ..add(ServerVariable.serializer) ..add(Tag.serializer) ..addBuilderFactory(const FullType(BuiltList, [FullType(Parameter)]), () => ListBuilder()) - ..addBuilderFactory(const FullType(BuiltList, [FullType(Schema)]), () => ListBuilder()) - ..addBuilderFactory(const FullType(BuiltList, [FullType(Schema)]), () => ListBuilder()) - ..addBuilderFactory(const FullType(BuiltList, [FullType(Schema)]), () => ListBuilder()) - ..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), () => ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltMap, [FullType(String), FullType(Schema)]), () => MapBuilder()) - ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), () => ListBuilder()) ..addBuilderFactory(const FullType(BuiltList, [FullType(Server)]), () => ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, [ @@ -60,7 +51,7 @@ Serializers _$serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(BuiltMap, [FullType(String), FullType(SecurityScheme)]), () => MapBuilder()) ..addBuilderFactory( - const FullType(BuiltMap, [FullType(String), FullType(Schema)]), () => MapBuilder()) + const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]), () => MapBuilder()) ..addBuilderFactory(const FullType(BuiltMap, [FullType(String), FullType(ServerVariable)]), () => MapBuilder()) ..addBuilderFactory( diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/components.dart b/packages/dynamite/dynamite/lib/src/models/openapi/components.dart index b833c5c0cf9..e60a6c466f5 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/components.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/components.dart @@ -1,7 +1,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/json_schema.dart'; import 'package:dynamite/src/models/openapi/security_scheme.dart'; part 'components.g.dart'; @@ -15,5 +15,5 @@ abstract class Components implements Built { BuiltMap? get securitySchemes; - BuiltMap? get schemas; + BuiltMap? get schemas; } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart index d2514c4483b..a28b01fe427 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/components.g.dart @@ -31,7 +31,7 @@ class _$ComponentsSerializer implements StructuredSerializer { result ..add('schemas') ..add(serializers.serialize(value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Schema)]))); + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]))); } return result; } @@ -53,7 +53,7 @@ class _$ComponentsSerializer implements StructuredSerializer { break; case 'schemas': result.schemas.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Schema)]))!); + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(JsonSchema)]))!); break; } } @@ -66,7 +66,7 @@ class _$Components extends Components { @override final BuiltMap? securitySchemes; @override - final BuiltMap? schemas; + final BuiltMap? schemas; factory _$Components([void Function(ComponentsBuilder)? updates]) => (ComponentsBuilder()..update(updates))._build(); @@ -110,9 +110,9 @@ class ComponentsBuilder implements Builder { _$this._securitySchemes ??= MapBuilder(); set securitySchemes(MapBuilder? securitySchemes) => _$this._securitySchemes = securitySchemes; - MapBuilder? _schemas; - MapBuilder get schemas => _$this._schemas ??= MapBuilder(); - set schemas(MapBuilder? schemas) => _$this._schemas = schemas; + MapBuilder? _schemas; + MapBuilder get schemas => _$this._schemas ??= MapBuilder(); + set schemas(MapBuilder? schemas) => _$this._schemas = schemas; ComponentsBuilder(); diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/header.dart b/packages/dynamite/dynamite/lib/src/models/openapi/header.dart index d65bd0b29ca..4a1c1dba1e6 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/header.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/header.dart @@ -1,6 +1,6 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/json_schema.dart'; part 'header.g.dart'; @@ -16,7 +16,7 @@ abstract class Header implements Built { bool get required; - Schema? get schema; + JsonSchema? get schema; @BuiltValueHook(finalizeBuilder: true) static void _defaults(HeaderBuilder b) { diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart index 965aec23809..1d5ab22fb27 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/header.g.dart @@ -31,7 +31,7 @@ class _$HeaderSerializer implements StructuredSerializer
{ if (value != null) { result ..add('schema') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); } return result; } @@ -54,7 +54,7 @@ class _$HeaderSerializer implements StructuredSerializer
{ result.required = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; break; case 'schema': - result.schema.replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); + result.schema = serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; break; } } @@ -69,7 +69,7 @@ class _$Header extends Header { @override final bool required; @override - final Schema? schema; + final JsonSchema? schema; factory _$Header([void Function(HeaderBuilder)? updates]) => (HeaderBuilder()..update(updates))._build(); @@ -119,9 +119,9 @@ class HeaderBuilder implements Builder { bool? get required => _$this._required; set required(bool? required) => _$this._required = required; - SchemaBuilder? _schema; - SchemaBuilder get schema => _$this._schema ??= SchemaBuilder(); - set schema(SchemaBuilder? schema) => _$this._schema = schema; + JsonSchema? _schema; + JsonSchema? get schema => _$this._schema; + set schema(JsonSchema? schema) => _$this._schema = schema; HeaderBuilder(); @@ -130,7 +130,7 @@ class HeaderBuilder implements Builder { if ($v != null) { _description = $v.description; _required = $v.required; - _schema = $v.schema?.toBuilder(); + _schema = $v.schema; _$v = null; } return this; @@ -152,23 +152,11 @@ class HeaderBuilder implements Builder { _$Header _build() { Header._defaults(this); - _$Header _$result; - try { - _$result = _$v ?? - _$Header._( - description: description, - required: BuiltValueNullFieldError.checkNotNull(required, r'Header', 'required'), - schema: _schema?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'schema'; - _schema?.build(); - } catch (e) { - throw BuiltValueNestedFieldError(r'Header', _$failedField, e.toString()); - } - rethrow; - } + final _$result = _$v ?? + _$Header._( + description: description, + required: BuiltValueNullFieldError.checkNotNull(required, r'Header', 'required'), + schema: schema); replace(_$result); return _$result; } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart index 16a9c48cf3d..357bdada64d 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.dart @@ -1,6 +1,6 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/models/openapi/schema.dart'; +import 'package:dynamite/src/models/json_schema.dart'; part 'media_type.g.dart'; @@ -11,5 +11,5 @@ abstract class MediaType implements Built { static Serializer get serializer => _$mediaTypeSerializer; - Schema? get schema; + JsonSchema? get schema; } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart index e8e047b62de..c32084d8164 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/media_type.g.dart @@ -23,7 +23,7 @@ class _$MediaTypeSerializer implements StructuredSerializer { if (value != null) { result ..add('schema') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); } return result; } @@ -40,7 +40,7 @@ class _$MediaTypeSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'schema': - result.schema.replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); + result.schema = serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; break; } } @@ -51,7 +51,7 @@ class _$MediaTypeSerializer implements StructuredSerializer { class _$MediaType extends MediaType { @override - final Schema? schema; + final JsonSchema? schema; factory _$MediaType([void Function(MediaTypeBuilder)? updates]) => (MediaTypeBuilder()..update(updates))._build(); @@ -86,16 +86,16 @@ class _$MediaType extends MediaType { class MediaTypeBuilder implements Builder { _$MediaType? _$v; - SchemaBuilder? _schema; - SchemaBuilder get schema => _$this._schema ??= SchemaBuilder(); - set schema(SchemaBuilder? schema) => _$this._schema = schema; + JsonSchema? _schema; + JsonSchema? get schema => _$this._schema; + set schema(JsonSchema? schema) => _$this._schema = schema; MediaTypeBuilder(); MediaTypeBuilder get _$this { final $v = _$v; if ($v != null) { - _schema = $v.schema?.toBuilder(); + _schema = $v.schema; _$v = null; } return this; @@ -116,19 +116,7 @@ class MediaTypeBuilder implements Builder { MediaType build() => _build(); _$MediaType _build() { - _$MediaType _$result; - try { - _$result = _$v ?? _$MediaType._(schema: _schema?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'schema'; - _schema?.build(); - } catch (e) { - throw BuiltValueNestedFieldError(r'MediaType', _$failedField, e.toString()); - } - rethrow; - } + final _$result = _$v ?? _$MediaType._(schema: schema); replace(_$result); return _$result; } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart index d8f22f0317b..b1b3cf689b3 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.dart @@ -5,8 +5,8 @@ import 'package:dynamite/src/helpers/dart_helpers.dart'; import 'package:dynamite/src/helpers/docs.dart'; import 'package:dynamite/src/helpers/logger.dart'; import 'package:dynamite/src/models/exceptions.dart'; +import 'package:dynamite/src/models/json_schema.dart'; import 'package:dynamite/src/models/openapi/media_type.dart'; -import 'package:dynamite/src/models/openapi/schema.dart'; import 'package:meta/meta.dart'; part 'parameter.g.dart'; @@ -30,7 +30,7 @@ abstract class Parameter implements Built { @protected @BuiltValueField(wireName: 'schema') - Schema? get $schema; + JsonSchema? get $schema; BuiltMap? get content; @@ -41,7 +41,7 @@ abstract class Parameter implements Built { ParameterStyle get style; @memoized - Schema? get schema { + JsonSchema? get schema { if ($schema != null) { return $schema; } @@ -49,11 +49,11 @@ abstract class Parameter implements Built { if (content != null) { final mediaType = content!.entries.single; - return Schema( + return StringSchema( (b) => b - ..type = SchemaType.string + ..type = JsonSchemaType.string ..contentMediaType = mediaType.key - ..contentSchema.replace(mediaType.value.schema!), + ..contentSchema = mediaType.value.schema, ); } @@ -142,7 +142,7 @@ abstract class Parameter implements Built { } case ParameterStyle.spaceDelimited: - if (b._$schema?.type != SchemaType.array && b._$schema?.type != SchemaType.object) { + if (b._$schema?.type != JsonSchemaType.array && b._$schema?.type != JsonSchemaType.object) { throw OpenAPISpecError('ParameterStyle.spaceDelimited can only be used with array or object schemas.'); } if (b._$in != ParameterType.query) { @@ -150,7 +150,7 @@ abstract class Parameter implements Built { } case ParameterStyle.pipeDelimited: - if (b._$schema?.type != SchemaType.array && b._$schema?.type != SchemaType.object) { + if (b._$schema?.type != JsonSchemaType.array && b._$schema?.type != JsonSchemaType.object) { throw OpenAPISpecError('ParameterStyle.pipeDelimited can only be used with array or object schemas.'); } if (b._$in != ParameterType.query) { @@ -158,7 +158,7 @@ abstract class Parameter implements Built { } case ParameterStyle.deepObject: - if (b._$schema?.type != SchemaType.object) { + if (b._$schema?.type != JsonSchemaType.object) { throw OpenAPISpecError('ParameterStyle.deepObject can only be used with object schemas.'); } if (b._$in != ParameterType.query) { @@ -170,7 +170,7 @@ abstract class Parameter implements Built { throw OpenAPISpecError('Path parameters must be required but ${b.name} is not.'); } - if (b.required! && b._$schema != null && b.$schema.rawDefault != null) { + if (b.required! && b._$schema != null && b.$schema?.$default != null) { dynamiteLog.requiredParameters(); } diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart index 8170e921a39..6b114c71a07 100644 --- a/packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart +++ b/packages/dynamite/dynamite/lib/src/models/openapi/parameter.g.dart @@ -110,7 +110,7 @@ class _$ParameterSerializer implements StructuredSerializer { if (value != null) { result ..add('schema') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); + ..add(serializers.serialize(value, specifiedType: const FullType(JsonSchema))); } value = object.content; if (value != null) { @@ -146,7 +146,7 @@ class _$ParameterSerializer implements StructuredSerializer { result.required = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; break; case 'schema': - result.$schema.replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); + result.$schema = serializers.deserialize(value, specifiedType: const FullType(JsonSchema)) as JsonSchema?; break; case 'content': result.content.replace(serializers.deserialize(value, @@ -211,7 +211,7 @@ class _$Parameter extends Parameter { @override final bool required; @override - final Schema? $schema; + final JsonSchema? $schema; @override final BuiltMap? content; @override @@ -220,7 +220,7 @@ class _$Parameter extends Parameter { final bool allowReserved; @override final ParameterStyle style; - Schema? __schema; + JsonSchema? __schema; bool ___schema = false; String? __formattedDescription; @@ -246,7 +246,7 @@ class _$Parameter extends Parameter { } @override - Schema? get schema { + JsonSchema? get schema { if (!___schema) { __schema = super.schema; ___schema = true; @@ -327,9 +327,9 @@ class ParameterBuilder implements Builder { bool? get required => _$this._required; set required(bool? required) => _$this._required = required; - SchemaBuilder? _$schema; - SchemaBuilder get $schema => _$this._$schema ??= SchemaBuilder(); - set $schema(SchemaBuilder? $schema) => _$this._$schema = $schema; + JsonSchema? _$schema; + JsonSchema? get $schema => _$this._$schema; + set $schema(JsonSchema? $schema) => _$this._$schema = $schema; MapBuilder? _content; MapBuilder get content => _$this._content ??= MapBuilder(); @@ -356,7 +356,7 @@ class ParameterBuilder implements Builder { _$in = $v.$in; _description = $v.description; _required = $v.required; - _$schema = $v.$schema?.toBuilder(); + _$schema = $v.$schema; _content = $v.content?.toBuilder(); _explode = $v.explode; _allowReserved = $v.allowReserved; @@ -390,7 +390,7 @@ class ParameterBuilder implements Builder { $in: BuiltValueNullFieldError.checkNotNull($in, r'Parameter', '\$in'), description: description, required: BuiltValueNullFieldError.checkNotNull(required, r'Parameter', 'required'), - $schema: _$schema?.build(), + $schema: $schema, content: _content?.build(), explode: BuiltValueNullFieldError.checkNotNull(explode, r'Parameter', 'explode'), allowReserved: BuiltValueNullFieldError.checkNotNull(allowReserved, r'Parameter', 'allowReserved'), @@ -398,8 +398,6 @@ class ParameterBuilder implements Builder { } catch (_) { late String _$failedField; try { - _$failedField = '\$schema'; - _$schema?.build(); _$failedField = 'content'; _content?.build(); } catch (e) { diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/schema.dart b/packages/dynamite/dynamite/lib/src/models/openapi/schema.dart deleted file mode 100644 index 8d06dd0f707..00000000000 --- a/packages/dynamite/dynamite/lib/src/models/openapi/schema.dart +++ /dev/null @@ -1,191 +0,0 @@ -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/serializer.dart'; -import 'package:dynamite/src/helpers/default_value.dart'; -import 'package:dynamite/src/helpers/docs.dart'; -import 'package:dynamite/src/helpers/logger.dart'; -import 'package:dynamite/src/models/exceptions.dart'; -import 'package:dynamite/src/models/openapi.dart'; -import 'package:meta/meta.dart'; -import 'package:rfc_6901/rfc_6901.dart'; - -part 'schema.g.dart'; - -abstract class Schema implements Built { - factory Schema([void Function(SchemaBuilder) updates]) = _$Schema; - - const Schema._(); - - static Serializer get serializer => _$schemaSerializer; - - @BuiltValueField(wireName: r'$id') - Uri? get id; - - @BuiltValueField(wireName: r'$ref') - Uri? get ref; - - Schema resolveRef(Map json) { - if (ref == null) { - throw StateError(r'Referenced schema can only be resolved when a $ref is present'); - } - - final rootID = json[r'$id'] as String?; - - final Uri uri; - if (rootID != null) { - uri = Uri.parse(rootID).resolveUri(ref!); - } else { - uri = ref!; - } - - // Only relative references are supported. - final value = JsonPointer(uri.fragment).read(json); - var schema = serializers.deserializeWith(serializer, value)!; - if (schema.id == null) { - schema = schema.rebuild((b) { - b.id = uri; - }); - } - - return schema; - } - - BuiltList? get oneOf; - - BuiltList? get anyOf; - - BuiltList? get allOf; - - BuiltList? get ofs => oneOf ?? anyOf ?? allOf; - - @BuiltValueField(compare: false) - String? get description; - - bool get deprecated; - - SchemaType? get type; - - String? get format; - - @BuiltValueField(wireName: 'default') - @protected - JsonObject? get rawDefault; - - @memoized - String? get $default => encodeDefault(rawDefault); - - @memoized - String? get defaultDescription => encodeDefault(rawDefault, constant: false); - - @BuiltValueField(wireName: 'enum') - BuiltList? get $enum; - - BuiltMap? get properties; - - BuiltList get required; - - Schema? get items; - - Schema? get additionalProperties; - - String? get contentMediaType; - - Schema? get contentSchema; - - Discriminator? get discriminator; - - String? get pattern; - - int? get minLength; - - int? get maxLength; - - int? get minItems; - - int? get maxItems; - - bool get nullable; - - @memoized - bool get isContentString => type == SchemaType.string && contentMediaType != null && contentSchema != null; - - @memoized - String? get formattedDescription => formatDescription(description); - - @BuiltValueHook(finalizeBuilder: true) - static void _defaults(SchemaBuilder b) { - b - ..deprecated ??= false - ..nullable ??= false; - - const allowedNumberFormats = [null, 'float', 'double']; - if (b.type == SchemaType.number && !allowedNumberFormats.contains(b.format)) { - throw OpenAPISpecError('Format "${b.format}" is not allowed for ${b.type}. Use one of $allowedNumberFormats.'); - } - const allowedIntegerFormats = [null, 'int32', 'int64']; - if (b.type == SchemaType.integer) { - if (!allowedIntegerFormats.contains(b.format)) { - throw OpenAPISpecError('Format "${b.format}" is not allowed for ${b.type}. Use one of $allowedIntegerFormats.'); - } else if (b.format != null) { - dynamiteLog.integerPrecision(); - } - } - } -} - -class SchemaType extends EnumClass { - const SchemaType._(super.name); - - static const SchemaType boolean = _$schemaTypeBoolean; - static const SchemaType integer = _$schemaTypeInteger; - static const SchemaType number = _$schemaTypeNumber; - static const SchemaType string = _$schemaTypeString; - static const SchemaType array = _$schemaTypeArray; - static const SchemaType object = _$schemaTypeObject; - - static BuiltSet get values => _$schemaTypeValues; - - static SchemaType valueOf(String name) => _$schemaType(name); - - static Serializer get serializer => _$schemaTypeSerializer; -} - -/// A Schema value can be either a json boolean or object. -/// -/// https://json-schema.org/understanding-json-schema/basics -class SchemaPlugin implements SerializerPlugin { - const SchemaPlugin(); - - @override - Object? afterDeserialize(Object? object, FullType specifiedType) => object; - - @override - Object? afterSerialize(Object? object, FullType specifiedType) => object; - - @override - Object? beforeDeserialize(Object? object, FullType specifiedType) { - if (specifiedType.root != Schema) { - return object; - } - - switch (object) { - case null: - return null; - - case bool _: - if (object) { - // An empty list in BuiltValue it equivalent to the empty json object. - return []; - } else { - throw UnsupportedError('The never matching schema is not yet supported.'); - } - - default: - return object; - } - } - - @override - Object? beforeSerialize(Object? object, FullType specifiedType) => object; -} diff --git a/packages/dynamite/dynamite/lib/src/models/openapi/schema.g.dart b/packages/dynamite/dynamite/lib/src/models/openapi/schema.g.dart deleted file mode 100644 index ba6c0567718..00000000000 --- a/packages/dynamite/dynamite/lib/src/models/openapi/schema.g.dart +++ /dev/null @@ -1,736 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'schema.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -const SchemaType _$schemaTypeBoolean = SchemaType._('boolean'); -const SchemaType _$schemaTypeInteger = SchemaType._('integer'); -const SchemaType _$schemaTypeNumber = SchemaType._('number'); -const SchemaType _$schemaTypeString = SchemaType._('string'); -const SchemaType _$schemaTypeArray = SchemaType._('array'); -const SchemaType _$schemaTypeObject = SchemaType._('object'); - -SchemaType _$schemaType(String name) { - switch (name) { - case 'boolean': - return _$schemaTypeBoolean; - case 'integer': - return _$schemaTypeInteger; - case 'number': - return _$schemaTypeNumber; - case 'string': - return _$schemaTypeString; - case 'array': - return _$schemaTypeArray; - case 'object': - return _$schemaTypeObject; - default: - throw ArgumentError(name); - } -} - -final BuiltSet _$schemaTypeValues = BuiltSet(const [ - _$schemaTypeBoolean, - _$schemaTypeInteger, - _$schemaTypeNumber, - _$schemaTypeString, - _$schemaTypeArray, - _$schemaTypeObject, -]); - -Serializer _$schemaSerializer = _$SchemaSerializer(); -Serializer _$schemaTypeSerializer = _$SchemaTypeSerializer(); - -class _$SchemaSerializer implements StructuredSerializer { - @override - final Iterable types = const [Schema, _$Schema]; - @override - final String wireName = 'Schema'; - - @override - Iterable serialize(Serializers serializers, Schema object, {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'deprecated', - serializers.serialize(object.deprecated, specifiedType: const FullType(bool)), - 'required', - serializers.serialize(object.required, specifiedType: const FullType(BuiltList, [FullType(String)])), - 'nullable', - serializers.serialize(object.nullable, specifiedType: const FullType(bool)), - ]; - Object? value; - value = object.id; - if (value != null) { - result - ..add('\$id') - ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); - } - value = object.ref; - if (value != null) { - result - ..add('\$ref') - ..add(serializers.serialize(value, specifiedType: const FullType(Uri))); - } - value = object.oneOf; - if (value != null) { - result - ..add('oneOf') - ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(Schema)]))); - } - value = object.anyOf; - if (value != null) { - result - ..add('anyOf') - ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(Schema)]))); - } - value = object.allOf; - if (value != null) { - result - ..add('allOf') - ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(Schema)]))); - } - value = object.description; - if (value != null) { - result - ..add('description') - ..add(serializers.serialize(value, specifiedType: const FullType(String))); - } - value = object.type; - if (value != null) { - result - ..add('type') - ..add(serializers.serialize(value, specifiedType: const FullType(SchemaType))); - } - value = object.format; - if (value != null) { - result - ..add('format') - ..add(serializers.serialize(value, specifiedType: const FullType(String))); - } - value = object.rawDefault; - if (value != null) { - result - ..add('default') - ..add(serializers.serialize(value, specifiedType: const FullType(JsonObject))); - } - value = object.$enum; - if (value != null) { - result - ..add('enum') - ..add(serializers.serialize(value, specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))); - } - value = object.properties; - if (value != null) { - result - ..add('properties') - ..add(serializers.serialize(value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Schema)]))); - } - value = object.items; - if (value != null) { - result - ..add('items') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); - } - value = object.additionalProperties; - if (value != null) { - result - ..add('additionalProperties') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); - } - value = object.contentMediaType; - if (value != null) { - result - ..add('contentMediaType') - ..add(serializers.serialize(value, specifiedType: const FullType(String))); - } - value = object.contentSchema; - if (value != null) { - result - ..add('contentSchema') - ..add(serializers.serialize(value, specifiedType: const FullType(Schema))); - } - value = object.discriminator; - if (value != null) { - result - ..add('discriminator') - ..add(serializers.serialize(value, specifiedType: const FullType(Discriminator))); - } - value = object.pattern; - if (value != null) { - result - ..add('pattern') - ..add(serializers.serialize(value, specifiedType: const FullType(String))); - } - value = object.minLength; - if (value != null) { - result - ..add('minLength') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - value = object.maxLength; - if (value != null) { - result - ..add('maxLength') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - value = object.minItems; - if (value != null) { - result - ..add('minItems') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - value = object.maxItems; - if (value != null) { - result - ..add('maxItems') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - return result; - } - - @override - Schema deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = SchemaBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case '\$id': - result.id = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; - break; - case '\$ref': - result.ref = serializers.deserialize(value, specifiedType: const FullType(Uri)) as Uri?; - break; - case 'oneOf': - result.oneOf.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(Schema)]))! as BuiltList); - break; - case 'anyOf': - result.anyOf.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(Schema)]))! as BuiltList); - break; - case 'allOf': - result.allOf.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(Schema)]))! as BuiltList); - break; - case 'description': - result.description = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; - break; - case 'deprecated': - result.deprecated = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; - break; - case 'type': - result.type = serializers.deserialize(value, specifiedType: const FullType(SchemaType)) as SchemaType?; - break; - case 'format': - result.format = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; - break; - case 'default': - result.rawDefault = serializers.deserialize(value, specifiedType: const FullType(JsonObject)) as JsonObject?; - break; - case 'enum': - result.$enum.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]))! as BuiltList); - break; - case 'properties': - result.properties.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(Schema)]))!); - break; - case 'required': - result.required.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList); - break; - case 'items': - result.items.replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); - break; - case 'additionalProperties': - result.additionalProperties - .replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); - break; - case 'contentMediaType': - result.contentMediaType = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; - break; - case 'contentSchema': - result.contentSchema - .replace(serializers.deserialize(value, specifiedType: const FullType(Schema))! as Schema); - break; - case 'discriminator': - result.discriminator - .replace(serializers.deserialize(value, specifiedType: const FullType(Discriminator))! as Discriminator); - break; - case 'pattern': - result.pattern = serializers.deserialize(value, specifiedType: const FullType(String)) as String?; - break; - case 'minLength': - result.minLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; - break; - case 'maxLength': - result.maxLength = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; - break; - case 'minItems': - result.minItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; - break; - case 'maxItems': - result.maxItems = serializers.deserialize(value, specifiedType: const FullType(int)) as int?; - break; - case 'nullable': - result.nullable = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; - break; - } - } - - return result.build(); - } -} - -class _$SchemaTypeSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [SchemaType]; - @override - final String wireName = 'SchemaType'; - - @override - Object serialize(Serializers serializers, SchemaType object, {FullType specifiedType = FullType.unspecified}) => - object.name; - - @override - SchemaType deserialize(Serializers serializers, Object serialized, {FullType specifiedType = FullType.unspecified}) => - SchemaType.valueOf(serialized as String); -} - -class _$Schema extends Schema { - @override - final Uri? id; - @override - final Uri? ref; - @override - final BuiltList? oneOf; - @override - final BuiltList? anyOf; - @override - final BuiltList? allOf; - @override - final String? description; - @override - final bool deprecated; - @override - final SchemaType? type; - @override - final String? format; - @override - final JsonObject? rawDefault; - @override - final BuiltList? $enum; - @override - final BuiltMap? properties; - @override - final BuiltList required; - @override - final Schema? items; - @override - final Schema? additionalProperties; - @override - final String? contentMediaType; - @override - final Schema? contentSchema; - @override - final Discriminator? discriminator; - @override - final String? pattern; - @override - final int? minLength; - @override - final int? maxLength; - @override - final int? minItems; - @override - final int? maxItems; - @override - final bool nullable; - String? __$default; - bool ___$default = false; - String? __defaultDescription; - bool ___defaultDescription = false; - bool? __isContentString; - String? __formattedDescription; - bool ___formattedDescription = false; - - factory _$Schema([void Function(SchemaBuilder)? updates]) => (SchemaBuilder()..update(updates))._build(); - - _$Schema._( - {this.id, - this.ref, - this.oneOf, - this.anyOf, - this.allOf, - this.description, - required this.deprecated, - this.type, - this.format, - this.rawDefault, - this.$enum, - this.properties, - required this.required, - this.items, - this.additionalProperties, - this.contentMediaType, - this.contentSchema, - this.discriminator, - this.pattern, - this.minLength, - this.maxLength, - this.minItems, - this.maxItems, - required this.nullable}) - : super._() { - BuiltValueNullFieldError.checkNotNull(deprecated, r'Schema', 'deprecated'); - BuiltValueNullFieldError.checkNotNull(required, r'Schema', 'required'); - BuiltValueNullFieldError.checkNotNull(nullable, r'Schema', 'nullable'); - } - - @override - String? get $default { - if (!___$default) { - __$default = super.$default; - ___$default = true; - } - return __$default; - } - - @override - String? get defaultDescription { - if (!___defaultDescription) { - __defaultDescription = super.defaultDescription; - ___defaultDescription = true; - } - return __defaultDescription; - } - - @override - bool get isContentString => __isContentString ??= super.isContentString; - - @override - String? get formattedDescription { - if (!___formattedDescription) { - __formattedDescription = super.formattedDescription; - ___formattedDescription = true; - } - return __formattedDescription; - } - - @override - Schema rebuild(void Function(SchemaBuilder) updates) => (toBuilder()..update(updates)).build(); - - @override - SchemaBuilder toBuilder() => SchemaBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is Schema && - id == other.id && - ref == other.ref && - oneOf == other.oneOf && - anyOf == other.anyOf && - allOf == other.allOf && - deprecated == other.deprecated && - type == other.type && - format == other.format && - rawDefault == other.rawDefault && - $enum == other.$enum && - properties == other.properties && - required == other.required && - items == other.items && - additionalProperties == other.additionalProperties && - contentMediaType == other.contentMediaType && - contentSchema == other.contentSchema && - discriminator == other.discriminator && - pattern == other.pattern && - minLength == other.minLength && - maxLength == other.maxLength && - minItems == other.minItems && - maxItems == other.maxItems && - nullable == other.nullable; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, id.hashCode); - _$hash = $jc(_$hash, ref.hashCode); - _$hash = $jc(_$hash, oneOf.hashCode); - _$hash = $jc(_$hash, anyOf.hashCode); - _$hash = $jc(_$hash, allOf.hashCode); - _$hash = $jc(_$hash, deprecated.hashCode); - _$hash = $jc(_$hash, type.hashCode); - _$hash = $jc(_$hash, format.hashCode); - _$hash = $jc(_$hash, rawDefault.hashCode); - _$hash = $jc(_$hash, $enum.hashCode); - _$hash = $jc(_$hash, properties.hashCode); - _$hash = $jc(_$hash, required.hashCode); - _$hash = $jc(_$hash, items.hashCode); - _$hash = $jc(_$hash, additionalProperties.hashCode); - _$hash = $jc(_$hash, contentMediaType.hashCode); - _$hash = $jc(_$hash, contentSchema.hashCode); - _$hash = $jc(_$hash, discriminator.hashCode); - _$hash = $jc(_$hash, pattern.hashCode); - _$hash = $jc(_$hash, minLength.hashCode); - _$hash = $jc(_$hash, maxLength.hashCode); - _$hash = $jc(_$hash, minItems.hashCode); - _$hash = $jc(_$hash, maxItems.hashCode); - _$hash = $jc(_$hash, nullable.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'Schema') - ..add('id', id) - ..add('ref', ref) - ..add('oneOf', oneOf) - ..add('anyOf', anyOf) - ..add('allOf', allOf) - ..add('description', description) - ..add('deprecated', deprecated) - ..add('type', type) - ..add('format', format) - ..add('rawDefault', rawDefault) - ..add('\$enum', $enum) - ..add('properties', properties) - ..add('required', required) - ..add('items', items) - ..add('additionalProperties', additionalProperties) - ..add('contentMediaType', contentMediaType) - ..add('contentSchema', contentSchema) - ..add('discriminator', discriminator) - ..add('pattern', pattern) - ..add('minLength', minLength) - ..add('maxLength', maxLength) - ..add('minItems', minItems) - ..add('maxItems', maxItems) - ..add('nullable', nullable)) - .toString(); - } -} - -class SchemaBuilder implements Builder { - _$Schema? _$v; - - Uri? _id; - Uri? get id => _$this._id; - set id(Uri? id) => _$this._id = id; - - Uri? _ref; - Uri? get ref => _$this._ref; - set ref(Uri? ref) => _$this._ref = ref; - - ListBuilder? _oneOf; - ListBuilder get oneOf => _$this._oneOf ??= ListBuilder(); - set oneOf(ListBuilder? oneOf) => _$this._oneOf = oneOf; - - ListBuilder? _anyOf; - ListBuilder get anyOf => _$this._anyOf ??= ListBuilder(); - set anyOf(ListBuilder? anyOf) => _$this._anyOf = anyOf; - - ListBuilder? _allOf; - ListBuilder get allOf => _$this._allOf ??= ListBuilder(); - set allOf(ListBuilder? allOf) => _$this._allOf = allOf; - - String? _description; - String? get description => _$this._description; - set description(String? description) => _$this._description = description; - - bool? _deprecated; - bool? get deprecated => _$this._deprecated; - set deprecated(bool? deprecated) => _$this._deprecated = deprecated; - - SchemaType? _type; - SchemaType? get type => _$this._type; - set type(SchemaType? type) => _$this._type = type; - - String? _format; - String? get format => _$this._format; - set format(String? format) => _$this._format = format; - - JsonObject? _rawDefault; - JsonObject? get rawDefault => _$this._rawDefault; - set rawDefault(JsonObject? rawDefault) => _$this._rawDefault = rawDefault; - - ListBuilder? _$enum; - ListBuilder get $enum => _$this._$enum ??= ListBuilder(); - set $enum(ListBuilder? $enum) => _$this._$enum = $enum; - - MapBuilder? _properties; - MapBuilder get properties => _$this._properties ??= MapBuilder(); - set properties(MapBuilder? properties) => _$this._properties = properties; - - ListBuilder? _required; - ListBuilder get required => _$this._required ??= ListBuilder(); - set required(ListBuilder? required) => _$this._required = required; - - SchemaBuilder? _items; - SchemaBuilder get items => _$this._items ??= SchemaBuilder(); - set items(SchemaBuilder? items) => _$this._items = items; - - SchemaBuilder? _additionalProperties; - SchemaBuilder get additionalProperties => _$this._additionalProperties ??= SchemaBuilder(); - set additionalProperties(SchemaBuilder? additionalProperties) => _$this._additionalProperties = additionalProperties; - - String? _contentMediaType; - String? get contentMediaType => _$this._contentMediaType; - set contentMediaType(String? contentMediaType) => _$this._contentMediaType = contentMediaType; - - SchemaBuilder? _contentSchema; - SchemaBuilder get contentSchema => _$this._contentSchema ??= SchemaBuilder(); - set contentSchema(SchemaBuilder? contentSchema) => _$this._contentSchema = contentSchema; - - DiscriminatorBuilder? _discriminator; - DiscriminatorBuilder get discriminator => _$this._discriminator ??= DiscriminatorBuilder(); - set discriminator(DiscriminatorBuilder? discriminator) => _$this._discriminator = discriminator; - - String? _pattern; - String? get pattern => _$this._pattern; - set pattern(String? pattern) => _$this._pattern = pattern; - - int? _minLength; - int? get minLength => _$this._minLength; - set minLength(int? minLength) => _$this._minLength = minLength; - - int? _maxLength; - int? get maxLength => _$this._maxLength; - set maxLength(int? maxLength) => _$this._maxLength = maxLength; - - int? _minItems; - int? get minItems => _$this._minItems; - set minItems(int? minItems) => _$this._minItems = minItems; - - int? _maxItems; - int? get maxItems => _$this._maxItems; - set maxItems(int? maxItems) => _$this._maxItems = maxItems; - - bool? _nullable; - bool? get nullable => _$this._nullable; - set nullable(bool? nullable) => _$this._nullable = nullable; - - SchemaBuilder(); - - SchemaBuilder get _$this { - final $v = _$v; - if ($v != null) { - _id = $v.id; - _ref = $v.ref; - _oneOf = $v.oneOf?.toBuilder(); - _anyOf = $v.anyOf?.toBuilder(); - _allOf = $v.allOf?.toBuilder(); - _description = $v.description; - _deprecated = $v.deprecated; - _type = $v.type; - _format = $v.format; - _rawDefault = $v.rawDefault; - _$enum = $v.$enum?.toBuilder(); - _properties = $v.properties?.toBuilder(); - _required = $v.required.toBuilder(); - _items = $v.items?.toBuilder(); - _additionalProperties = $v.additionalProperties?.toBuilder(); - _contentMediaType = $v.contentMediaType; - _contentSchema = $v.contentSchema?.toBuilder(); - _discriminator = $v.discriminator?.toBuilder(); - _pattern = $v.pattern; - _minLength = $v.minLength; - _maxLength = $v.maxLength; - _minItems = $v.minItems; - _maxItems = $v.maxItems; - _nullable = $v.nullable; - _$v = null; - } - return this; - } - - @override - void replace(Schema other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$Schema; - } - - @override - void update(void Function(SchemaBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - Schema build() => _build(); - - _$Schema _build() { - Schema._defaults(this); - _$Schema _$result; - try { - _$result = _$v ?? - _$Schema._( - id: id, - ref: ref, - oneOf: _oneOf?.build(), - anyOf: _anyOf?.build(), - allOf: _allOf?.build(), - description: description, - deprecated: BuiltValueNullFieldError.checkNotNull(deprecated, r'Schema', 'deprecated'), - type: type, - format: format, - rawDefault: rawDefault, - $enum: _$enum?.build(), - properties: _properties?.build(), - required: required.build(), - items: _items?.build(), - additionalProperties: _additionalProperties?.build(), - contentMediaType: contentMediaType, - contentSchema: _contentSchema?.build(), - discriminator: _discriminator?.build(), - pattern: pattern, - minLength: minLength, - maxLength: maxLength, - minItems: minItems, - maxItems: maxItems, - nullable: BuiltValueNullFieldError.checkNotNull(nullable, r'Schema', 'nullable')); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'oneOf'; - _oneOf?.build(); - _$failedField = 'anyOf'; - _anyOf?.build(); - _$failedField = 'allOf'; - _allOf?.build(); - - _$failedField = '\$enum'; - _$enum?.build(); - _$failedField = 'properties'; - _properties?.build(); - _$failedField = 'required'; - required.build(); - _$failedField = 'items'; - _items?.build(); - _$failedField = 'additionalProperties'; - _additionalProperties?.build(); - - _$failedField = 'contentSchema'; - _contentSchema?.build(); - _$failedField = 'discriminator'; - _discriminator?.build(); - } catch (e) { - throw BuiltValueNestedFieldError(r'Schema', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/dynamite/dynamite/test/json_schema_test.dart b/packages/dynamite/dynamite/test/json_schema_test.dart new file mode 100644 index 00000000000..7870d9dbd37 --- /dev/null +++ b/packages/dynamite/dynamite/test/json_schema_test.dart @@ -0,0 +1,69 @@ +import 'package:dynamite/src/models/json_schema.dart'; +import 'package:test/test.dart'; + +void main() { + group('JsonSchema deserialization', () { + test(JsonSchema, () { + Object? value = { + 'type': 'integer', + }; + var schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, IntegerSchema()); + + value = { + 'type': 'number', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, NumberSchema()); + + value = { + 'type': 'string', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, StringSchema()); + + value = { + 'type': 'array', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, ArraySchema()); + + value = { + 'type': 'object', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, ObjectSchema()); + + value = { + 'type': 'null', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, NullSchema()); + + value = { + 'type': null, + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, GenericSchema()); + + value = { + r'$ref': '#/Object', + }; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect( + schema, + GenericSchema((b) { + b.ref = Uri.parse('#/Object'); + }), + ); + + value = {}; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, GenericSchema()); + + value = true; + schema = serializers.deserializeWith(JsonSchema.serializer, value); + expect(schema, GenericSchema()); + }); + }); +} diff --git a/packages/dynamite/dynamite/test/openapi_spec_test.dart b/packages/dynamite/dynamite/test/openapi_spec_test.dart index 52fa11264fc..ec1efb13669 100644 --- a/packages/dynamite/dynamite/test/openapi_spec_test.dart +++ b/packages/dynamite/dynamite/test/openapi_spec_test.dart @@ -1,21 +1,12 @@ // ignore_for_file: inference_failure_on_collection_literal import 'package:built_value_test/matcher.dart'; +import 'package:dynamite/src/models/json_schema.dart' hide serializers; import 'package:dynamite/src/models/openapi.dart'; import 'package:test/test.dart'; void main() { group('OpenAPI spec deserialization', () { - test(Schema, () { - Object? value = {}; - var schema = serializers.deserializeWith(Schema.serializer, value); - expect(schema, Schema()); - - value = true; - schema = serializers.deserializeWith(Schema.serializer, value); - expect(schema, Schema()); - }); - test('Schema reference resolving', () { const json = { 'openapi': '3.1.0', @@ -58,14 +49,15 @@ void main() { }; final spec = serializers.deserializeWith(OpenAPI.serializer, json); - final superSchema = spec!.components!.schemas!['SuperClass']!; - expect(superSchema.type, equals(SchemaType.object)); + + final superSchema = spec!.components!.schemas!['SuperClass']! as ObjectSchema; + expect(superSchema.type, equals(JsonSchemaType.object)); final subSchema = spec.components!.schemas!['SubClass']!; expect( subSchema, equalsBuilt( - Schema((b) { + GenericSchema((b) { b.ref = Uri.parse('#/components/schemas/SuperClass'); }), ),