@devlearning/swagger-generator 1.1.20 → 1.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -47,16 +47,21 @@ export class ModelDartWriter {
|
|
|
47
47
|
var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
|
|
48
48
|
fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
|
|
49
49
|
const isFileField = property.typeName === 'File';
|
|
50
|
+
const isFileArrayField = isFileField && property.isArray;
|
|
50
51
|
const jsonKeyAnnotation = isFileField
|
|
51
52
|
? "@JsonKey(includeFromJson: false, includeToJson: false)"
|
|
52
53
|
: undefined;
|
|
54
|
+
const defaultAnnotation = isFileArrayField
|
|
55
|
+
? '@Default(<File>[])'
|
|
56
|
+
: undefined;
|
|
53
57
|
dartModel.fields.push({
|
|
54
58
|
name: property.name,
|
|
55
59
|
type: property.isArray ? `List<${fieldTypeName}>` : fieldTypeName,
|
|
56
60
|
typeName: property.typeName,
|
|
57
61
|
nullable: property.nullable && !property.isArray ? '?' : '',
|
|
58
|
-
required: property.nullable && !property.isArray ? '' : 'required ',
|
|
62
|
+
required: (property.nullable && !property.isArray) || isFileArrayField ? '' : 'required ',
|
|
59
63
|
jsonKeyAnnotation,
|
|
64
|
+
defaultAnnotation,
|
|
60
65
|
});
|
|
61
66
|
if (property.isTypeReference) {
|
|
62
67
|
if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
|
|
@@ -13,6 +13,9 @@ abstract class {{className}} with _${{className}} {
|
|
|
13
13
|
{{#jsonKeyAnnotation}}
|
|
14
14
|
{{{jsonKeyAnnotation}}}
|
|
15
15
|
{{/jsonKeyAnnotation}}
|
|
16
|
+
{{#defaultAnnotation}}
|
|
17
|
+
{{{defaultAnnotation}}}
|
|
18
|
+
{{/defaultAnnotation}}
|
|
16
19
|
{{required}}{{{type}}}{{nullable}} {{name}},
|
|
17
20
|
{{/fields}}
|
|
18
21
|
}) = _{{className}};
|
package/package.json
CHANGED
|
@@ -34,6 +34,7 @@ interface FieldDefinitionDart {
|
|
|
34
34
|
nullable: string;
|
|
35
35
|
required: string;
|
|
36
36
|
jsonKeyAnnotation?: string;
|
|
37
|
+
defaultAnnotation?: string;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
interface ExportClassDefinitionDart {
|
|
@@ -102,17 +103,23 @@ export class ModelDartWriter {
|
|
|
102
103
|
fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
|
|
103
104
|
|
|
104
105
|
const isFileField = property.typeName === 'File';
|
|
106
|
+
const isFileArrayField = isFileField && property.isArray;
|
|
105
107
|
const jsonKeyAnnotation = isFileField
|
|
106
108
|
? "@JsonKey(includeFromJson: false, includeToJson: false)"
|
|
107
109
|
: undefined;
|
|
108
110
|
|
|
111
|
+
const defaultAnnotation = isFileArrayField
|
|
112
|
+
? '@Default(<File>[])'
|
|
113
|
+
: undefined;
|
|
114
|
+
|
|
109
115
|
dartModel.fields!.push(<FieldDefinitionDart>{
|
|
110
116
|
name: property.name,
|
|
111
117
|
type: property.isArray ? `List<${fieldTypeName}>` : fieldTypeName,
|
|
112
118
|
typeName: property.typeName,
|
|
113
119
|
nullable: property.nullable && !property.isArray ? '?' : '',
|
|
114
|
-
required: property.nullable && !property.isArray ? '' : 'required ',
|
|
120
|
+
required: (property.nullable && !property.isArray) || isFileArrayField ? '' : 'required ',
|
|
115
121
|
jsonKeyAnnotation,
|
|
122
|
+
defaultAnnotation,
|
|
116
123
|
});
|
|
117
124
|
|
|
118
125
|
if (property.isTypeReference) {
|
|
@@ -13,6 +13,9 @@ abstract class {{className}} with _${{className}} {
|
|
|
13
13
|
{{#jsonKeyAnnotation}}
|
|
14
14
|
{{{jsonKeyAnnotation}}}
|
|
15
15
|
{{/jsonKeyAnnotation}}
|
|
16
|
+
{{#defaultAnnotation}}
|
|
17
|
+
{{{defaultAnnotation}}}
|
|
18
|
+
{{/defaultAnnotation}}
|
|
16
19
|
{{required}}{{{type}}}{{nullable}} {{name}},
|
|
17
20
|
{{/fields}}
|
|
18
21
|
}) = _{{className}};
|