diff --git a/packages/dynamite/lib/src/models/schema.dart b/packages/dynamite/lib/src/models/schema.dart index dbfffb29..fc59f41f 100644 --- a/packages/dynamite/lib/src/models/schema.dart +++ b/packages/dynamite/lib/src/models/schema.dart @@ -1,4 +1,3 @@ -import 'package:dynamite/src/models/media_type.dart'; import 'package:json_annotation/json_annotation.dart'; part 'schema.g.dart'; @@ -20,7 +19,8 @@ class Schema { this.required, this.items, this.additionalProperties, - this.content, + this.contentMediaType, + this.contentSchema, }); factory Schema.fromJson(final Map json) => _$SchemaFromJson(json); @@ -59,7 +59,9 @@ class Schema { final bool? additionalProperties; - final Map? content; + final String? contentMediaType; - bool get isJsonString => type == 'string' && content?['application/json']?.schema != null; + final Schema? contentSchema; + + bool get isJsonString => type == 'string' && contentMediaType == 'application/json' && contentSchema != null; } diff --git a/packages/dynamite/lib/src/models/schema.g.dart b/packages/dynamite/lib/src/models/schema.g.dart index a3418539..1afeb5be 100644 --- a/packages/dynamite/lib/src/models/schema.g.dart +++ b/packages/dynamite/lib/src/models/schema.g.dart @@ -24,7 +24,8 @@ Schema _$SchemaFromJson(Map json) { 'required', 'items', 'additionalProperties', - 'content' + 'contentMediaType', + 'contentSchema' ], ); return Schema( @@ -44,9 +45,9 @@ Schema _$SchemaFromJson(Map json) { required: (json['required'] as List?)?.map((e) => e as String).toList(), items: json['items'] == null ? null : Schema.fromJson(json['items'] as Map), additionalProperties: json['additionalProperties'] as bool?, - content: (json['content'] as Map?)?.map( - (k, e) => MapEntry(k, MediaType.fromJson(e as Map)), - ), + contentMediaType: json['contentMediaType'] as String?, + contentSchema: + json['contentSchema'] == null ? null : Schema.fromJson(json['contentSchema'] as Map), ); } @@ -73,6 +74,7 @@ Map _$SchemaToJson(Schema instance) { writeNotNull('required', instance.required); writeNotNull('items', instance.items?.toJson()); writeNotNull('additionalProperties', instance.additionalProperties); - writeNotNull('content', instance.content?.map((k, e) => MapEntry(k, e.toJson()))); + writeNotNull('contentMediaType', instance.contentMediaType); + writeNotNull('contentSchema', instance.contentSchema?.toJson()); return val; } diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index 4594a45d..99aa70fb 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -1332,7 +1332,7 @@ TypeResult resolveType( spec, state, identifier, - schema.content!['application/json']!.schema!, + schema.contentSchema!, extraJsonSerializableValues: extraJsonSerializableValues, ); break;