Browse Source

dynamite: Cleanup OpenAPI models

pull/130/head
jld3103 2 years ago
parent
commit
d5af8790f4
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/dynamite/lib/src/models/components.dart
  2. 22
      packages/dynamite/lib/src/models/header.dart
  3. 34
      packages/dynamite/lib/src/models/header.g.dart
  4. 6
      packages/dynamite/lib/src/models/info.dart
  5. 6
      packages/dynamite/lib/src/models/info.g.dart
  6. 4
      packages/dynamite/lib/src/models/license.dart
  7. 2
      packages/dynamite/lib/src/models/media_type.dart
  8. 10
      packages/dynamite/lib/src/models/open_api.dart
  9. 10
      packages/dynamite/lib/src/models/operation.dart
  10. 6
      packages/dynamite/lib/src/models/parameter.dart
  11. 20
      packages/dynamite/lib/src/models/path_item.dart
  12. 6
      packages/dynamite/lib/src/models/request_body.dart
  13. 6
      packages/dynamite/lib/src/models/response.dart
  14. 6
      packages/dynamite/lib/src/models/response.g.dart
  15. 26
      packages/dynamite/lib/src/models/schema.dart
  16. 4
      packages/dynamite/lib/src/models/security_scheme.dart
  17. 2
      packages/dynamite/lib/src/models/server.dart
  18. 4
      packages/dynamite/lib/src/models/server_variable.dart

4
packages/dynamite/lib/src/models/components.dart

@ -7,8 +7,8 @@ part 'components.g.dart';
@JsonSerializable()
class Components {
Components({
required this.securitySchemes,
required this.schemas,
this.securitySchemes,
this.schemas,
});
factory Components.fromJson(final Map<String, dynamic> json) => _$ComponentsFromJson(json);

22
packages/dynamite/lib/src/models/header.dart

@ -0,0 +1,22 @@
import 'package:dynamite/src/models/schema.dart';
import 'package:json_annotation/json_annotation.dart';
part 'header.g.dart';
@JsonSerializable()
class Header {
Header({
this.description,
this.required,
this.schema,
});
factory Header.fromJson(final Map<String, dynamic> json) => _$HeaderFromJson(json);
Map<String, dynamic> toJson() => _$HeaderToJson(this);
final String? description;
final bool? required;
final Schema? schema;
}

34
packages/dynamite/lib/src/models/header.g.dart

@ -0,0 +1,34 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'header.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Header _$HeaderFromJson(Map<String, dynamic> json) {
$checkKeys(
json,
allowedKeys: const ['description', 'required', 'schema'],
);
return Header(
description: json['description'] as String?,
required: json['required'] as bool?,
schema: json['schema'] == null ? null : Schema.fromJson(json['schema'] as Map<String, dynamic>),
);
}
Map<String, dynamic> _$HeaderToJson(Header instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('description', instance.description);
writeNotNull('required', instance.required);
writeNotNull('schema', instance.schema?.toJson());
return val;
}

6
packages/dynamite/lib/src/models/info.dart

@ -8,8 +8,8 @@ class Info {
Info({
required this.title,
required this.version,
required this.description,
required this.license,
this.description,
});
factory Info.fromJson(final Map<String, dynamic> json) => _$InfoFromJson(json);
@ -19,7 +19,7 @@ class Info {
final String version;
final String? description;
final License license;
final String? description;
}

6
packages/dynamite/lib/src/models/info.g.dart

@ -9,13 +9,13 @@ part of 'info.dart';
Info _$InfoFromJson(Map<String, dynamic> json) {
$checkKeys(
json,
allowedKeys: const ['title', 'version', 'description', 'license'],
allowedKeys: const ['title', 'version', 'license', 'description'],
);
return Info(
title: json['title'] as String,
version: json['version'] as String,
description: json['description'] as String?,
license: License.fromJson(json['license'] as Map<String, dynamic>),
description: json['description'] as String?,
);
}
@ -23,6 +23,7 @@ Map<String, dynamic> _$InfoToJson(Info instance) {
final val = <String, dynamic>{
'title': instance.title,
'version': instance.version,
'license': instance.license.toJson(),
};
void writeNotNull(String key, dynamic value) {
@ -32,6 +33,5 @@ Map<String, dynamic> _$InfoToJson(Info instance) {
}
writeNotNull('description', instance.description);
val['license'] = instance.license.toJson();
return val;
}

4
packages/dynamite/lib/src/models/license.dart

@ -6,8 +6,8 @@ part 'license.g.dart';
class License {
License({
required this.name,
required this.identifier,
required this.url,
this.identifier,
this.url,
});
factory License.fromJson(final Map<String, dynamic> json) => _$LicenseFromJson(json);

2
packages/dynamite/lib/src/models/media_type.dart

@ -6,7 +6,7 @@ part 'media_type.g.dart';
@JsonSerializable()
class MediaType {
MediaType({
required this.schema,
this.schema,
});
factory MediaType.fromJson(final Map<String, dynamic> json) => _$MediaTypeFromJson(json);

10
packages/dynamite/lib/src/models/open_api.dart

@ -14,11 +14,11 @@ class OpenAPI {
OpenAPI({
required this.version,
required this.info,
required this.servers,
required this.security,
required this.tags,
required this.components,
required this.paths,
this.servers,
this.security,
this.tags,
this.components,
this.paths,
});
factory OpenAPI.fromJson(final Map<String, dynamic> json) => _$OpenAPIFromJson(json);

10
packages/dynamite/lib/src/models/operation.dart

@ -9,11 +9,11 @@ part 'operation.g.dart';
@JsonSerializable()
class Operation {
Operation({
required this.operationId,
required this.tags,
required this.parameters,
required this.requestBody,
required this.responses,
this.operationId,
this.tags,
this.parameters,
this.requestBody,
this.responses,
});
factory Operation.fromJson(final Map<String, dynamic> json) => _$OperationFromJson(json);

6
packages/dynamite/lib/src/models/parameter.dart

@ -8,9 +8,9 @@ class Parameter {
Parameter({
required this.name,
required this.in_,
required this.description,
required this.required,
required this.schema,
this.description,
this.required,
this.schema,
});
factory Parameter.fromJson(final Map<String, dynamic> json) => _$ParameterFromJson(json);

20
packages/dynamite/lib/src/models/path_item.dart

@ -7,16 +7,16 @@ part 'path_item.g.dart';
@JsonSerializable()
class PathItem {
PathItem({
required this.description,
required this.parameters,
required this.get,
required this.put,
required this.post,
required this.delete,
required this.options,
required this.head,
required this.patch,
required this.trace,
this.description,
this.parameters,
this.get,
this.put,
this.post,
this.delete,
this.options,
this.head,
this.patch,
this.trace,
});
factory PathItem.fromJson(final Map<String, dynamic> json) => _$PathItemFromJson(json);

6
packages/dynamite/lib/src/models/request_body.dart

@ -6,9 +6,9 @@ part 'request_body.g.dart';
@JsonSerializable()
class RequestBody {
RequestBody({
required this.description,
required this.content,
required this.required,
this.description,
this.content,
this.required,
});
factory RequestBody.fromJson(final Map<String, dynamic> json) => _$RequestBodyFromJson(json);

6
packages/dynamite/lib/src/models/response.dart

@ -1,3 +1,4 @@
import 'package:dynamite/src/models/header.dart';
import 'package:dynamite/src/models/media_type.dart';
import 'package:json_annotation/json_annotation.dart';
@ -7,7 +8,8 @@ part 'response.g.dart';
class Response {
Response({
required this.description,
required this.content,
this.content,
this.headers,
});
factory Response.fromJson(final Map<String, dynamic> json) => _$ResponseFromJson(json);
@ -16,4 +18,6 @@ class Response {
final String description;
final Map<String, MediaType>? content;
final Map<String, Header>? headers;
}

6
packages/dynamite/lib/src/models/response.g.dart

@ -9,13 +9,16 @@ part of 'response.dart';
Response _$ResponseFromJson(Map<String, dynamic> json) {
$checkKeys(
json,
allowedKeys: const ['description', 'content'],
allowedKeys: const ['description', 'content', 'headers'],
);
return Response(
description: json['description'] as String,
content: (json['content'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, MediaType.fromJson(e as Map<String, dynamic>)),
),
headers: (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, Header.fromJson(e as Map<String, dynamic>)),
),
);
}
@ -31,5 +34,6 @@ Map<String, dynamic> _$ResponseToJson(Response instance) {
}
writeNotNull('content', instance.content?.map((k, e) => MapEntry(k, e.toJson())));
writeNotNull('headers', instance.headers?.map((k, e) => MapEntry(k, e.toJson())));
return val;
}

26
packages/dynamite/lib/src/models/schema.dart

@ -5,19 +5,19 @@ part 'schema.g.dart';
@JsonSerializable()
class Schema {
Schema({
required this.ref,
required this.oneOf,
required this.anyOf,
required this.allOf,
required this.description,
required this.deprecated,
required this.type,
required this.format,
required this.default_,
required this.enum_,
required this.properties,
required this.required,
required this.items,
this.ref,
this.oneOf,
this.anyOf,
this.allOf,
this.description,
this.deprecated,
this.type,
this.format,
this.default_,
this.enum_,
this.properties,
this.required,
this.items,
});
factory Schema.fromJson(final Map<String, dynamic> json) => _$SchemaFromJson(json);

4
packages/dynamite/lib/src/models/security_scheme.dart

@ -6,8 +6,8 @@ part 'security_scheme.g.dart';
class SecurityScheme {
SecurityScheme({
required this.type,
required this.description,
required this.scheme,
this.description,
this.scheme,
});
factory SecurityScheme.fromJson(final Map<String, dynamic> json) => _$SecuritySchemeFromJson(json);

2
packages/dynamite/lib/src/models/server.dart

@ -7,7 +7,7 @@ part 'server.g.dart';
class Server {
Server({
required this.url,
required this.variables,
this.variables,
});
factory Server.fromJson(final Map<String, dynamic> json) => _$ServerFromJson(json);

4
packages/dynamite/lib/src/models/server_variable.dart

@ -6,8 +6,8 @@ part 'server_variable.g.dart';
class ServerVariable {
ServerVariable({
required this.default_,
required this.enum_,
required this.description,
this.enum_,
this.description,
});
factory ServerVariable.fromJson(final Map<String, dynamic> json) => _$ServerVariableFromJson(json);

Loading…
Cancel
Save