@goast/kotlin 0.5.14 → 0.6.0-beta.2
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.
- package/esm/src/ast/references/jackson.d.ts +8 -0
- package/esm/src/ast/references/jackson.d.ts.map +1 -1
- package/esm/src/ast/references/jackson.js +8 -0
- package/esm/src/generators/file-generator.d.ts +21 -1
- package/esm/src/generators/file-generator.d.ts.map +1 -1
- package/esm/src/generators/file-generator.js +41 -2
- package/esm/src/generators/models/args.d.ts +5 -0
- package/esm/src/generators/models/args.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.d.ts +23 -0
- package/esm/src/generators/models/model-generator.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.js +117 -9
- package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +9 -0
- package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +14 -3
- package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
- package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +3 -1
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +11 -3
- package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts +3 -0
- package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -1
- package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +7 -0
- package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +18 -6
- package/esm/src/import-collection.d.ts.map +1 -1
- package/esm/src/import-collection.js +2 -2
- package/package.json +2 -2
- package/script/src/ast/references/jackson.d.ts +8 -0
- package/script/src/ast/references/jackson.d.ts.map +1 -1
- package/script/src/ast/references/jackson.js +9 -1
- package/script/src/generators/file-generator.d.ts +21 -1
- package/script/src/generators/file-generator.d.ts.map +1 -1
- package/script/src/generators/file-generator.js +41 -2
- package/script/src/generators/models/args.d.ts +5 -0
- package/script/src/generators/models/args.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.d.ts +23 -0
- package/script/src/generators/models/model-generator.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.js +117 -9
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +9 -0
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +14 -3
- package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +3 -1
- package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/spring-controller-generator.js +11 -3
- package/script/src/generators/services/spring-reactive-web-clients/args.d.ts +3 -0
- package/script/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -1
- package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +7 -0
- package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +18 -6
- package/script/src/import-collection.d.ts.map +1 -1
- package/script/src/import-collection.js +1 -1
- package/src/mod.ts +0 -8
- package/src/src/assets.ts +0 -9
- package/src/src/ast/_index.ts +0 -66
- package/src/src/ast/common.ts +0 -1
- package/src/src/ast/index.ts +0 -1
- package/src/src/ast/node.ts +0 -10
- package/src/src/ast/nodes/annotation.ts +0 -79
- package/src/src/ast/nodes/argument.ts +0 -62
- package/src/src/ast/nodes/call.ts +0 -75
- package/src/src/ast/nodes/class.ts +0 -178
- package/src/src/ast/nodes/collection-literal.ts +0 -49
- package/src/src/ast/nodes/constructor.ts +0 -126
- package/src/src/ast/nodes/doc-tag.ts +0 -138
- package/src/src/ast/nodes/doc.ts +0 -111
- package/src/src/ast/nodes/enum-value.ts +0 -100
- package/src/src/ast/nodes/enum.ts +0 -163
- package/src/src/ast/nodes/function.ts +0 -178
- package/src/src/ast/nodes/generic-parameter.ts +0 -54
- package/src/src/ast/nodes/init-block.ts +0 -38
- package/src/src/ast/nodes/interface.ts +0 -133
- package/src/src/ast/nodes/lambda-type.ts +0 -73
- package/src/src/ast/nodes/lambda.ts +0 -74
- package/src/src/ast/nodes/object.ts +0 -102
- package/src/src/ast/nodes/parameter.ts +0 -118
- package/src/src/ast/nodes/property.ts +0 -225
- package/src/src/ast/nodes/reference.ts +0 -178
- package/src/src/ast/nodes/string.ts +0 -114
- package/src/src/ast/nodes/types.ts +0 -23
- package/src/src/ast/references/index.ts +0 -10
- package/src/src/ast/references/jackson.ts +0 -59
- package/src/src/ast/references/jakarta.ts +0 -14
- package/src/src/ast/references/java.ts +0 -27
- package/src/src/ast/references/kotlin.ts +0 -41
- package/src/src/ast/references/kotlinx.ts +0 -14
- package/src/src/ast/references/okhttp3.ts +0 -5
- package/src/src/ast/references/reactor.ts +0 -5
- package/src/src/ast/references/spring-reactive.ts +0 -37
- package/src/src/ast/references/spring.ts +0 -86
- package/src/src/ast/references/swagger.ts +0 -23
- package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
- package/src/src/ast/utils/to-kt-node.ts +0 -31
- package/src/src/ast/utils/write-kt-annotations.ts +0 -15
- package/src/src/ast/utils/write-kt-arguments.ts +0 -45
- package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
- package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
- package/src/src/ast/utils/write-kt-members.ts +0 -25
- package/src/src/ast/utils/write-kt-node.ts +0 -37
- package/src/src/ast/utils/write-kt-parameters.ts +0 -25
- package/src/src/common-results.ts +0 -4
- package/src/src/config.ts +0 -61
- package/src/src/file-builder.ts +0 -112
- package/src/src/generators/file-generator.ts +0 -29
- package/src/src/generators/index.ts +0 -5
- package/src/src/generators/models/args.ts +0 -136
- package/src/src/generators/models/index.ts +0 -4
- package/src/src/generators/models/model-generator.ts +0 -736
- package/src/src/generators/models/models-generator.ts +0 -65
- package/src/src/generators/models/models.ts +0 -95
- package/src/src/generators/services/okhttp3-clients/args.ts +0 -90
- package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
- package/src/src/generators/services/okhttp3-clients/models.ts +0 -73
- package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -627
- package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -188
- package/src/src/generators/services/okhttp3-clients/refs.ts +0 -59
- package/src/src/generators/services/spring-controllers/args.ts +0 -95
- package/src/src/generators/services/spring-controllers/index.ts +0 -4
- package/src/src/generators/services/spring-controllers/models.ts +0 -76
- package/src/src/generators/services/spring-controllers/refs.ts +0 -17
- package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -1122
- package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -140
- package/src/src/generators/services/spring-reactive-web-clients/args.ts +0 -112
- package/src/src/generators/services/spring-reactive-web-clients/index.ts +0 -4
- package/src/src/generators/services/spring-reactive-web-clients/models.ts +0 -78
- package/src/src/generators/services/spring-reactive-web-clients/refs.ts +0 -11
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +0 -641
- package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +0 -125
- package/src/src/import-collection.ts +0 -98
- package/src/src/types.ts +0 -3
- package/src/src/utils.ts +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring-reactive-web-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY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B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,uBAAuB,GAAG,MAAM;IAK3F,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"spring-reactive-web-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iDAAiD,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EACV,6CAA6C,EAC7C,4CAA4C,EAC7C,MAAM,aAAa,CAAC;AAErB,KAAK,OAAO,GAAG,6CAA6C,CAAC;AAC7D,KAAK,MAAM,GAAG,4CAA4C,CAAC;AAC3D,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,sCAAsC,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACrF,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,6CAA8C,SAAQ,mBAAmB,CAAC,OAAO,EAAE,MAAM,CACpG,YAAW,sCAAsC;IAC1C,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAA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AC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,GAAG,MAAM;IAK3E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,MAAM;IAMnE,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,qBAAqB,GAAG,MAAM;IAIvF,OAAO,CAAC,kBAAkB;CAgB3B"}
|
|
@@ -42,11 +42,21 @@ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGen
|
|
|
42
42
|
const { endpoint } = args;
|
|
43
43
|
return toCasing(endpoint.name, ctx.config.functionNameCasing);
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The Kotlin `@Deprecated` annotation for a deprecated operation, or nothing for a supported one. Every
|
|
47
|
+
* function generated for the operation carries it, matching what the OkHttp3 client generator does for
|
|
48
|
+
* the same input — including the empty message, which is what `kotlin.Deprecated` requires as its first
|
|
49
|
+
* positional argument.
|
|
50
|
+
*/
|
|
51
|
+
getEndpointDeprecatedAnnotations(_ctx, args) {
|
|
52
|
+
return args.endpoint.deprecated ? [kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))])] : [];
|
|
53
|
+
}
|
|
45
54
|
getEndpointFunction(ctx, args) {
|
|
46
55
|
const { endpoint, parameters, responseSchema } = args;
|
|
47
56
|
const functionName = this.getEndpointFunctionName(ctx, { endpoint });
|
|
48
57
|
return kt.function(functionName, {
|
|
49
58
|
doc: kt.doc(this.getEndpointDocDescription(ctx, { endpoint })),
|
|
59
|
+
annotations: this.getEndpointDeprecatedAnnotations(ctx, { endpoint }),
|
|
50
60
|
suspend: true,
|
|
51
61
|
receiverType: kt.refs.springReactive.webClient(),
|
|
52
62
|
parameters: parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
|
|
@@ -82,11 +92,11 @@ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGen
|
|
|
82
92
|
const functionName = this.getEndpointFunctionName(ctx, { endpoint });
|
|
83
93
|
return kt.function(functionName, {
|
|
84
94
|
doc: kt.doc(this.getEndpointDocDescription(ctx, { endpoint })),
|
|
95
|
+
annotations: this.getEndpointDeprecatedAnnotations(ctx, { endpoint }),
|
|
85
96
|
suspend: true,
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
97
|
+
// `WebClient.awaitExchange` is `<V : Any>` on both Spring lines, so the `<T>` overload needs the bound
|
|
98
|
+
// unconditionally. Defect 28 scoped it to Spring Boot 4, leaving every Boot 3 unit uncompilable.
|
|
99
|
+
generics: [kt.genericParameter('T', { constraint: kt.refs.any() })],
|
|
90
100
|
receiverType: kt.refs.springReactive.webClient(),
|
|
91
101
|
parameters: [
|
|
92
102
|
...parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
|
|
@@ -116,6 +126,7 @@ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGen
|
|
|
116
126
|
const functionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
|
|
117
127
|
return kt.function(functionName, {
|
|
118
128
|
doc: kt.doc(this.getEndpointDocDescription(ctx, { endpoint })),
|
|
129
|
+
annotations: this.getEndpointDeprecatedAnnotations(ctx, { endpoint }),
|
|
119
130
|
receiverType: kt.refs.springReactive.webClient(),
|
|
120
131
|
parameters: parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
|
|
121
132
|
returnType: kt.refs.springReactive.requestHeadersSpec(['*']),
|
|
@@ -262,6 +273,7 @@ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGen
|
|
|
262
273
|
const { endpoint, parameters } = args;
|
|
263
274
|
const functionName = this.getEndpointUriFunctionName(ctx, { endpoint });
|
|
264
275
|
return kt.function(functionName, {
|
|
276
|
+
annotations: this.getEndpointDeprecatedAnnotations(ctx, { endpoint }),
|
|
265
277
|
parameters: parameters.filter((p) => p.target === 'path' || p.target === 'query').map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
|
|
266
278
|
returnType: kt.refs.string(),
|
|
267
279
|
body: this.getEndpointUriFunctionBody(ctx, { endpoint, parameters }),
|
|
@@ -314,12 +326,12 @@ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGen
|
|
|
314
326
|
return null;
|
|
315
327
|
}
|
|
316
328
|
if (getStringEnumSchema(schema) && (schema === null || schema === void 0 ? void 0 : schema.default)) {
|
|
317
|
-
return s `${this.getTypeUsage(ctx, { schema, nullable: false })}.${
|
|
329
|
+
return s `${this.getTypeUsage(ctx, { schema, nullable: false })}.${this.toEnumValueName(ctx, schema.enum, schema.default)}`;
|
|
318
330
|
}
|
|
319
331
|
const itemEnumSchema = getArrayItemStringEnumSchema(schema);
|
|
320
332
|
if (itemEnumSchema && Array.isArray(schema === null || schema === void 0 ? void 0 : schema.default)) {
|
|
321
333
|
const itemType = this.getTypeUsage(ctx, { schema: itemEnumSchema, nullable: false });
|
|
322
|
-
return kt.call(kt.refs.listOf.infer(), schema.default.map((x) => s `${itemType}.${
|
|
334
|
+
return kt.call(kt.refs.listOf.infer(), schema.default.map((x) => s `${itemType}.${this.toEnumValueName(ctx, itemEnumSchema.enum, x)}`));
|
|
323
335
|
}
|
|
324
336
|
return kt.toNode(schema === null || schema === void 0 ? void 0 : schema.default);
|
|
325
337
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,uBAE5C,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;IAChE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;gBAEvC,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM;IAI1D,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,IAAW,OAAO,IAAI,YAAY,EAAE,CASnC;IAEM,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IACvD,SAAS,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;IAiBxC,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI;IAMzC,KAAK,IAAI,IAAI;IAIb,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,MAAM;IAMzD,OAAO,CAAC,OAAO,EAAE,aAAa;CAuBtC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StringBuilder } from '@goast/core';
|
|
1
|
+
import { compareString, StringBuilder } from '@goast/core';
|
|
2
2
|
import { defaultKotlinGeneratorConfig } from './config.js';
|
|
3
3
|
export const defaultImportCollectionOptions = {
|
|
4
4
|
globalImports: defaultKotlinGeneratorConfig.globalImports,
|
|
@@ -75,7 +75,7 @@ export class ImportCollection {
|
|
|
75
75
|
else if (!isCoreImport(a) && isCoreImport(b)) {
|
|
76
76
|
return -1;
|
|
77
77
|
}
|
|
78
|
-
return a
|
|
78
|
+
return compareString(a, b);
|
|
79
79
|
})
|
|
80
80
|
.forEach((importPath) => builder.appendLine(`import ${importPath}`));
|
|
81
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/kotlin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-beta.2",
|
|
4
4
|
"description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
27
|
"http-status-codes": "^2.3.0",
|
|
28
|
-
"@goast/core": "0.
|
|
28
|
+
"@goast/core": "0.6.0-beta.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0"
|
|
@@ -13,6 +13,14 @@ export declare const jsonAnyGetter: KtReferenceFactory;
|
|
|
13
13
|
export declare const objectMapper: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
14
14
|
export declare const serializationFeature: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
15
15
|
export declare const deserializationFeature: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
16
|
+
/**
|
|
17
|
+
* `tools.jackson.databind.cfg.DateTimeFeature` — Jackson 3 only.
|
|
18
|
+
*
|
|
19
|
+
* Jackson 3 moved `WRITE_DATES_AS_TIMESTAMPS` off `SerializationFeature` onto this type. Unlike its
|
|
20
|
+
* neighbours it takes no `springBootVersion`, because Jackson 2 has no equivalent type: on the Spring Boot 3
|
|
21
|
+
* line the constant still lives on `SerializationFeature`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const dateTimeFeature: KtReferenceFactory;
|
|
16
24
|
export declare const jacksonObjectMapper: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
17
25
|
export declare const jacksonMapperBuilder: <TBuilder extends SourceBuilder>(springBootVersion?: SpringBootVersion) => KtReference<TBuilder>;
|
|
18
26
|
//# sourceMappingURL=jackson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jackson.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/jackson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAY/F,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,oBAAoB,EAAE,kBAGlC,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAA4F,CAAC;AACxH,eAAO,MAAM,uBAAuB,EAAE,kBAGrC,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAA2F,CAAC;AACtH,eAAO,MAAM,UAAU,EAAE,kBAA0F,CAAC;AACpH,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAGF,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,aAAa,sBACtC,iBAAiB,KACnC,WAAW,CAAC,QAAQ,CAAyF,CAAC;AACjH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,aAAa,sBAC9C,iBAAiB,KACnC,WAAW,CAAC,QAAQ,CACuE,CAAC;AAC/F,eAAO,MAAM,sBAAsB,GAAI,QAAQ,S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AACnG,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,aAAa,sBAC9C,iBAAiB,KACnC,WAAW,CAAC,QAAQ,CAC4E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jacksonMapperBuilder = exports.jacksonObjectMapper = exports.deserializationFeature = exports.serializationFeature = exports.objectMapper = exports.jsonAnyGetter = exports.jsonAnySetter = exports.jsonIgnore = exports.jsonInclude = exports.jsonPropertyDescription = exports.jsonProperty = exports.jsonClassDescription = exports.jsonSubTypes = exports.jsonTypeInfo = void 0;
|
|
3
|
+
exports.jacksonMapperBuilder = exports.jacksonObjectMapper = exports.dateTimeFeature = exports.deserializationFeature = exports.serializationFeature = exports.objectMapper = exports.jsonAnyGetter = exports.jsonAnySetter = exports.jsonIgnore = exports.jsonInclude = exports.jsonPropertyDescription = exports.jsonProperty = exports.jsonClassDescription = exports.jsonSubTypes = exports.jsonTypeInfo = void 0;
|
|
4
4
|
const reference_js_1 = require("../nodes/reference.js");
|
|
5
5
|
/**
|
|
6
6
|
* Resolves a Jackson package name for the targeted Spring Boot version.
|
|
@@ -26,6 +26,14 @@ const serializationFeature = (springBootVersion = 3) => (0, reference_js_1.ktRef
|
|
|
26
26
|
exports.serializationFeature = serializationFeature;
|
|
27
27
|
const deserializationFeature = (springBootVersion = 3) => (0, reference_js_1.ktReference)('DeserializationFeature', jacksonPackage('databind', springBootVersion));
|
|
28
28
|
exports.deserializationFeature = deserializationFeature;
|
|
29
|
+
/**
|
|
30
|
+
* `tools.jackson.databind.cfg.DateTimeFeature` — Jackson 3 only.
|
|
31
|
+
*
|
|
32
|
+
* Jackson 3 moved `WRITE_DATES_AS_TIMESTAMPS` off `SerializationFeature` onto this type. Unlike its
|
|
33
|
+
* neighbours it takes no `springBootVersion`, because Jackson 2 has no equivalent type: on the Spring Boot 3
|
|
34
|
+
* line the constant still lives on `SerializationFeature`.
|
|
35
|
+
*/
|
|
36
|
+
exports.dateTimeFeature = reference_js_1.ktReference.factory('DateTimeFeature', 'tools.jackson.databind.cfg');
|
|
29
37
|
// com.fasterxml.jackson.module.kotlin (Jackson 2) / tools.jackson.module.kotlin (Jackson 3, Spring Boot 4)
|
|
30
38
|
const jacksonObjectMapper = (springBootVersion = 3) => (0, reference_js_1.ktReference)('jacksonObjectMapper', jacksonPackage('module.kotlin', springBootVersion));
|
|
31
39
|
exports.jacksonObjectMapper = jacksonObjectMapper;
|
|
@@ -3,7 +3,27 @@ import type { KotlinGeneratorConfig } from '../config.js';
|
|
|
3
3
|
export declare abstract class KotlinFileGenerator<TContext extends OpenApiGenerationProviderContext<OpenApiGeneratorInput, KotlinGeneratorConfig>, TOutput> {
|
|
4
4
|
abstract generate(context: TContext): MaybePromise<TOutput>;
|
|
5
5
|
protected toPropertyName(context: TContext, name: string): string;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The Kotlin constant names for the values of an enum, index-aligned with `values`.
|
|
8
|
+
*
|
|
9
|
+
* `toCasing` cannot be relied on alone: `getWords` strips leading digits and every non-alphanumeric
|
|
10
|
+
* character, so a purely numeric value (`1`, `1.1`), the empty string, or a value written only in
|
|
11
|
+
* punctuation or non-ASCII letters all case to `''` — which renders as a nameless enum constant and an
|
|
12
|
+
* empty `when` branch, neither of which is valid Kotlin. Such a value gets an identifier derived from its
|
|
13
|
+
* raw text instead, always prefixed with `_`. That prefix cannot collide with anything `toCasing`
|
|
14
|
+
* produces, because `getWords` strips leading non-alphanumerics.
|
|
15
|
+
*
|
|
16
|
+
* Names are then de-duplicated in declaration order (`_2`, `_2_2`, `_2_3`, ...), so two distinct raw
|
|
17
|
+
* values — `2` and `'2'`, say — can never share one constant.
|
|
18
|
+
*/
|
|
19
|
+
protected toEnumValueNames(context: TContext, values: Nullable<readonly unknown[]>): string[];
|
|
20
|
+
/**
|
|
21
|
+
* The Kotlin constant name `value` is given among the enum's `values`, so that a reference to an enum
|
|
22
|
+
* constant always agrees with the constant `toEnumValueNames` declared for it. Values are matched by
|
|
23
|
+
* their string form, because that is what the generated enum stores. Falls back to the name `value`
|
|
24
|
+
* would get on its own if it is not among `values`.
|
|
25
|
+
*/
|
|
26
|
+
protected toEnumValueName(context: TContext, values: Nullable<readonly unknown[]>, value: unknown): string;
|
|
7
27
|
protected toStringLiteral(_context: TContext, text: Nullable<string>): string;
|
|
8
28
|
}
|
|
9
29
|
//# sourceMappingURL=file-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-generator.d.ts","sourceRoot":"","sources":["../../../src/src/generators/file-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAE3B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,8BAAsB,mBAAmB,CACvC,QAAQ,SAAS,gCAAgC,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,EAC/F,OAAO;aAES,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC;IAElE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIjE,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"file-generator.d.ts","sourceRoot":"","sources":["../../../src/src/generators/file-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAE3B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,8BAAsB,mBAAmB,CACvC,QAAQ,SAAS,gCAAgC,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,EAC/F,OAAO;aAES,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC;IAElE,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIjE;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,OAAO,EAAE,CAAC,GAAG,MAAM,EAAE;IAqB7F;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM;IAM1G,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM;CAG9E"}
|
|
@@ -7,8 +7,47 @@ class KotlinFileGenerator {
|
|
|
7
7
|
toPropertyName(context, name) {
|
|
8
8
|
return (0, utils_js_1.toKotlinPropertyName)((0, core_1.toCasing)(name, context.config.propertyNameCasing));
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The Kotlin constant names for the values of an enum, index-aligned with `values`.
|
|
12
|
+
*
|
|
13
|
+
* `toCasing` cannot be relied on alone: `getWords` strips leading digits and every non-alphanumeric
|
|
14
|
+
* character, so a purely numeric value (`1`, `1.1`), the empty string, or a value written only in
|
|
15
|
+
* punctuation or non-ASCII letters all case to `''` — which renders as a nameless enum constant and an
|
|
16
|
+
* empty `when` branch, neither of which is valid Kotlin. Such a value gets an identifier derived from its
|
|
17
|
+
* raw text instead, always prefixed with `_`. That prefix cannot collide with anything `toCasing`
|
|
18
|
+
* produces, because `getWords` strips leading non-alphanumerics.
|
|
19
|
+
*
|
|
20
|
+
* Names are then de-duplicated in declaration order (`_2`, `_2_2`, `_2_3`, ...), so two distinct raw
|
|
21
|
+
* values — `2` and `'2'`, say — can never share one constant.
|
|
22
|
+
*/
|
|
23
|
+
toEnumValueNames(context, values) {
|
|
24
|
+
const names = [];
|
|
25
|
+
const used = new Set();
|
|
26
|
+
for (const value of values !== null && values !== void 0 ? values : []) {
|
|
27
|
+
const raw = String(value);
|
|
28
|
+
let base = (0, core_1.toCasing)(raw, context.config.enumValueNameCasing);
|
|
29
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(base) || /^_+$/.test(base)) {
|
|
30
|
+
const sanitized = raw.replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '');
|
|
31
|
+
base = sanitized.length > 0 ? `_${sanitized}` : raw.length === 0 ? '_EMPTY' : '_VALUE';
|
|
32
|
+
}
|
|
33
|
+
let name = base;
|
|
34
|
+
for (let i = 2; used.has(name); i++)
|
|
35
|
+
name = `${base}_${i}`;
|
|
36
|
+
used.add(name);
|
|
37
|
+
names.push(name);
|
|
38
|
+
}
|
|
39
|
+
return names;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The Kotlin constant name `value` is given among the enum's `values`, so that a reference to an enum
|
|
43
|
+
* constant always agrees with the constant `toEnumValueNames` declared for it. Values are matched by
|
|
44
|
+
* their string form, because that is what the generated enum stores. Falls back to the name `value`
|
|
45
|
+
* would get on its own if it is not among `values`.
|
|
46
|
+
*/
|
|
47
|
+
toEnumValueName(context, values, value) {
|
|
48
|
+
const all = values !== null && values !== void 0 ? values : [];
|
|
49
|
+
const index = all.findIndex((x) => String(x) === String(value));
|
|
50
|
+
return index < 0 ? this.toEnumValueNames(context, [value])[0] : this.toEnumValueNames(context, all)[index];
|
|
12
51
|
}
|
|
13
52
|
toStringLiteral(_context, text) {
|
|
14
53
|
return (0, utils_js_1.toKotlinStringLiteral)(text);
|
|
@@ -99,8 +99,13 @@ export type SortProperties = {
|
|
|
99
99
|
export type NormalizeSchema = {
|
|
100
100
|
schema: ApiSchema;
|
|
101
101
|
};
|
|
102
|
+
export type NormalizeDiscriminatedBases = {
|
|
103
|
+
schema: ApiSchema;
|
|
104
|
+
};
|
|
102
105
|
export type HasProperty = {
|
|
103
106
|
schema: ApiSchema;
|
|
104
107
|
propertyName: string;
|
|
108
|
+
/** The schemas already inspected, so a composition that cycles back on itself terminates. */
|
|
109
|
+
visited?: Set<ApiSchema>;
|
|
105
110
|
};
|
|
106
111
|
//# sourceMappingURL=args.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe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B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;CAC1B,CAAC"}
|
|
@@ -44,6 +44,29 @@ export declare class DefaultKotlinModelGenerator extends KotlinFileGenerator<Con
|
|
|
44
44
|
protected getClassProperties(ctx: Context, args: Args.GetClassProperties): ApiSchemaProperty[];
|
|
45
45
|
protected sortProperties(_ctx: Context, args: Args.SortProperties): ApiSchemaProperty[];
|
|
46
46
|
protected normalizeSchema(ctx: Context, args: Args.NormalizeSchema): ApiSchema;
|
|
47
|
+
/**
|
|
48
|
+
* Rewrites every discriminated `oneOf` base reachable from the schema through a composition into the
|
|
49
|
+
* `object` it describes, so that the merge in `normalizeSchema` treats it as one.
|
|
50
|
+
*
|
|
51
|
+
* A schema that declares a `oneOf` is of kind `oneOf` even when it also declares `type: object` and
|
|
52
|
+
* properties of its own — `determineSchemaKind` looks at `oneOf` first. For a *discriminated* `oneOf` that
|
|
53
|
+
* loses the very information the Kotlin declarations need, because the branches of such a `oneOf` are the
|
|
54
|
+
* schema's subtypes rather than parts of it (the same distinction `resolveAnyOfAndAllOf` draws for a `oneOf`
|
|
55
|
+
* nested inside a composition):
|
|
56
|
+
*
|
|
57
|
+
* - the base is an object in its own right, described by its own `properties`, `required` and any
|
|
58
|
+
* `allOf`/`anyOf` it composes — so its interface must declare those and nothing else, not the union of
|
|
59
|
+
* what its subtypes declare;
|
|
60
|
+
* - a subtype's `allOf: [Base]` is a composition with that object — so the subtype must inherit the base's
|
|
61
|
+
* own properties, including the discriminator, while inheriting nothing from its siblings.
|
|
62
|
+
*
|
|
63
|
+
* Both follow from turning the base into an `object` before the merge runs: the merge already collects the
|
|
64
|
+
* properties of an `object` branch and already declines to collect the branches of a discriminated `oneOf`.
|
|
65
|
+
* This is why `AllOfInheritanceDiscriminator` in test/specs/v3/discriminator-variants.yml has always been
|
|
66
|
+
* correct — with no `oneOf` keyword it is of kind `object` already — while every `oneOf`-holder base in the
|
|
67
|
+
* same document was not.
|
|
68
|
+
*/
|
|
69
|
+
protected normalizeDiscriminatedBases(_ctx: Context, args: Args.NormalizeDiscriminatedBases): ApiSchema;
|
|
47
70
|
protected hasProperty(ctx: Context, args: Args.HasProperty): boolean;
|
|
48
71
|
}
|
|
49
72
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAMrB,KAAK,YAAY,EAKjB,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,+BAA+B,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE3F,KAAK,OAAO,GAAG,2BAA2B,CAAC;AAC3C,KAAK,MAAM,GAAG,0BAA0B,CAAC;AACzC,K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IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,2BAA2B,GAAG,SAAS;IAmEvG,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,OAAO;CAoBrE"}
|
|
@@ -86,7 +86,9 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
86
86
|
var _a, _b, _c;
|
|
87
87
|
const { schema } = args;
|
|
88
88
|
const name = this.getDeclarationTypeName(ctx, { schema });
|
|
89
|
-
|
|
89
|
+
// One set of names for both generation sites below, so the constant and its `when` branch agree.
|
|
90
|
+
const valueNames = this.toEnumValueNames(ctx, schema.enum);
|
|
91
|
+
return index_js_1.kt.enum(name, (_b = (_a = schema.enum) === null || _a === void 0 ? void 0 : _a.map((x, i) => index_js_1.kt.enumValue(valueNames[i], {
|
|
90
92
|
annotations: [index_js_1.kt.annotation(index_js_1.kt.refs.jackson.jsonProperty(), [index_js_1.kt.argument(index_js_1.kt.string(String(x)))])],
|
|
91
93
|
arguments: [index_js_1.kt.argument(index_js_1.kt.string(String(x)))],
|
|
92
94
|
}))) !== null && _b !== void 0 ? _b : [], {
|
|
@@ -104,7 +106,7 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
104
106
|
returnType: index_js_1.kt.reference(name, null, { nullable: true }),
|
|
105
107
|
singleExpression: true,
|
|
106
108
|
body: !((_c = schema.enum) === null || _c === void 0 ? void 0 : _c.length) ? 'null' : (0, core_1.builderTemplate) `\nwhen(value) {${core_1.builderTemplate.indent `${(0, core_1.appendValueGroup)([
|
|
107
|
-
schema.enum.map((x) => (0, core_1.builderTemplate) `\n${index_js_1.kt.string(String(x))} -> ${
|
|
109
|
+
schema.enum.map((x, i) => (0, core_1.builderTemplate) `\n${index_js_1.kt.string(String(x))} -> ${valueNames[i]}`),
|
|
108
110
|
])}
|
|
109
111
|
else -> null`}
|
|
110
112
|
}`,
|
|
@@ -213,7 +215,7 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
213
215
|
return String(schema.default);
|
|
214
216
|
case 'string':
|
|
215
217
|
return schema.enum && schema.enum.length > 0
|
|
216
|
-
? index_js_1.kt.call([this.getType(ctx, { schema }), (
|
|
218
|
+
? index_js_1.kt.call([this.getType(ctx, { schema }), this.toEnumValueName(ctx, schema.enum, schema.default)])
|
|
217
219
|
: index_js_1.kt.string(String(schema.default));
|
|
218
220
|
case 'array': {
|
|
219
221
|
const itemEnumSchema = (0, utils_js_1.getStringEnumSchema)(schema.items);
|
|
@@ -221,7 +223,7 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
221
223
|
? schema.default.map((x) => itemEnumSchema
|
|
222
224
|
? index_js_1.kt.call([
|
|
223
225
|
this.getType(ctx, { schema: itemEnumSchema }),
|
|
224
|
-
(
|
|
226
|
+
this.toEnumValueName(ctx, itemEnumSchema.enum, x),
|
|
225
227
|
])
|
|
226
228
|
: index_js_1.kt.toNode(x))
|
|
227
229
|
: []);
|
|
@@ -451,11 +453,19 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
451
453
|
if (schema.kind === 'combined' || schema.kind === 'oneOf') {
|
|
452
454
|
return false;
|
|
453
455
|
}
|
|
456
|
+
// A discriminated schema is the supertype its subtypes implement and the carrier of the
|
|
457
|
+
// `@JsonTypeInfo`/`@JsonSubTypes` pair, so it always needs a declaration of its own. The two rules below
|
|
458
|
+
// simplify a schema that nothing refers to as a type; degrading a polymorphic base to `Any` or to a `Map`
|
|
459
|
+
// instead drops the supertype from every subtype and the polymorphism with it. This matters for a base
|
|
460
|
+
// whose `discriminator.propertyName` is declared on the mapping targets rather than on the base, which is
|
|
461
|
+
// legal and leaves the base with no properties of its own.
|
|
462
|
+
const isDiscriminatedBase = schema.kind === 'object' && schema.discriminator !== undefined;
|
|
454
463
|
// Schemas representable by a simple Map type do not need its own type declaration
|
|
455
|
-
if (schema.kind === 'object' && schema.properties.size === 0 && schema.additionalProperties) {
|
|
464
|
+
if (!isDiscriminatedBase && schema.kind === 'object' && schema.properties.size === 0 && schema.additionalProperties) {
|
|
456
465
|
return false;
|
|
457
466
|
}
|
|
458
|
-
if (schema.kind === 'object' &&
|
|
467
|
+
if (!isDiscriminatedBase && schema.kind === 'object' &&
|
|
468
|
+
ctx.config.emptyObjectTypeBehavior === 'use-any' && schema.properties.size === 0) {
|
|
459
469
|
return false;
|
|
460
470
|
}
|
|
461
471
|
// Dynamically generated schemas do not have its own type declaration
|
|
@@ -511,6 +521,7 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
511
521
|
}
|
|
512
522
|
normalizeSchema(ctx, args) {
|
|
513
523
|
let { schema } = args;
|
|
524
|
+
schema = this.normalizeDiscriminatedBases(ctx, { schema });
|
|
514
525
|
if (schema.kind === 'oneOf') {
|
|
515
526
|
schema = ctx.config.oneOfBehavior === 'treat-as-any-of'
|
|
516
527
|
// deno-lint-ignore no-explicit-any
|
|
@@ -527,11 +538,108 @@ class DefaultKotlinModelGenerator extends file_generator_js_1.KotlinFileGenerato
|
|
|
527
538
|
}
|
|
528
539
|
return schema;
|
|
529
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Rewrites every discriminated `oneOf` base reachable from the schema through a composition into the
|
|
543
|
+
* `object` it describes, so that the merge in `normalizeSchema` treats it as one.
|
|
544
|
+
*
|
|
545
|
+
* A schema that declares a `oneOf` is of kind `oneOf` even when it also declares `type: object` and
|
|
546
|
+
* properties of its own — `determineSchemaKind` looks at `oneOf` first. For a *discriminated* `oneOf` that
|
|
547
|
+
* loses the very information the Kotlin declarations need, because the branches of such a `oneOf` are the
|
|
548
|
+
* schema's subtypes rather than parts of it (the same distinction `resolveAnyOfAndAllOf` draws for a `oneOf`
|
|
549
|
+
* nested inside a composition):
|
|
550
|
+
*
|
|
551
|
+
* - the base is an object in its own right, described by its own `properties`, `required` and any
|
|
552
|
+
* `allOf`/`anyOf` it composes — so its interface must declare those and nothing else, not the union of
|
|
553
|
+
* what its subtypes declare;
|
|
554
|
+
* - a subtype's `allOf: [Base]` is a composition with that object — so the subtype must inherit the base's
|
|
555
|
+
* own properties, including the discriminator, while inheriting nothing from its siblings.
|
|
556
|
+
*
|
|
557
|
+
* Both follow from turning the base into an `object` before the merge runs: the merge already collects the
|
|
558
|
+
* properties of an `object` branch and already declines to collect the branches of a discriminated `oneOf`.
|
|
559
|
+
* This is why `AllOfInheritanceDiscriminator` in test/specs/v3/discriminator-variants.yml has always been
|
|
560
|
+
* correct — with no `oneOf` keyword it is of kind `object` already — while every `oneOf`-holder base in the
|
|
561
|
+
* same document was not.
|
|
562
|
+
*/
|
|
563
|
+
normalizeDiscriminatedBases(_ctx, args) {
|
|
564
|
+
// `normalizeSchema` runs once per property type via `shouldGenerateTypeDeclaration`, and almost no schema
|
|
565
|
+
// has a discriminated base anywhere below it. Answering that first costs one traversal and one set, and
|
|
566
|
+
// lets the overwhelmingly common case return the schema itself rather than a copy per composing schema.
|
|
567
|
+
//
|
|
568
|
+
// The question is asked once for the whole call rather than again per branch: a per-branch answer would
|
|
569
|
+
// have to be memoised to stay linear, and memoising it is unsound, because a walk truncated by the cycle
|
|
570
|
+
// guard can record `false` for a branch that reaches a base only by going back through an ancestor.
|
|
571
|
+
if (!containsDiscriminatedBase(args.schema, new Set()))
|
|
572
|
+
return args.schema;
|
|
573
|
+
const rewritten = new Map();
|
|
574
|
+
return rewrite(args.schema);
|
|
575
|
+
function rewrite(schema) {
|
|
576
|
+
const existing = rewritten.get(schema);
|
|
577
|
+
if (existing)
|
|
578
|
+
return existing;
|
|
579
|
+
const isBase = isDiscriminatedBase(schema);
|
|
580
|
+
const allOf = branches(schema, 'allOf');
|
|
581
|
+
const anyOf = branches(schema, 'anyOf');
|
|
582
|
+
// The branches of a discriminated `oneOf` are dropped rather than descended into: they are the schema's
|
|
583
|
+
// subtypes, and a subtype is generated from its own file where it is the root of this walk.
|
|
584
|
+
const oneOf = isBase ? [] : branches(schema, 'oneOf');
|
|
585
|
+
if (!isBase && allOf.length === 0 && anyOf.length === 0 && oneOf.length === 0) {
|
|
586
|
+
return schema;
|
|
587
|
+
}
|
|
588
|
+
// Registered before descending, so a branch composing back to one of its own ancestors terminates.
|
|
589
|
+
// deno-lint-ignore no-explicit-any
|
|
590
|
+
const copy = { ...schema };
|
|
591
|
+
rewritten.set(schema, copy);
|
|
592
|
+
if (isBase) {
|
|
593
|
+
copy.kind = 'object';
|
|
594
|
+
copy.type = 'object';
|
|
595
|
+
}
|
|
596
|
+
copy.allOf = allOf.map(rewrite);
|
|
597
|
+
copy.anyOf = anyOf.map(rewrite);
|
|
598
|
+
copy.oneOf = oneOf.map(rewrite);
|
|
599
|
+
return copy;
|
|
600
|
+
}
|
|
601
|
+
/** Whether the schema or anything it composes is a base this walk would rewrite. */
|
|
602
|
+
function containsDiscriminatedBase(schema, visited) {
|
|
603
|
+
if (visited.has(schema))
|
|
604
|
+
return false;
|
|
605
|
+
visited.add(schema);
|
|
606
|
+
if (isDiscriminatedBase(schema))
|
|
607
|
+
return true;
|
|
608
|
+
const contains = (x) => containsDiscriminatedBase(x, visited);
|
|
609
|
+
return branches(schema, 'allOf').some(contains) ||
|
|
610
|
+
branches(schema, 'anyOf').some(contains) ||
|
|
611
|
+
branches(schema, 'oneOf').some(contains);
|
|
612
|
+
}
|
|
613
|
+
function isDiscriminatedBase(schema) {
|
|
614
|
+
return schema.kind === 'oneOf' && schema.discriminator !== undefined;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* The branches a schema composes under one keyword. `normalizeSchema` leaves an explicit
|
|
618
|
+
* `oneOf: undefined` behind when it rewrites a `oneOf` holder, so a keyword can be present with no value.
|
|
619
|
+
*/
|
|
620
|
+
function branches(schema, keyword) {
|
|
621
|
+
var _a;
|
|
622
|
+
const values = schema;
|
|
623
|
+
return (_a = values[keyword]) !== null && _a !== void 0 ? _a : [];
|
|
624
|
+
}
|
|
625
|
+
}
|
|
530
626
|
hasProperty(ctx, args) {
|
|
531
|
-
|
|
627
|
+
// A composition branch may compose back to one of its own ancestors (see test/specs/v3/anyof-cycle.yml).
|
|
628
|
+
// Without this guard such a cycle recurses until the stack overflows. Re-visiting a schema can never
|
|
629
|
+
// change the answer, so returning `false` for one is safe: another path either already found the
|
|
630
|
+
// property or does not contain it at all.
|
|
631
|
+
const { schema, propertyName, visited = new Set() } = args;
|
|
632
|
+
if (visited.has(schema))
|
|
633
|
+
return false;
|
|
634
|
+
visited.add(schema);
|
|
532
635
|
return (('properties' in schema && schema.properties.has(propertyName)) ||
|
|
533
|
-
('anyOf' in schema && schema.anyOf.some((schema) => this.hasProperty(ctx, { schema, propertyName }))) ||
|
|
534
|
-
('allOf' in schema && schema.allOf.some((schema) => this.hasProperty(ctx, { schema, propertyName })))
|
|
636
|
+
('anyOf' in schema && schema.anyOf.some((schema) => this.hasProperty(ctx, { schema, propertyName, visited }))) ||
|
|
637
|
+
('allOf' in schema && schema.allOf.some((schema) => this.hasProperty(ctx, { schema, propertyName, visited }))) ||
|
|
638
|
+
// Only an undiscriminated `oneOf` composes into the schema that references it, matching which `oneOf`
|
|
639
|
+
// branches `resolveAnyOfAndAllOf` merges. A discriminated one lists subtypes, whose properties are not
|
|
640
|
+
// the referencing schema's, so an inherited property never comes from there.
|
|
641
|
+
('oneOf' in schema && !schema.discriminator &&
|
|
642
|
+
schema.oneOf.some((schema) => this.hasProperty(ctx, { schema, propertyName, visited }))));
|
|
535
643
|
}
|
|
536
644
|
}
|
|
537
645
|
exports.DefaultKotlinModelGenerator = DefaultKotlinModelGenerator;
|
|
@@ -14,6 +14,15 @@ export interface KotlinOkHttp3Generator<TOutput extends Output = Output> {
|
|
|
14
14
|
export declare class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator<Context, Output> implements KotlinOkHttp3Generator {
|
|
15
15
|
generate(ctx: KotlinOkHttp3ClientGeneratorContext): MaybePromise<Output>;
|
|
16
16
|
protected getClientFileContent(ctx: Context, _args: Args.GetClientFileContent): AppendValueGroup<Builder>;
|
|
17
|
+
/**
|
|
18
|
+
* The `super(…)` arguments, in the base class's own parameter order.
|
|
19
|
+
*
|
|
20
|
+
* The base's order is chosen by `serializer`, at the `@API_CLIENT_PARAMETERS@` placeholder substitution in
|
|
21
|
+
* `okhttp3-clients-generator.ts`, and this list is positional, so the two must be derived from the same
|
|
22
|
+
* flag. Defect 27 was this list being a constant that matched only the `'parameter'` shape while every
|
|
23
|
+
* corpus profile uses the default `'static'`.
|
|
24
|
+
*/
|
|
25
|
+
protected getClientDelegateArguments(serializerAsParameter: boolean): string[];
|
|
17
26
|
protected getClientClass(ctx: Context, _args: Args.GetClientClass): kt.Class<Builder>;
|
|
18
27
|
protected getClientCompanionObject(ctx: Context, _args: Args.GetClientCompanionObject): kt.Object<Builder>;
|
|
19
28
|
protected getEndpointClientMembers(ctx: Context, args: Args.GetEndpointClientMembers): kt.ClassMember<Builder>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"okhttp3-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iCAAiC,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,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AAgB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,GAAG,MAAM;IAI9E,OAAO,CAAC,kBAAkB;CAgB3B"}
|
|
1
|
+
{"version":3,"file":"okhttp3-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iCAAiC,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,mCAAmC,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAE3G,KAAK,OAAO,GAAG,mCAAmC,CAAC;AACnD,KAAK,MAAM,GAAG,kCAAkC,CAAC;AACjD,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACrE,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,6BAA8B,SAAQ,mBAAmB,CAAC,OAAO,EAAE,MAAM,CACpF,YAAW,sBAAsB;IAC1B,QAAQ,CAAC,GAAG,EAAE,mCAAmC,GAAG,YAAY,CAAC,MAAM,CAAC;IAkB/E,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,oBAAoB,GAA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