jld3103
2 years ago
44 changed files with 2565 additions and 146 deletions
@ -0,0 +1,10 @@
|
||||
# Files and directories created by pub. |
||||
.dart_tool/ |
||||
.packages |
||||
|
||||
# Conventional directory for build outputs. |
||||
build/ |
||||
|
||||
# Omit committing pubspec.lock for library packages; see |
||||
# https://dart.dev/guides/libraries/private-files#pubspeclock. |
||||
pubspec.lock |
@ -0,0 +1,9 @@
|
||||
include: package:nit_picking/dart.yaml |
||||
|
||||
linter: |
||||
rules: |
||||
public_member_api_docs: false |
||||
|
||||
analyzer: |
||||
exclude: |
||||
- '**.g.dart' |
@ -0,0 +1,22 @@
|
||||
targets: |
||||
$default: |
||||
builders: |
||||
json_serializable: |
||||
options: |
||||
disallow_unrecognized_keys: true |
||||
explicit_to_json: true |
||||
create_factory: true |
||||
create_to_json: true |
||||
include_if_null: false |
||||
dynamite: |
||||
enabled: true |
||||
|
||||
builders: |
||||
dynamite: |
||||
import: "package:dynamite/builder.dart" |
||||
builder_factories: ["openAPIBuilder"] |
||||
build_extensions: {'.openapi.json': ['openapi.dart']} |
||||
auto_apply: root_package |
||||
build_to: source |
||||
runs_before: ["json_serializable"] |
||||
applies_builders: ["json_serializable"] |
@ -0,0 +1,4 @@
|
||||
import 'package:build/build.dart'; |
||||
import 'package:dynamite/dynamite.dart'; |
||||
|
||||
Builder openAPIBuilder(final BuilderOptions options) => OpenAPIBuilder(); |
@ -0,0 +1,15 @@
|
||||
library dynamite; |
||||
|
||||
import 'dart:convert'; |
||||
|
||||
import 'package:build/build.dart'; |
||||
import 'package:code_builder/code_builder.dart'; |
||||
import 'package:dart_style/dart_style.dart'; |
||||
import 'package:dynamite/src/models/open_api.dart'; |
||||
import 'package:dynamite/src/models/parameter.dart' as spec_parameter; |
||||
import 'package:dynamite/src/models/path_item.dart'; |
||||
import 'package:dynamite/src/models/schema.dart'; |
||||
import 'package:dynamite/src/models/tag.dart'; |
||||
import 'package:path/path.dart' as p; |
||||
|
||||
part 'src/openapi_builder.dart'; |
@ -0,0 +1,20 @@
|
||||
import 'package:dynamite/src/models/schema.dart'; |
||||
import 'package:dynamite/src/models/security_scheme.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'components.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Components { |
||||
Components({ |
||||
required this.securitySchemes, |
||||
required this.schemas, |
||||
}); |
||||
|
||||
factory Components.fromJson(final Map<String, dynamic> json) => _$ComponentsFromJson(json); |
||||
Map<String, dynamic> toJson() => _$ComponentsToJson(this); |
||||
|
||||
final Map<String, SecurityScheme>? securitySchemes; |
||||
|
||||
final Map<String, Schema>? schemas; |
||||
} |
@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'components.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Components _$ComponentsFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['securitySchemes', 'schemas'], |
||||
); |
||||
return Components( |
||||
securitySchemes: (json['securitySchemes'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, SecurityScheme.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
schemas: (json['schemas'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, Schema.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$ComponentsToJson(Components instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('securitySchemes', instance.securitySchemes?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
writeNotNull('schemas', instance.schemas?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
return val; |
||||
} |
@ -0,0 +1,25 @@
|
||||
import 'package:dynamite/src/models/license.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'info.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Info { |
||||
Info({ |
||||
required this.title, |
||||
required this.version, |
||||
required this.description, |
||||
required this.license, |
||||
}); |
||||
|
||||
factory Info.fromJson(final Map<String, dynamic> json) => _$InfoFromJson(json); |
||||
Map<String, dynamic> toJson() => _$InfoToJson(this); |
||||
|
||||
final String title; |
||||
|
||||
final String version; |
||||
|
||||
final String? description; |
||||
|
||||
final License license; |
||||
} |
@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'info.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Info _$InfoFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['title', 'version', 'description', 'license'], |
||||
); |
||||
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>), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$InfoToJson(Info instance) { |
||||
final val = <String, dynamic>{ |
||||
'title': instance.title, |
||||
'version': instance.version, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('description', instance.description); |
||||
val['license'] = instance.license.toJson(); |
||||
return val; |
||||
} |
@ -0,0 +1,21 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'license.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class License { |
||||
License({ |
||||
required this.name, |
||||
required this.identifier, |
||||
required this.url, |
||||
}); |
||||
|
||||
factory License.fromJson(final Map<String, dynamic> json) => _$LicenseFromJson(json); |
||||
Map<String, dynamic> toJson() => _$LicenseToJson(this); |
||||
|
||||
final String name; |
||||
|
||||
final String? identifier; |
||||
|
||||
final String? url; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'license.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
License _$LicenseFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['name', 'identifier', 'url'], |
||||
); |
||||
return License( |
||||
name: json['name'] as String, |
||||
identifier: json['identifier'] as String?, |
||||
url: json['url'] as String?, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$LicenseToJson(License instance) { |
||||
final val = <String, dynamic>{ |
||||
'name': instance.name, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('identifier', instance.identifier); |
||||
writeNotNull('url', instance.url); |
||||
return val; |
||||
} |
@ -0,0 +1,16 @@
|
||||
import 'package:dynamite/src/models/schema.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'media_type.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class MediaType { |
||||
MediaType({ |
||||
required this.schema, |
||||
}); |
||||
|
||||
factory MediaType.fromJson(final Map<String, dynamic> json) => _$MediaTypeFromJson(json); |
||||
Map<String, dynamic> toJson() => _$MediaTypeToJson(this); |
||||
|
||||
final Schema? schema; |
||||
} |
@ -0,0 +1,30 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'media_type.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
MediaType _$MediaTypeFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['schema'], |
||||
); |
||||
return MediaType( |
||||
schema: json['schema'] == null ? null : Schema.fromJson(json['schema'] as Map<String, dynamic>), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$MediaTypeToJson(MediaType instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('schema', instance.schema?.toJson()); |
||||
return val; |
||||
} |
@ -0,0 +1,41 @@
|
||||
import 'package:dynamite/src/models/components.dart'; |
||||
import 'package:dynamite/src/models/info.dart'; |
||||
import 'package:dynamite/src/models/path_item.dart'; |
||||
import 'package:dynamite/src/models/paths.dart'; |
||||
import 'package:dynamite/src/models/security_requirement.dart'; |
||||
import 'package:dynamite/src/models/server.dart'; |
||||
import 'package:dynamite/src/models/tag.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'open_api.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class OpenAPI { |
||||
OpenAPI({ |
||||
required this.version, |
||||
required this.info, |
||||
required this.servers, |
||||
required this.security, |
||||
required this.tags, |
||||
required this.components, |
||||
required this.paths, |
||||
}); |
||||
|
||||
factory OpenAPI.fromJson(final Map<String, dynamic> json) => _$OpenAPIFromJson(json); |
||||
Map<String, dynamic> toJson() => _$OpenAPIToJson(this); |
||||
|
||||
@JsonKey(name: 'openapi') |
||||
final String version; |
||||
|
||||
final Info info; |
||||
|
||||
final List<Server>? servers; |
||||
|
||||
final List<SecurityRequirement>? security; |
||||
|
||||
final List<Tag>? tags; |
||||
|
||||
final Components? components; |
||||
|
||||
final Paths? paths; |
||||
} |
@ -0,0 +1,49 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'open_api.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
OpenAPI _$OpenAPIFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['openapi', 'info', 'servers', 'security', 'tags', 'components', 'paths'], |
||||
); |
||||
return OpenAPI( |
||||
version: json['openapi'] as String, |
||||
info: Info.fromJson(json['info'] as Map<String, dynamic>), |
||||
servers: (json['servers'] as List<dynamic>?)?.map((e) => Server.fromJson(e as Map<String, dynamic>)).toList(), |
||||
security: (json['security'] as List<dynamic>?) |
||||
?.map((e) => (e as Map<String, dynamic>).map( |
||||
(k, e) => MapEntry(k, (e as List<dynamic>).map((e) => e as String).toList()), |
||||
)) |
||||
.toList(), |
||||
tags: (json['tags'] as List<dynamic>?)?.map((e) => Tag.fromJson(e as Map<String, dynamic>)).toList(), |
||||
components: json['components'] == null ? null : Components.fromJson(json['components'] as Map<String, dynamic>), |
||||
paths: (json['paths'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, PathItem.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$OpenAPIToJson(OpenAPI instance) { |
||||
final val = <String, dynamic>{ |
||||
'openapi': instance.version, |
||||
'info': instance.info.toJson(), |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('servers', instance.servers?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('security', instance.security); |
||||
writeNotNull('tags', instance.tags?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('components', instance.components?.toJson()); |
||||
writeNotNull('paths', instance.paths?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
return val; |
||||
} |
@ -0,0 +1,31 @@
|
||||
import 'package:dynamite/src/models/parameter.dart'; |
||||
import 'package:dynamite/src/models/request_body.dart'; |
||||
import 'package:dynamite/src/models/response.dart'; |
||||
import 'package:dynamite/src/models/responses.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'operation.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Operation { |
||||
Operation({ |
||||
required this.operationId, |
||||
required this.tags, |
||||
required this.parameters, |
||||
required this.requestBody, |
||||
required this.responses, |
||||
}); |
||||
|
||||
factory Operation.fromJson(final Map<String, dynamic> json) => _$OperationFromJson(json); |
||||
Map<String, dynamic> toJson() => _$OperationToJson(this); |
||||
|
||||
final String? operationId; |
||||
|
||||
final List<String>? tags; |
||||
|
||||
final List<Parameter>? parameters; |
||||
|
||||
final RequestBody? requestBody; |
||||
|
||||
final Responses? responses; |
||||
} |
@ -0,0 +1,41 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'operation.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Operation _$OperationFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['operationId', 'tags', 'parameters', 'requestBody', 'responses'], |
||||
); |
||||
return Operation( |
||||
operationId: json['operationId'] as String?, |
||||
tags: (json['tags'] as List<dynamic>?)?.map((e) => e as String).toList(), |
||||
parameters: |
||||
(json['parameters'] as List<dynamic>?)?.map((e) => Parameter.fromJson(e as Map<String, dynamic>)).toList(), |
||||
requestBody: json['requestBody'] == null ? null : RequestBody.fromJson(json['requestBody'] as Map<String, dynamic>), |
||||
responses: (json['responses'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, Response.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$OperationToJson(Operation instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('operationId', instance.operationId); |
||||
writeNotNull('tags', instance.tags); |
||||
writeNotNull('parameters', instance.parameters?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('requestBody', instance.requestBody?.toJson()); |
||||
writeNotNull('responses', instance.responses?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
return val; |
||||
} |
@ -0,0 +1,29 @@
|
||||
import 'package:dynamite/src/models/schema.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'parameter.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Parameter { |
||||
Parameter({ |
||||
required this.name, |
||||
required this.in_, |
||||
required this.description, |
||||
required this.required, |
||||
required this.schema, |
||||
}); |
||||
|
||||
factory Parameter.fromJson(final Map<String, dynamic> json) => _$ParameterFromJson(json); |
||||
Map<String, dynamic> toJson() => _$ParameterToJson(this); |
||||
|
||||
final String name; |
||||
|
||||
@JsonKey(name: 'in') |
||||
final String in_; |
||||
|
||||
final String? description; |
||||
|
||||
final bool? required; |
||||
|
||||
final Schema? schema; |
||||
} |
@ -0,0 +1,39 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'parameter.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Parameter _$ParameterFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['name', 'in', 'description', 'required', 'schema'], |
||||
); |
||||
return Parameter( |
||||
name: json['name'] as String, |
||||
in_: json['in'] as String, |
||||
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> _$ParameterToJson(Parameter instance) { |
||||
final val = <String, dynamic>{ |
||||
'name': instance.name, |
||||
'in': instance.in_, |
||||
}; |
||||
|
||||
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; |
||||
} |
@ -0,0 +1,68 @@
|
||||
import 'package:dynamite/src/models/operation.dart'; |
||||
import 'package:dynamite/src/models/parameter.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
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, |
||||
}); |
||||
|
||||
factory PathItem.fromJson(final Map<String, dynamic> json) => _$PathItemFromJson(json); |
||||
Map<String, dynamic> toJson() => _$PathItemToJson(this); |
||||
|
||||
final String? description; |
||||
|
||||
final List<Parameter>? parameters; |
||||
|
||||
final Operation? get; |
||||
|
||||
final Operation? put; |
||||
|
||||
final Operation? post; |
||||
|
||||
final Operation? delete; |
||||
|
||||
final Operation? options; |
||||
|
||||
final Operation? head; |
||||
|
||||
final Operation? patch; |
||||
|
||||
final Operation? trace; |
||||
|
||||
Map<String, Operation> get operations => <String, Operation>{ |
||||
if (get != null) 'get': get!, |
||||
if (put != null) 'put': put!, |
||||
if (post != null) 'post': post!, |
||||
if (delete != null) 'delete': delete!, |
||||
if (options != null) 'options': options!, |
||||
if (head != null) 'head': head!, |
||||
if (patch != null) 'patch': patch!, |
||||
if (trace != null) 'trace': trace!, |
||||
}; |
||||
|
||||
PathItem copyWithOperations(final Map<String, Operation> operations) => PathItem( |
||||
description: description, |
||||
parameters: parameters, |
||||
get: operations['get'] ?? get, |
||||
put: operations['put'] ?? put, |
||||
post: operations['post'] ?? post, |
||||
delete: operations['delete'] ?? delete, |
||||
options: operations['options'] ?? options, |
||||
head: operations['head'] ?? head, |
||||
patch: operations['patch'] ?? patch, |
||||
trace: operations['trace'] ?? trace, |
||||
); |
||||
} |
@ -0,0 +1,60 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'path_item.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
PathItem _$PathItemFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const [ |
||||
'description', |
||||
'parameters', |
||||
'get', |
||||
'put', |
||||
'post', |
||||
'delete', |
||||
'options', |
||||
'head', |
||||
'patch', |
||||
'trace' |
||||
], |
||||
); |
||||
return PathItem( |
||||
description: json['description'] as String?, |
||||
parameters: |
||||
(json['parameters'] as List<dynamic>?)?.map((e) => Parameter.fromJson(e as Map<String, dynamic>)).toList(), |
||||
get: json['get'] == null ? null : Operation.fromJson(json['get'] as Map<String, dynamic>), |
||||
put: json['put'] == null ? null : Operation.fromJson(json['put'] as Map<String, dynamic>), |
||||
post: json['post'] == null ? null : Operation.fromJson(json['post'] as Map<String, dynamic>), |
||||
delete: json['delete'] == null ? null : Operation.fromJson(json['delete'] as Map<String, dynamic>), |
||||
options: json['options'] == null ? null : Operation.fromJson(json['options'] as Map<String, dynamic>), |
||||
head: json['head'] == null ? null : Operation.fromJson(json['head'] as Map<String, dynamic>), |
||||
patch: json['patch'] == null ? null : Operation.fromJson(json['patch'] as Map<String, dynamic>), |
||||
trace: json['trace'] == null ? null : Operation.fromJson(json['trace'] as Map<String, dynamic>), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$PathItemToJson(PathItem instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('description', instance.description); |
||||
writeNotNull('parameters', instance.parameters?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('get', instance.get?.toJson()); |
||||
writeNotNull('put', instance.put?.toJson()); |
||||
writeNotNull('post', instance.post?.toJson()); |
||||
writeNotNull('delete', instance.delete?.toJson()); |
||||
writeNotNull('options', instance.options?.toJson()); |
||||
writeNotNull('head', instance.head?.toJson()); |
||||
writeNotNull('patch', instance.patch?.toJson()); |
||||
writeNotNull('trace', instance.trace?.toJson()); |
||||
return val; |
||||
} |
@ -0,0 +1,3 @@
|
||||
import 'package:dynamite/src/models/path_item.dart'; |
||||
|
||||
typedef Paths = Map<String, PathItem>; |
@ -0,0 +1,22 @@
|
||||
import 'package:dynamite/src/models/media_type.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'request_body.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class RequestBody { |
||||
RequestBody({ |
||||
required this.description, |
||||
required this.content, |
||||
required this.required, |
||||
}); |
||||
|
||||
factory RequestBody.fromJson(final Map<String, dynamic> json) => _$RequestBodyFromJson(json); |
||||
Map<String, dynamic> toJson() => _$RequestBodyToJson(this); |
||||
|
||||
final String? description; |
||||
|
||||
final Map<String, MediaType>? content; |
||||
|
||||
final bool? required; |
||||
} |
@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'request_body.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
RequestBody _$RequestBodyFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['description', 'content', 'required'], |
||||
); |
||||
return RequestBody( |
||||
description: json['description'] as String?, |
||||
content: (json['content'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, MediaType.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
required: json['required'] as bool?, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$RequestBodyToJson(RequestBody instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('description', instance.description); |
||||
writeNotNull('content', instance.content?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
writeNotNull('required', instance.required); |
||||
return val; |
||||
} |
@ -0,0 +1,19 @@
|
||||
import 'package:dynamite/src/models/media_type.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'response.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Response { |
||||
Response({ |
||||
required this.description, |
||||
required this.content, |
||||
}); |
||||
|
||||
factory Response.fromJson(final Map<String, dynamic> json) => _$ResponseFromJson(json); |
||||
Map<String, dynamic> toJson() => _$ResponseToJson(this); |
||||
|
||||
final String description; |
||||
|
||||
final Map<String, MediaType>? content; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'response.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Response _$ResponseFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['description', 'content'], |
||||
); |
||||
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>)), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$ResponseToJson(Response instance) { |
||||
final val = <String, dynamic>{ |
||||
'description': instance.description, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('content', instance.content?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
return val; |
||||
} |
@ -0,0 +1,3 @@
|
||||
import 'package:dynamite/src/models/response.dart'; |
||||
|
||||
typedef Responses = Map<String, Response>; |
@ -0,0 +1,53 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
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.items, |
||||
}); |
||||
|
||||
factory Schema.fromJson(final Map<String, dynamic> json) => _$SchemaFromJson(json); |
||||
Map<String, dynamic> toJson() => _$SchemaToJson(this); |
||||
|
||||
@JsonKey(name: r'$ref') |
||||
final String? ref; |
||||
|
||||
final List<Schema>? oneOf; |
||||
|
||||
final List<Schema>? anyOf; |
||||
|
||||
final List<Schema>? allOf; |
||||
|
||||
List<Schema>? get ofs => oneOf ?? anyOf ?? allOf; |
||||
|
||||
final String? description; |
||||
|
||||
final bool? deprecated; |
||||
|
||||
final String? type; |
||||
|
||||
final String? format; |
||||
|
||||
@JsonKey(name: 'default') |
||||
final dynamic default_; |
||||
|
||||
@JsonKey(name: 'enum') |
||||
final List<dynamic>? enum_; |
||||
|
||||
final Map<String, Schema>? properties; |
||||
|
||||
final Schema? items; |
||||
} |
@ -0,0 +1,67 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'schema.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Schema _$SchemaFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const [ |
||||
r'$ref', |
||||
'oneOf', |
||||
'anyOf', |
||||
'allOf', |
||||
'description', |
||||
'deprecated', |
||||
'type', |
||||
'format', |
||||
'default', |
||||
'enum', |
||||
'properties', |
||||
'items' |
||||
], |
||||
); |
||||
return Schema( |
||||
ref: json[r'$ref'] as String?, |
||||
oneOf: (json['oneOf'] as List<dynamic>?)?.map((e) => Schema.fromJson(e as Map<String, dynamic>)).toList(), |
||||
anyOf: (json['anyOf'] as List<dynamic>?)?.map((e) => Schema.fromJson(e as Map<String, dynamic>)).toList(), |
||||
allOf: (json['allOf'] as List<dynamic>?)?.map((e) => Schema.fromJson(e as Map<String, dynamic>)).toList(), |
||||
description: json['description'] as String?, |
||||
deprecated: json['deprecated'] as bool?, |
||||
type: json['type'] as String?, |
||||
format: json['format'] as String?, |
||||
default_: json['default'], |
||||
enum_: json['enum'] as List<dynamic>?, |
||||
properties: (json['properties'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, Schema.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
items: json['items'] == null ? null : Schema.fromJson(json['items'] as Map<String, dynamic>), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$SchemaToJson(Schema instance) { |
||||
final val = <String, dynamic>{}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull(r'$ref', instance.ref); |
||||
writeNotNull('oneOf', instance.oneOf?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('anyOf', instance.anyOf?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('allOf', instance.allOf?.map((e) => e.toJson()).toList()); |
||||
writeNotNull('description', instance.description); |
||||
writeNotNull('deprecated', instance.deprecated); |
||||
writeNotNull('type', instance.type); |
||||
writeNotNull('format', instance.format); |
||||
writeNotNull('default', instance.default_); |
||||
writeNotNull('enum', instance.enum_); |
||||
writeNotNull('properties', instance.properties?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
writeNotNull('items', instance.items?.toJson()); |
||||
return val; |
||||
} |
@ -0,0 +1 @@
|
||||
typedef SecurityRequirement = Map<String, List<String>>; |
@ -0,0 +1,19 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'security_scheme.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class SecurityScheme { |
||||
SecurityScheme({ |
||||
required this.type, |
||||
required this.description, |
||||
required this.scheme, |
||||
}); |
||||
|
||||
factory SecurityScheme.fromJson(final Map<String, dynamic> json) => _$SecuritySchemeFromJson(json); |
||||
Map<String, dynamic> toJson() => _$SecuritySchemeToJson(this); |
||||
|
||||
final String type; |
||||
final String? description; |
||||
final String? scheme; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'security_scheme.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
SecurityScheme _$SecuritySchemeFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['type', 'description', 'scheme'], |
||||
); |
||||
return SecurityScheme( |
||||
type: json['type'] as String, |
||||
description: json['description'] as String?, |
||||
scheme: json['scheme'] as String?, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$SecuritySchemeToJson(SecurityScheme instance) { |
||||
final val = <String, dynamic>{ |
||||
'type': instance.type, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('description', instance.description); |
||||
writeNotNull('scheme', instance.scheme); |
||||
return val; |
||||
} |
@ -0,0 +1,19 @@
|
||||
import 'package:dynamite/src/models/server_variable.dart'; |
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'server.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Server { |
||||
Server({ |
||||
required this.url, |
||||
required this.variables, |
||||
}); |
||||
|
||||
factory Server.fromJson(final Map<String, dynamic> json) => _$ServerFromJson(json); |
||||
Map<String, dynamic> toJson() => _$ServerToJson(this); |
||||
|
||||
final String url; |
||||
|
||||
final Map<String, ServerVariable>? variables; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'server.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Server _$ServerFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['url', 'variables'], |
||||
); |
||||
return Server( |
||||
url: json['url'] as String, |
||||
variables: (json['variables'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, ServerVariable.fromJson(e as Map<String, dynamic>)), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$ServerToJson(Server instance) { |
||||
final val = <String, dynamic>{ |
||||
'url': instance.url, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('variables', instance.variables?.map((k, e) => MapEntry(k, e.toJson()))); |
||||
return val; |
||||
} |
@ -0,0 +1,23 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'server_variable.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class ServerVariable { |
||||
ServerVariable({ |
||||
required this.default_, |
||||
required this.enum_, |
||||
required this.description, |
||||
}); |
||||
|
||||
factory ServerVariable.fromJson(final Map<String, dynamic> json) => _$ServerVariableFromJson(json); |
||||
Map<String, dynamic> toJson() => _$ServerVariableToJson(this); |
||||
|
||||
@JsonKey(name: 'default') |
||||
final String default_; |
||||
|
||||
@JsonKey(name: 'enum') |
||||
final List<String>? enum_; |
||||
|
||||
final String? description; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'server_variable.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
ServerVariable _$ServerVariableFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['default', 'enum', 'description'], |
||||
); |
||||
return ServerVariable( |
||||
default_: json['default'] as String, |
||||
enum_: (json['enum'] as List<dynamic>?)?.map((e) => e as String).toList(), |
||||
description: json['description'] as String?, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$ServerVariableToJson(ServerVariable instance) { |
||||
final val = <String, dynamic>{ |
||||
'default': instance.default_, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('enum', instance.enum_); |
||||
writeNotNull('description', instance.description); |
||||
return val; |
||||
} |
@ -0,0 +1,15 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'tag.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Tag { |
||||
Tag({ |
||||
required this.name, |
||||
}); |
||||
|
||||
factory Tag.fromJson(final Map<String, dynamic> json) => _$TagFromJson(json); |
||||
Map<String, dynamic> toJson() => _$TagToJson(this); |
||||
|
||||
final String name; |
||||
} |
@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'tag.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Tag _$TagFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['name'], |
||||
); |
||||
return Tag( |
||||
name: json['name'] as String, |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$TagToJson(Tag instance) => <String, dynamic>{ |
||||
'name': instance.name, |
||||
}; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
sdk: |
||||
- stable |
||||
|
||||
stages: |
||||
- analyze: |
||||
- analyze: --fatal-infos . |
||||
- format: --output=none --set-exit-if-changed --line-length 120 . |
@ -0,0 +1,20 @@
|
||||
name: dynamite |
||||
version: 1.0.0 |
||||
|
||||
environment: |
||||
sdk: '>=2.18.0 <3.0.0' |
||||
|
||||
dependencies: |
||||
build: ^2.3.1 |
||||
code_builder: ^4.3.0 |
||||
dart_style: ^2.2.4 |
||||
json_annotation: ^4.6.0 |
||||
path: ^1.8.2 |
||||
|
||||
dev_dependencies: |
||||
build_runner: ^2.2.1 |
||||
json_serializable: ^6.3.2 |
||||
nit_picking: |
||||
git: |
||||
url: https://github.com/stack11/dart_nit_picking |
||||
ref: f29382f |
Loading…
Reference in new issue