Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
A field is required in Dart when it is
required && !defaultValue in OAS
}}
{{#required}}{{^defaultValue}}required {{/defaultValue}}{{/required}}this.{{{name}}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{.}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}},
{{#required}}{{^defaultValue}}required {{/defaultValue}}{{/required}}this.{{{name}}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}{{^isNumeric}}const {{{enumName}}}._({{/isNumeric}}{{/isContainer}}{{/isEnum}}{{{.}}}{{#isEnum}}{{^isContainer}}{{^isNumeric}}){{/isNumeric}}{{/isContainer}}{{/isEnum}}{{/defaultValue}},
{{/vars}}
});
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class {{{classname}}} {

/// Returns a new [{{{classname}}}] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static {{{classname}}}? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
Expand Down Expand Up @@ -219,8 +218,7 @@ class {{{classname}}} {
{{^isEnum}}
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
{{/isEnum}}
{{#isEnum}}
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
{{#isEnum}}{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{#isEnum}}{{^isContainer}}{{^isNumeric}}const {{{enumName}}}._({{/isNumeric}}{{/isContainer}}{{/isEnum}}{{{.}}}{{#isEnum}}{{^isContainer}}{{^isNumeric}}){{/isNumeric}}{{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/required}},
{{/isEnum}}
{{/isNumber}}
{{/isMap}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class {{{classname}}} {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [{{{classname}}}] to {{{dataType}}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class {{{enumName}}} {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is {{{enumName}}} && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [{{{enumName}}}] to {{{dataType}}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Order {
petId: mapValueOfType<int>(json, r'petId'),
quantity: mapValueOfType<int>(json, r'quantity'),
shipDate: mapDateTime(json, r'shipDate', r''),

status: OrderStatusEnum.fromJson(json[r'status']),
complete: mapValueOfType<bool>(json, r'complete') ?? false,
);
Expand Down Expand Up @@ -224,6 +225,12 @@ class OrderStatusEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is OrderStatusEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OrderStatusEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Pet {
? (json[r'photoUrls'] as Iterable).cast<String>().toList(growable: false)
: const [],
tags: Tag.listFromJson(json[r'tags']),

status: PetStatusEnum.fromJson(json[r'status']),
);
}
Expand Down Expand Up @@ -208,6 +209,12 @@ class PetStatusEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is PetStatusEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [PetStatusEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ChildWithNullable {
}());

return ChildWithNullable(

type: ChildWithNullableTypeEnum.fromJson(json[r'type']),
nullableProperty: mapValueOfType<String>(json, r'nullableProperty'),
otherProperty: mapValueOfType<String>(json, r'otherProperty'),
Expand Down Expand Up @@ -172,6 +173,12 @@ class ChildWithNullableTypeEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is ChildWithNullableTypeEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [ChildWithNullableTypeEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class EnumArrays {
}());

return EnumArrays(

justSymbol: EnumArraysJustSymbolEnum.fromJson(json[r'just_symbol']),
arrayEnum: EnumArraysArrayEnumEnum.listFromJson(json[r'array_enum']),
);
Expand Down Expand Up @@ -153,6 +154,12 @@ class EnumArraysJustSymbolEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumArraysJustSymbolEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumArraysJustSymbolEnum] to String,
Expand Down Expand Up @@ -227,6 +234,12 @@ class EnumArraysArrayEnumEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumArraysArrayEnumEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumArraysArrayEnumEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class EnumClass {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is EnumClass && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumClass] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ class EnumTest {
}());

return EnumTest(

enumString: EnumTestEnumStringEnum.fromJson(json[r'enum_string']),

enumStringRequired: EnumTestEnumStringRequiredEnum.fromJson(json[r'enum_string_required'])!,

enumInteger: EnumTestEnumIntegerEnum.fromJson(json[r'enum_integer']),

enumNumber: EnumTestEnumNumberEnum.fromJson(json[r'enum_number']),
outerEnum: OuterEnum.fromJson(json[r'outerEnum']),
outerEnumInteger: OuterEnumInteger.fromJson(json[r'outerEnumInteger']),
Expand Down Expand Up @@ -240,6 +244,12 @@ class EnumTestEnumStringEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumTestEnumStringEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumTestEnumStringEnum] to String,
Expand Down Expand Up @@ -317,6 +327,12 @@ class EnumTestEnumStringRequiredEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumTestEnumStringRequiredEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumTestEnumStringRequiredEnum] to String,
Expand Down Expand Up @@ -392,6 +408,12 @@ class EnumTestEnumIntegerEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumTestEnumIntegerEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumTestEnumIntegerEnum] to int,
Expand Down Expand Up @@ -466,6 +488,12 @@ class EnumTestEnumNumberEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is EnumTestEnumNumberEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [EnumTestEnumNumberEnum] to double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ class MapTestMapOfEnumStringEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is MapTestMapOfEnumStringEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [MapTestMapOfEnumStringEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Order {
petId: mapValueOfType<int>(json, r'petId'),
quantity: mapValueOfType<int>(json, r'quantity'),
shipDate: mapDateTime(json, r'shipDate', r''),

status: OrderStatusEnum.fromJson(json[r'status']),
complete: mapValueOfType<bool>(json, r'complete') ?? false,
);
Expand Down Expand Up @@ -224,6 +225,12 @@ class OrderStatusEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is OrderStatusEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OrderStatusEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class OuterEnum {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is OuterEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OuterEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class OuterEnumDefaultValue {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is OuterEnumDefaultValue && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OuterEnumDefaultValue] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class OuterEnumInteger {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is OuterEnumInteger && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OuterEnumInteger] to int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class OuterEnumIntegerDefaultValue {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is OuterEnumIntegerDefaultValue && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [OuterEnumIntegerDefaultValue] to int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ParentWithNullable {
}());

return ParentWithNullable(

type: ParentWithNullableTypeEnum.fromJson(json[r'type']),
nullableProperty: mapValueOfType<String>(json, r'nullableProperty'),
);
Expand Down Expand Up @@ -155,6 +156,12 @@ class ParentWithNullableTypeEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is ParentWithNullableTypeEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [ParentWithNullableTypeEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class Pet {
? (json[r'photoUrls'] as Iterable).cast<String>().toSet()
: const {},
tags: Tag.listFromJson(json[r'tags']),

status: PetStatusEnum.fromJson(json[r'status']),
);
}
Expand Down Expand Up @@ -208,6 +209,12 @@ class PetStatusEnum {
}
return result.toList(growable: growable);
}

@override
bool operator ==(Object other) => identical(this, other) || other is PetStatusEnum && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [PetStatusEnum] to String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class SingleRefType {
}
return result.toList(growable: growable);
}


@override
bool operator ==(Object other) => identical(this, other) || other is SingleRefType && other.value == value;

@override
int get hashCode => value.hashCode;
}

/// Transformation class that can [encode] an instance of [SingleRefType] to String,
Expand Down