@goast/kotlin 0.1.7 → 0.1.8
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.
|
@@ -149,7 +149,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
|
|
|
149
149
|
.append((builder) => this.generateDocumentation(ctx, builder, schema))
|
|
150
150
|
.append('data class ')
|
|
151
151
|
.append(this.getDeclarationTypeName(ctx, schema))
|
|
152
|
-
.parenthesizeIf(schema.properties.size > 0, '()', (builder) => builder.forEach(params, (builder, property) => this.generateObjectDataClassProperty(ctx, builder, schema, inheritedSchemas, property), { separator: ',\n' }), { multiline: true })
|
|
152
|
+
.parenthesizeIf(schema.properties.size > 0, '()', (builder) => builder.forEach(this.sortProperties(ctx, schema, params), (builder, property) => this.generateObjectDataClassProperty(ctx, builder, schema, inheritedSchemas, property), { separator: ',\n' }), { multiline: true })
|
|
153
153
|
.if(inheritedSchemas.length > 0, (builder) => builder
|
|
154
154
|
.append(' : ')
|
|
155
155
|
.forEach(inheritedSchemas, (builder, schema) => this.generateTypeUsage(ctx, builder, schema), {
|
|
@@ -441,11 +441,14 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
|
|
|
441
441
|
return result;
|
|
442
442
|
}
|
|
443
443
|
sortProperties(ctx, schema, properties) {
|
|
444
|
-
return [...properties].sort((a, b) =>
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
444
|
+
return [...properties].sort((a, b) => classify(a) - classify(b));
|
|
445
|
+
function classify(p) {
|
|
446
|
+
if (p.schema.default !== undefined)
|
|
447
|
+
return 1;
|
|
448
|
+
if (schema.required.has(p.name))
|
|
449
|
+
return 0;
|
|
450
|
+
return 2;
|
|
451
|
+
}
|
|
449
452
|
}
|
|
450
453
|
normalizeSchema(ctx, schema) {
|
|
451
454
|
if (schema.kind === 'oneOf') {
|
|
@@ -146,7 +146,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
|
|
|
146
146
|
.append((builder) => this.generateDocumentation(ctx, builder, schema))
|
|
147
147
|
.append('data class ')
|
|
148
148
|
.append(this.getDeclarationTypeName(ctx, schema))
|
|
149
|
-
.parenthesizeIf(schema.properties.size > 0, '()', (builder) => builder.forEach(params, (builder, property) => this.generateObjectDataClassProperty(ctx, builder, schema, inheritedSchemas, property), { separator: ',\n' }), { multiline: true })
|
|
149
|
+
.parenthesizeIf(schema.properties.size > 0, '()', (builder) => builder.forEach(this.sortProperties(ctx, schema, params), (builder, property) => this.generateObjectDataClassProperty(ctx, builder, schema, inheritedSchemas, property), { separator: ',\n' }), { multiline: true })
|
|
150
150
|
.if(inheritedSchemas.length > 0, (builder) => builder
|
|
151
151
|
.append(' : ')
|
|
152
152
|
.forEach(inheritedSchemas, (builder, schema) => this.generateTypeUsage(ctx, builder, schema), {
|
|
@@ -438,11 +438,14 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
|
|
|
438
438
|
return result;
|
|
439
439
|
}
|
|
440
440
|
sortProperties(ctx, schema, properties) {
|
|
441
|
-
return [...properties].sort((a, b) =>
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
return [...properties].sort((a, b) => classify(a) - classify(b));
|
|
442
|
+
function classify(p) {
|
|
443
|
+
if (p.schema.default !== undefined)
|
|
444
|
+
return 1;
|
|
445
|
+
if (schema.required.has(p.name))
|
|
446
|
+
return 0;
|
|
447
|
+
return 2;
|
|
448
|
+
}
|
|
446
449
|
}
|
|
447
450
|
normalizeSchema(ctx, schema) {
|
|
448
451
|
if (schema.kind === 'oneOf') {
|