Browse Source

feat(dynamite): make models immutable

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/694/head
Nikolas Rimikis 1 year ago
parent
commit
c65521f041
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 4
      packages/dynamite/dynamite/lib/src/models/components.dart
  2. 4
      packages/dynamite/dynamite/lib/src/models/discriminator.dart
  3. 4
      packages/dynamite/dynamite/lib/src/models/header.dart
  4. 4
      packages/dynamite/dynamite/lib/src/models/info.dart
  5. 4
      packages/dynamite/dynamite/lib/src/models/license.dart
  6. 4
      packages/dynamite/dynamite/lib/src/models/media_type.dart
  7. 4
      packages/dynamite/dynamite/lib/src/models/open_api.dart
  8. 4
      packages/dynamite/dynamite/lib/src/models/operation.dart
  9. 4
      packages/dynamite/dynamite/lib/src/models/parameter.dart
  10. 4
      packages/dynamite/dynamite/lib/src/models/path_item.dart
  11. 4
      packages/dynamite/dynamite/lib/src/models/request_body.dart
  12. 4
      packages/dynamite/dynamite/lib/src/models/response.dart
  13. 10
      packages/dynamite/dynamite/lib/src/models/schema.dart
  14. 4
      packages/dynamite/dynamite/lib/src/models/security_scheme.dart
  15. 4
      packages/dynamite/dynamite/lib/src/models/server.dart
  16. 4
      packages/dynamite/dynamite/lib/src/models/server_variable.dart
  17. 4
      packages/dynamite/dynamite/lib/src/models/tag.dart

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

@ -1,12 +1,14 @@
import 'package:dynamite/src/models/schema.dart';
import 'package:dynamite/src/models/security_scheme.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'components.g.dart';
@JsonSerializable()
@immutable
class Components {
Components({
const Components({
this.securitySchemes,
this.schemas,
});

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

@ -1,10 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'discriminator.g.dart';
@JsonSerializable()
@immutable
class Discriminator {
Discriminator({
const Discriminator({
required this.propertyName,
this.mapping,
});

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/schema.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'header.g.dart';
@JsonSerializable()
@immutable
class Header {
Header({
const Header({
this.description,
this.required,
this.schema,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/license.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'info.g.dart';
@JsonSerializable()
@immutable
class Info {
Info({
const Info({
required this.title,
required this.version,
required this.license,

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

@ -1,10 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'license.g.dart';
@JsonSerializable()
@immutable
class License {
License({
const License({
required this.name,
this.identifier,
this.url,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/schema.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'media_type.g.dart';
@JsonSerializable()
@immutable
class MediaType {
MediaType({
const MediaType({
this.schema,
});

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

@ -6,12 +6,14 @@ 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';
import 'package:meta/meta.dart';
part 'open_api.g.dart';
@JsonSerializable()
@immutable
class OpenAPI {
OpenAPI({
const OpenAPI({
required this.version,
required this.info,
this.servers,

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

@ -4,12 +4,14 @@ import 'package:dynamite/src/models/response.dart';
import 'package:dynamite/src/models/responses.dart';
import 'package:dynamite/src/models/security_requirement.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'operation.g.dart';
@JsonSerializable()
@immutable
class Operation {
Operation({
const Operation({
this.operationId,
this.summary,
this.description,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/schema.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'parameter.g.dart';
@JsonSerializable()
@immutable
class Parameter {
Parameter({
const Parameter({
required this.name,
required this.in_,
this.description,

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

@ -1,12 +1,14 @@
import 'package:dynamite/src/models/operation.dart';
import 'package:dynamite/src/models/parameter.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'path_item.g.dart';
@JsonSerializable()
@immutable
class PathItem {
PathItem({
const PathItem({
this.description,
this.parameters,
this.get,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/media_type.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'request_body.g.dart';
@JsonSerializable()
@immutable
class RequestBody {
RequestBody({
const RequestBody({
this.description,
this.content,
this.required,

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

@ -1,12 +1,14 @@
import 'package:dynamite/src/models/header.dart';
import 'package:dynamite/src/models/media_type.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'response.g.dart';
@JsonSerializable()
@immutable
class Response {
Response({
const Response({
required this.description,
this.content,
this.headers,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/discriminator.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'schema.g.dart';
@JsonSerializable()
@immutable
class Schema {
Schema({
const Schema({
this.ref,
this.oneOf,
this.anyOf,
@ -85,7 +87,9 @@ class Schema {
bool get isContentString => type == 'string' && (contentMediaType?.isNotEmpty ?? false) && contentSchema != null;
}
class EmptySchema extends Schema {}
class EmptySchema extends Schema {
const EmptySchema();
}
Schema? _parseAdditionalProperties(final dynamic data) {
if (data == null) {
@ -93,7 +97,7 @@ Schema? _parseAdditionalProperties(final dynamic data) {
}
if (data is bool) {
return data ? EmptySchema() : null;
return data ? const EmptySchema() : null;
}
if (data is Map<String, dynamic>) {

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

@ -1,10 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'security_scheme.g.dart';
@JsonSerializable()
@immutable
class SecurityScheme {
SecurityScheme({
const SecurityScheme({
required this.type,
this.description,
this.scheme,

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

@ -1,11 +1,13 @@
import 'package:dynamite/src/models/server_variable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'server.g.dart';
@JsonSerializable()
@immutable
class Server {
Server({
const Server({
required this.url,
this.variables,
});

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

@ -1,10 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'server_variable.g.dart';
@JsonSerializable()
@immutable
class ServerVariable {
ServerVariable({
const ServerVariable({
required this.default_,
this.enum_,
this.description,

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

@ -1,10 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'tag.g.dart';
@JsonSerializable()
@immutable
class Tag {
Tag({
const Tag({
required this.name,
this.description,
});

Loading…
Cancel
Save