@goast/kotlin 0.4.21 → 0.4.23
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/generators/services/okhttp3-clients/okhttp3-client-generator.js +1 -1
- package/esm/src/generators/services/spring-controllers/models.d.ts +1 -0
- package/esm/src/generators/services/spring-controllers/models.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/models.js +1 -0
- 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 +120 -41
- package/esm/src/generators/services/spring-controllers/spring-controllers-generator.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/spring-controllers-generator.js +4 -2
- package/package.json +1 -1
- package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +1 -1
- package/script/src/generators/services/spring-controllers/models.d.ts +1 -0
- package/script/src/generators/services/spring-controllers/models.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/models.js +1 -0
- 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 +120 -41
- package/script/src/generators/services/spring-controllers/spring-controllers-generator.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/spring-controllers-generator.js +4 -2
- package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +1 -1
- package/src/src/generators/services/spring-controllers/models.ts +6 -1
- package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +418 -151
- package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +37 -11
|
@@ -213,7 +213,7 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
|
|
|
213
213
|
${appendValueGroup(queryParameters.map((param) => {
|
|
214
214
|
const paramName = toCasing(param.name, ctx.config.parameterNameCasing);
|
|
215
215
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: param });
|
|
216
|
-
const put = s `put(${kt.string(
|
|
216
|
+
const put = s `put(${kt.string(param.name)}, listOf(${paramName}${toString}))`;
|
|
217
217
|
return param.required ? put : s `if (${paramName} != null) {${s.indent `
|
|
218
218
|
${put}`}
|
|
219
219
|
}`;
|
|
@@ -11,6 +11,7 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
|
|
|
11
11
|
addSwaggerAnnotations: boolean;
|
|
12
12
|
addJakartaValidationAnnotations: boolean;
|
|
13
13
|
arrayType: 'list' | 'flux';
|
|
14
|
+
suspendingFunctions: boolean;
|
|
14
15
|
strictResponseEntities: boolean;
|
|
15
16
|
defaultStatusCodes: number[];
|
|
16
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC;IAEjE,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAA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W,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GACtC,wCAAwC,CACxC,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,CAC7B,GACC;IACA,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEJ,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,GAAG;IAC3E,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,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,0CAA0C,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE/F,KAAK,OAAO,GAAG,6BAA6B,CAAC;AAC7C,KAAK,MAAM,GAAG,4BAA4B,CAAC;AAC3C,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,+BAA+B,
|
|
1
|
+
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,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C,cAAc,GAAG,MAAM;IAO1E,SAAS,CAAC,wBAAwB,CAChC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,wBAAwB,GAClC,MAAM;IAQT,SAAS,CAAC,mBAAmB,CAC3B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,mBAAmB,GAC9B,MAAM;IAIT,SAAS,CAAC,oBAAoB,CAC5B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,oBAAoB,GAC/B,MAAM;IAOT,SAAS,CAAC,2BAA2B,CACnC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,IAAI,CAAC,2BAA2B,GACtC,MAAM;IAOT,SAAS,CAAC,gBAAgB,CACxB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,gBAAgB,GAC1B,6BAA6B,EAAE;IA2DlC,OAAO,CAAC,kBAAkB;CAkB3B;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ1D"}
|
|
@@ -12,9 +12,18 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
12
12
|
fs.ensureDirSync(dirPath);
|
|
13
13
|
console.log(`Generating service ${ctx.service.id} to ${dirPath}...`);
|
|
14
14
|
return {
|
|
15
|
-
apiInterface: this.generateApiInterfaceFile(ctx, {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
apiInterface: this.generateApiInterfaceFile(ctx, {
|
|
16
|
+
dirPath,
|
|
17
|
+
packageName,
|
|
18
|
+
}),
|
|
19
|
+
apiController: this.generateApiControllerFile(ctx, {
|
|
20
|
+
dirPath,
|
|
21
|
+
packageName,
|
|
22
|
+
}),
|
|
23
|
+
apiDelegate: this.generateApiDelegateInterfaceFile(ctx, {
|
|
24
|
+
dirPath,
|
|
25
|
+
packageName,
|
|
26
|
+
}),
|
|
18
27
|
};
|
|
19
28
|
}
|
|
20
29
|
// #region API Interface
|
|
@@ -79,7 +88,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
79
88
|
const { endpoint } = args;
|
|
80
89
|
const parameters = this.getAllParameters(ctx, { endpoint });
|
|
81
90
|
return kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
82
|
-
suspend:
|
|
91
|
+
suspend: ctx.config.suspendingFunctions,
|
|
83
92
|
annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
|
|
84
93
|
parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
|
|
85
94
|
returnType: kt.refs.spring.responseEntity(['*']),
|
|
@@ -93,7 +102,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
93
102
|
annotations.push(kt.annotation(kt.refs.swagger.operation(), [
|
|
94
103
|
endpoint.summary ? kt.argument.named('summary', kt.string((_a = endpoint.summary) === null || _a === void 0 ? void 0 : _a.trim())) : null,
|
|
95
104
|
kt.argument.named('operationId', kt.string(endpoint.name)),
|
|
96
|
-
endpoint.description
|
|
105
|
+
endpoint.description
|
|
106
|
+
? kt.argument.named('description', kt.string((_b = endpoint.description) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
107
|
+
: null,
|
|
97
108
|
endpoint.deprecated !== undefined ? kt.argument.named('deprecated', kt.toNode(endpoint.deprecated)) : null,
|
|
98
109
|
]));
|
|
99
110
|
if (endpoint.responses.length > 0) {
|
|
@@ -109,7 +120,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
109
120
|
? [{ schema: undefined, type: undefined }]
|
|
110
121
|
: response.contentOptions).map((content) => {
|
|
111
122
|
var _a;
|
|
112
|
-
let schemaType = (_a = this.getSchemaType(ctx, {
|
|
123
|
+
let schemaType = (_a = this.getSchemaType(ctx, {
|
|
124
|
+
schema: content.schema,
|
|
125
|
+
})) !== null && _a !== void 0 ? _a : kt.refs.any();
|
|
113
126
|
let isArray = false;
|
|
114
127
|
if (kt.refs.list.matches(schemaType)) {
|
|
115
128
|
isArray = true;
|
|
@@ -124,8 +137,12 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
124
137
|
]);
|
|
125
138
|
}
|
|
126
139
|
return kt.call(kt.refs.swagger.content(), [
|
|
127
|
-
content.type
|
|
128
|
-
|
|
140
|
+
content.type
|
|
141
|
+
? kt.argument.named('mediaType', kt.string(content.type))
|
|
142
|
+
: null,
|
|
143
|
+
content.schema
|
|
144
|
+
? kt.argument.named(isArray ? 'array' : 'schema', ktSchema)
|
|
145
|
+
: null,
|
|
129
146
|
]);
|
|
130
147
|
}))),
|
|
131
148
|
]);
|
|
@@ -134,7 +151,12 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
const requestMapping = kt.annotation(kt.refs.spring.requestMapping(), [
|
|
137
|
-
kt.argument.named('method', kt.collectionLiteral([
|
|
154
|
+
kt.argument.named('method', kt.collectionLiteral([
|
|
155
|
+
kt.call([
|
|
156
|
+
kt.refs.spring.requestMethod(),
|
|
157
|
+
endpoint.method.toUpperCase(),
|
|
158
|
+
]),
|
|
159
|
+
])),
|
|
138
160
|
kt.argument.named('value', kt.collectionLiteral([this.getPathConstantName(ctx, { endpoint })])),
|
|
139
161
|
]);
|
|
140
162
|
if (endpoint.requestBody && endpoint.requestBody.content.length > 0) {
|
|
@@ -145,11 +167,17 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
145
167
|
}
|
|
146
168
|
getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter) {
|
|
147
169
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
148
|
-
const isEnumSchema = ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' &&
|
|
149
|
-
|
|
170
|
+
const isEnumSchema = ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' &&
|
|
171
|
+
((_b = parameter.schema.enum) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
172
|
+
this.getSchemaType(ctx, { schema: parameter.schema }) &&
|
|
173
|
+
!parameter.multipart;
|
|
150
174
|
const actualType = this.getSchemaType(ctx, { schema: parameter.schema });
|
|
151
175
|
const schemaType = isEnumSchema ? kt.refs.string({ nullable: actualType === null || actualType === void 0 ? void 0 : actualType.nullable }) : actualType;
|
|
152
|
-
const result = kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, {
|
|
176
|
+
const result = kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, {
|
|
177
|
+
endpoint,
|
|
178
|
+
parameter,
|
|
179
|
+
type: isEnumSchema ? schemaType : undefined,
|
|
180
|
+
}), {
|
|
153
181
|
default: parameter.multipart && ((_c = parameter.schema) === null || _c === void 0 ? void 0 : _c.default) !== undefined
|
|
154
182
|
? kt.toNode((_d = parameter.schema) === null || _d === void 0 ? void 0 : _d.default)
|
|
155
183
|
: null,
|
|
@@ -157,7 +185,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
157
185
|
if (ctx.config.addSwaggerAnnotations) {
|
|
158
186
|
const annotation = kt.annotation(kt.refs.swagger.parameter(), [
|
|
159
187
|
parameter.multipart ? kt.argument.named('name', kt.string(parameter.multipart.name)) : null,
|
|
160
|
-
parameter.description
|
|
188
|
+
parameter.description
|
|
189
|
+
? kt.argument.named('description', kt.string((_e = parameter.description) === null || _e === void 0 ? void 0 : _e.trim()))
|
|
190
|
+
: null,
|
|
161
191
|
kt.argument.named('required', parameter.required),
|
|
162
192
|
parameter.target === 'header' ? kt.argument.named('hidden', kt.toNode(true)) : null,
|
|
163
193
|
]);
|
|
@@ -173,7 +203,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
173
203
|
}
|
|
174
204
|
result.annotations.push(annotation);
|
|
175
205
|
}
|
|
176
|
-
const isCorePackage = !(schemaType === null || schemaType === void 0 ? void 0 : schemaType.packageName) ||
|
|
206
|
+
const isCorePackage = !(schemaType === null || schemaType === void 0 ? void 0 : schemaType.packageName) ||
|
|
207
|
+
/^(kotlin|java)(\..*|$)/.test(schemaType.packageName);
|
|
177
208
|
if (!isCorePackage && ctx.config.addJakartaValidationAnnotations) {
|
|
178
209
|
result.annotations.push(kt.annotation(kt.refs.jakarta.valid()));
|
|
179
210
|
}
|
|
@@ -191,10 +222,14 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
191
222
|
result.annotations.push(annotation);
|
|
192
223
|
}
|
|
193
224
|
if (parameter.target === 'path') {
|
|
194
|
-
result.annotations.push(kt.annotation(kt.refs.spring.pathVariable(), [
|
|
225
|
+
result.annotations.push(kt.annotation(kt.refs.spring.pathVariable(), [
|
|
226
|
+
kt.string(parameter.name),
|
|
227
|
+
]));
|
|
195
228
|
}
|
|
196
229
|
if (parameter.target === 'header') {
|
|
197
|
-
result.annotations.push(kt.annotation(kt.refs.spring.requestHeader(), [
|
|
230
|
+
result.annotations.push(kt.annotation(kt.refs.spring.requestHeader(), [
|
|
231
|
+
kt.string(parameter.name),
|
|
232
|
+
]));
|
|
198
233
|
}
|
|
199
234
|
if (parameter.multipart) {
|
|
200
235
|
result.annotations.push(kt.annotation(kt.refs.spring.requestPart(), [
|
|
@@ -209,15 +244,20 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
209
244
|
parameters.forEach((x) => {
|
|
210
245
|
var _a, _b;
|
|
211
246
|
const paramName = toCasing(x.name, ctx.config.parameterNameCasing);
|
|
212
|
-
if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' &&
|
|
247
|
+
if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' &&
|
|
248
|
+
((_b = x.schema.enum) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
249
|
+
!x.multipart) {
|
|
213
250
|
const type = this.getSchemaType(ctx, { schema: x.schema });
|
|
214
251
|
if (type) {
|
|
215
|
-
body.values.push(s `val ${paramName} = ${paramName}${type.nullable || !x.required && !x.schema.default ? '?' : ''}.let { ${type}.fromValue(it) ?: return ${kt.refs.spring.responseEntity.infer()}.status(${kt.refs.spring.httpStatus()}.BAD_REQUEST).body(${kt.string(`Invalid value for parameter ${x.name}`)}) }`);
|
|
252
|
+
body.values.push(s `val ${paramName} = ${paramName}${type.nullable || (!x.required && !x.schema.default) ? '?' : ''}.let { ${type}.fromValue(it) ?: return ${kt.refs.spring.responseEntity.infer()}.status(${kt.refs.spring.httpStatus()}.BAD_REQUEST).body(${kt.string(`Invalid value for parameter ${x.name}`)}) }`);
|
|
216
253
|
}
|
|
217
254
|
}
|
|
218
255
|
});
|
|
219
256
|
body.values.push(s `try {${s.indent `
|
|
220
|
-
return ${kt.call([
|
|
257
|
+
return ${kt.call([
|
|
258
|
+
kt.call(kt.reference('getDelegate'), []),
|
|
259
|
+
toCasing(endpoint.name, ctx.config.functionNameCasing),
|
|
260
|
+
], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`}
|
|
221
261
|
} catch (e: ${kt.refs.throwable()}) {${s.indent `
|
|
222
262
|
return getExceptionHandler()?.handleApiException(e) ?: throw e`}
|
|
223
263
|
}`);
|
|
@@ -232,11 +272,17 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
232
272
|
primaryConstructor: kt.constructor([
|
|
233
273
|
kt.parameter.class('body', kt.reference('T')),
|
|
234
274
|
kt.parameter.class('rawStatus', kt.refs.int()),
|
|
235
|
-
kt.parameter.class('headers', kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], {
|
|
275
|
+
kt.parameter.class('headers', kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], {
|
|
276
|
+
nullable: true,
|
|
277
|
+
}), { default: kt.toNode(null) }),
|
|
236
278
|
], null, {
|
|
237
279
|
accessModifier: endpoint.responses.length > 0 ? 'private' : null,
|
|
238
280
|
delegateTarget: 'super',
|
|
239
|
-
delegateArguments: [
|
|
281
|
+
delegateArguments: [
|
|
282
|
+
kt.argument('body'),
|
|
283
|
+
kt.argument('headers'),
|
|
284
|
+
kt.argument('rawStatus'),
|
|
285
|
+
],
|
|
240
286
|
}),
|
|
241
287
|
extends: kt.refs.spring.responseEntity([kt.reference('T')]),
|
|
242
288
|
companionObject: kt.object({
|
|
@@ -244,8 +290,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
244
290
|
...ctx.config.defaultStatusCodes,
|
|
245
291
|
501,
|
|
246
292
|
...endpoint.responses.map((x) => x.statusCode),
|
|
247
|
-
].filter(notNullish)))
|
|
248
|
-
.map((code) => {
|
|
293
|
+
].filter(notNullish))).map((code) => {
|
|
249
294
|
var _a;
|
|
250
295
|
const fnName = toCasing(getReasonPhrase(code), ctx.config.functionNameCasing);
|
|
251
296
|
const response = endpoint.responses.find((x) => x.statusCode === code);
|
|
@@ -260,7 +305,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
260
305
|
singleExpression: true,
|
|
261
306
|
body: kt.call([
|
|
262
307
|
kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, {
|
|
263
|
-
generics: [
|
|
308
|
+
generics: [
|
|
309
|
+
hasResponseBody ? responseType : kt.refs.unit({ nullable: true }),
|
|
310
|
+
],
|
|
264
311
|
}),
|
|
265
312
|
], [
|
|
266
313
|
hasResponseBody ? kt.argument('body') : kt.toNode(null),
|
|
@@ -301,11 +348,21 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
301
348
|
return kt.class(controllerName, {
|
|
302
349
|
annotations: this.getApiControllerAnnotations(ctx),
|
|
303
350
|
primaryConstructor: kt.constructor([
|
|
304
|
-
kt.parameter.class('delegate', kt.reference(this.getApiDelegateInterfaceName(ctx, {}), null, {
|
|
305
|
-
|
|
351
|
+
kt.parameter.class('delegate', kt.reference(this.getApiDelegateInterfaceName(ctx, {}), null, {
|
|
352
|
+
nullable: true,
|
|
353
|
+
}), {
|
|
354
|
+
annotations: [
|
|
355
|
+
kt.annotation(kt.refs.spring.autowired(), [
|
|
356
|
+
kt.argument.named('required', 'false'),
|
|
357
|
+
]),
|
|
358
|
+
],
|
|
306
359
|
}),
|
|
307
360
|
kt.parameter.class('exceptionHandler', ctx.refs.apiExceptionHandler({ nullable: true }), {
|
|
308
|
-
annotations: [
|
|
361
|
+
annotations: [
|
|
362
|
+
kt.annotation(kt.refs.spring.autowired(), [
|
|
363
|
+
kt.argument.named('required', 'false'),
|
|
364
|
+
]),
|
|
365
|
+
],
|
|
309
366
|
accessModifier: 'private',
|
|
310
367
|
property: 'readonly',
|
|
311
368
|
}),
|
|
@@ -318,11 +375,15 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
318
375
|
const annotations = [];
|
|
319
376
|
if (ctx.config.addJakartaValidationAnnotations) {
|
|
320
377
|
annotations.push(kt.annotation(kt.refs.jakarta.generated(), [
|
|
321
|
-
kt.argument.named('value', kt.collectionLiteral([
|
|
378
|
+
kt.argument.named('value', kt.collectionLiteral([
|
|
379
|
+
kt.string('com.goast.kotlin.spring-service-generator'),
|
|
380
|
+
])),
|
|
322
381
|
]));
|
|
323
382
|
}
|
|
324
383
|
annotations.push(kt.annotation(kt.refs.spring.controller()));
|
|
325
|
-
annotations.push(kt.annotation(kt.refs.spring.requestMapping(), [
|
|
384
|
+
annotations.push(kt.annotation(kt.refs.spring.requestMapping(), [
|
|
385
|
+
this.getControllerRequestMapping(ctx, {}),
|
|
386
|
+
]));
|
|
326
387
|
return annotations;
|
|
327
388
|
}
|
|
328
389
|
getApiControllerMembers(ctx) {
|
|
@@ -354,7 +415,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
354
415
|
const filePath = `${dirPath}/${fileName}`;
|
|
355
416
|
console.log(` Generating API delegate ${typeName} to ${fileName}...`);
|
|
356
417
|
const builder = new KotlinFileBuilder(packageName, ctx.config);
|
|
357
|
-
builder.append(this.getApiDelegateInterfaceFileContent(ctx, {
|
|
418
|
+
builder.append(this.getApiDelegateInterfaceFileContent(ctx, {
|
|
419
|
+
delegateInterfaceName: typeName,
|
|
420
|
+
}));
|
|
358
421
|
fs.writeFileSync(filePath, builder.toString());
|
|
359
422
|
return { typeName, packageName };
|
|
360
423
|
}
|
|
@@ -373,7 +436,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
373
436
|
const annotations = [];
|
|
374
437
|
if (ctx.config.addJakartaValidationAnnotations) {
|
|
375
438
|
annotations.push(kt.annotation(kt.refs.jakarta.generated(), [
|
|
376
|
-
kt.argument.named('value', kt.collectionLiteral([
|
|
439
|
+
kt.argument.named('value', kt.collectionLiteral([
|
|
440
|
+
kt.string('com.goast.kotlin.spring-service-generator'),
|
|
441
|
+
])),
|
|
377
442
|
]));
|
|
378
443
|
}
|
|
379
444
|
return annotations;
|
|
@@ -394,7 +459,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
394
459
|
const { endpoint } = args;
|
|
395
460
|
const parameters = this.getAllParameters(ctx, { endpoint });
|
|
396
461
|
const fn = kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
397
|
-
suspend:
|
|
462
|
+
suspend: ctx.config.suspendingFunctions,
|
|
398
463
|
parameters: parameters.map((parameter) => {
|
|
399
464
|
return kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }));
|
|
400
465
|
}),
|
|
@@ -402,14 +467,20 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
402
467
|
if (ctx.config.strictResponseEntities) {
|
|
403
468
|
const responseEntity = kt.reference.genericFactory(this.getApiResponseEntityName(ctx, { endpoint }), `${this.getPackageName(ctx, {})}.${this.getApiInterfaceName(ctx, {})}`);
|
|
404
469
|
fn.returnType = responseEntity(['*']);
|
|
405
|
-
fn.body = appendValueGroup([
|
|
470
|
+
fn.body = appendValueGroup([
|
|
471
|
+
s `return ${kt.call([
|
|
406
472
|
responseEntity.infer(),
|
|
407
473
|
toCasing(getReasonPhrase(501), ctx.config.functionNameCasing),
|
|
408
|
-
], [])}
|
|
474
|
+
], [])}`,
|
|
475
|
+
], '\n');
|
|
409
476
|
}
|
|
410
477
|
else {
|
|
411
|
-
fn.returnType = kt.refs.spring.responseEntity([
|
|
412
|
-
|
|
478
|
+
fn.returnType = kt.refs.spring.responseEntity([
|
|
479
|
+
this.getResponseType(ctx, { endpoint }),
|
|
480
|
+
]);
|
|
481
|
+
fn.body = appendValueGroup([
|
|
482
|
+
s `return ${kt.refs.spring.responseEntity.infer()}(${kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`,
|
|
483
|
+
], '\n');
|
|
413
484
|
}
|
|
414
485
|
return fn;
|
|
415
486
|
}
|
|
@@ -422,7 +493,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
422
493
|
}
|
|
423
494
|
const type = this.getTypeUsage(ctx, {
|
|
424
495
|
schema: parameter.schema,
|
|
425
|
-
nullable: (!parameter.required && ((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default) === undefined) ||
|
|
496
|
+
nullable: (!parameter.required && ((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default) === undefined) ||
|
|
497
|
+
undefined,
|
|
426
498
|
type: args.type,
|
|
427
499
|
});
|
|
428
500
|
return parameter.target === 'body' ? adjustListType(ctx, type) : type;
|
|
@@ -435,10 +507,14 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
435
507
|
.filter((x, i, a) => a.findIndex((y) => {
|
|
436
508
|
const xType = this.getSchemaType(ctx, { schema: x });
|
|
437
509
|
const yType = this.getSchemaType(ctx, { schema: y });
|
|
438
|
-
return (xType === null || xType === void 0 ? void 0 : xType.name) === (yType === null || yType === void 0 ? void 0 : yType.name) &&
|
|
510
|
+
return ((xType === null || xType === void 0 ? void 0 : xType.name) === (yType === null || yType === void 0 ? void 0 : yType.name) &&
|
|
511
|
+
(xType === null || xType === void 0 ? void 0 : xType.packageName) === (yType === null || yType === void 0 ? void 0 : yType.packageName));
|
|
439
512
|
}) === i);
|
|
440
513
|
if (responseSchemas.length === 1) {
|
|
441
|
-
return adjustListType(ctx, this.getTypeUsage(ctx, {
|
|
514
|
+
return adjustListType(ctx, this.getTypeUsage(ctx, {
|
|
515
|
+
schema: responseSchemas[0],
|
|
516
|
+
fallback: kt.refs.unit(),
|
|
517
|
+
}));
|
|
442
518
|
}
|
|
443
519
|
else if (responseSchemas.length === 0) {
|
|
444
520
|
return kt.refs.unit();
|
|
@@ -503,7 +579,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
503
579
|
getAllParameters(ctx, args) {
|
|
504
580
|
var _a, _b;
|
|
505
581
|
const { endpoint } = args;
|
|
506
|
-
const parameters = endpoint.parameters.filter((parameter) => parameter.target === 'query' ||
|
|
582
|
+
const parameters = endpoint.parameters.filter((parameter) => parameter.target === 'query' ||
|
|
583
|
+
parameter.target === 'path' ||
|
|
584
|
+
parameter.target === 'header');
|
|
507
585
|
if (endpoint.requestBody) {
|
|
508
586
|
const content = endpoint.requestBody.content[0];
|
|
509
587
|
let schema = content.schema;
|
|
@@ -522,7 +600,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
522
600
|
}), {
|
|
523
601
|
multipart: {
|
|
524
602
|
name,
|
|
525
|
-
isFile: property.schema.kind === 'string' &&
|
|
603
|
+
isFile: property.schema.kind === 'string' &&
|
|
604
|
+
property.schema.format === 'binary',
|
|
526
605
|
},
|
|
527
606
|
}));
|
|
528
607
|
}
|
package/esm/src/generators/services/spring-controllers/spring-controllers-generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,kCAAkC,CAAC;AAE1C,KAAK,KAAK,GAAG,4BAA4B,CAAC;AAC1C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,aAAa,GAAG,4BAA4B,CAAC;AAClD,KAAK,OAAO,GAAG,8BAA8B,CAAC;AAE9C,qBAAa,gCAAiC,SAAQ,qCAAqC,CACzF,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,O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AAG,EAAE,OAAO,GACX,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC;CAkBnC"}
|
|
@@ -61,8 +61,10 @@ export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationP
|
|
|
61
61
|
return kt.interface(ctx.refs.apiExceptionHandler.refName, {
|
|
62
62
|
members: [
|
|
63
63
|
kt.function('handleApiException', {
|
|
64
|
-
doc: kt.doc('Handler for API exceptions.', [
|
|
65
|
-
|
|
64
|
+
doc: kt.doc('Handler for API exceptions.', [
|
|
65
|
+
kt.docTag('return', 'Response entity.'),
|
|
66
|
+
]),
|
|
67
|
+
suspend: ctx.config.suspendingFunctions,
|
|
66
68
|
parameters: [
|
|
67
69
|
kt.parameter('exception', kt.refs.throwable(), {
|
|
68
70
|
description: 'Exception that has been thrown by the API.',
|
package/package.json
CHANGED
|
@@ -217,7 +217,7 @@ class DefaultKotlinOkHttp3Generator extends file_generator_js_1.KotlinFileGenera
|
|
|
217
217
|
${(0, core_1.appendValueGroup)(queryParameters.map((param) => {
|
|
218
218
|
const paramName = (0, core_1.toCasing)(param.name, ctx.config.parameterNameCasing);
|
|
219
219
|
const toString = this.getParameterToString(ctx, { endpoint, parameter: param });
|
|
220
|
-
const put = (0, core_1.builderTemplate) `put(${index_js_1.kt.string(
|
|
220
|
+
const put = (0, core_1.builderTemplate) `put(${index_js_1.kt.string(param.name)}, listOf(${paramName}${toString}))`;
|
|
221
221
|
return param.required ? put : (0, core_1.builderTemplate) `if (${paramName} != null) {${core_1.builderTemplate.indent `
|
|
222
222
|
${put}`}
|
|
223
223
|
}`;
|
|
@@ -11,6 +11,7 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
|
|
|
11
11
|
addSwaggerAnnotations: boolean;
|
|
12
12
|
addJakartaValidationAnnotations: boolean;
|
|
13
13
|
arrayType: 'list' | 'flux';
|
|
14
|
+
suspendingFunctions: boolean;
|
|
14
15
|
strictResponseEntities: boolean;
|
|
15
16
|
defaultStatusCodes: number[];
|
|
16
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC;IAEjE,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,KAAK,MAAM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@
|
|
|
1
|
-
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,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,0CAA0C,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE/F,KAAK,OAAO,GAAG,6BAA6B,CAAC;AAC7C,KAAK,MAAM,GAAG,4BAA4B,CAAC;AAC3C,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,+BAA+B,
|
|
1
|
+
{"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAA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