@goast/kotlin 0.4.7-beta1 → 0.4.7-beta2
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/spring.d.ts +1 -0
- package/esm/src/ast/references/spring.d.ts.map +1 -1
- package/esm/src/ast/references/spring.js +2 -0
- package/esm/src/generators/services/spring-controllers/args.d.ts +17 -2
- package/esm/src/generators/services/spring-controllers/args.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/models.d.ts +2 -1
- package/esm/src/generators/services/spring-controllers/models.d.ts.map +1 -1
- package/esm/src/generators/services/spring-controllers/models.js +2 -1
- package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts +4 -2
- 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 +78 -17
- package/package.json +2 -1
- package/script/src/ast/references/spring.d.ts +1 -0
- package/script/src/ast/references/spring.d.ts.map +1 -1
- package/script/src/ast/references/spring.js +3 -1
- package/script/src/generators/services/spring-controllers/args.d.ts +17 -2
- package/script/src/generators/services/spring-controllers/args.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/models.d.ts +2 -1
- package/script/src/generators/services/spring-controllers/models.d.ts.map +1 -1
- package/script/src/generators/services/spring-controllers/models.js +2 -1
- package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts +4 -2
- 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 +79 -18
|
@@ -4,6 +4,7 @@ export declare const httpStatus: KtReferenceFactory;
|
|
|
4
4
|
export declare const responseEntity: KtGenericReferenceFactory<1>;
|
|
5
5
|
export declare const filePart: KtReferenceFactory;
|
|
6
6
|
export declare const controller: KtReferenceFactory;
|
|
7
|
+
export declare const multiValueMap: KtGenericReferenceFactory<2>;
|
|
7
8
|
export declare const validated: KtReferenceFactory;
|
|
8
9
|
export declare const pathVariable: KtReferenceFactory;
|
|
9
10
|
export declare const requestBody: KtReferenceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/spring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,kBAAkF,CAAC;AAC5G,eAAO,MAAM,cAAc,EAAE,yBAAyB,CAAC,CAAC,CAGvD,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,kBAAgG,CAAC;AAGxH,eAAO,MAAM,UAAU,EAAE,kBAAwF,CAAC;AAGlH,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,kBAG5B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/spring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,kBAAkF,CAAC;AAC5G,eAAO,MAAM,cAAc,EAAE,yBAAyB,CAAC,CAAC,CAGvD,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,kBAAgG,CAAC;AAGxH,eAAO,MAAM,UAAU,EAAE,kBAAwF,CAAC;AAGlH,eAAO,MAAM,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAGtD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,kBAG5B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC"}
|
|
@@ -8,6 +8,8 @@ export const responseEntity = ktReference.genericFactory('ResponseEntity', 'org.
|
|
|
8
8
|
export const filePart = ktReference.factory('FilePart', 'org.springframework.http.codec.multipart');
|
|
9
9
|
// org.springframework.stereotype
|
|
10
10
|
export const controller = ktReference.factory('Controller', 'org.springframework.stereotype');
|
|
11
|
+
// org.springframework.util
|
|
12
|
+
export const multiValueMap = ktReference.genericFactory('MultiValueMap', 'org.springframework.util');
|
|
11
13
|
// org.springframework.validation.annotation
|
|
12
14
|
export const validated = ktReference.factory('Validated', 'org.springframework.validation.annotation');
|
|
13
15
|
// org.springframework.web.bind.annotation
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type { ApiEndpoint, ApiSchema, SourceBuilder } from '@goast/core';
|
|
1
|
+
import type { ApiEndpoint, ApiResponse, ApiSchema, SourceBuilder } from '@goast/core';
|
|
2
2
|
import type { kt } from '../../../ast/index.js';
|
|
3
3
|
import type { ApiParameterWithMultipartInfo } from '../../../types.js';
|
|
4
|
+
export type GenerateApiResponseEntitiesFile = {
|
|
5
|
+
dirPath: string;
|
|
6
|
+
packageName: string;
|
|
7
|
+
};
|
|
8
|
+
export type GetApiResponseEntitiesFileContent = {
|
|
9
|
+
packageName: string;
|
|
10
|
+
};
|
|
11
|
+
export type GetApiResponseEntities = object;
|
|
4
12
|
export type GenerateApiInterfaceFile = {
|
|
5
13
|
dirPath: string;
|
|
6
14
|
packageName: string;
|
|
7
15
|
};
|
|
8
|
-
export type
|
|
16
|
+
export type GetApiInterfaceFileContent = {
|
|
9
17
|
interfaceName: string;
|
|
10
18
|
};
|
|
11
19
|
export type GetApiInterface = {
|
|
@@ -14,6 +22,9 @@ export type GetApiInterface = {
|
|
|
14
22
|
export type GetApiInterfaceEndpointMethod = {
|
|
15
23
|
endpoint: ApiEndpoint;
|
|
16
24
|
};
|
|
25
|
+
export type GetApiResponseEntityClass = {
|
|
26
|
+
endpoint: ApiEndpoint;
|
|
27
|
+
};
|
|
17
28
|
export type GenerateApiControllerFile = {
|
|
18
29
|
dirPath: string;
|
|
19
30
|
packageName: string;
|
|
@@ -43,6 +54,7 @@ export type GetParameterType = {
|
|
|
43
54
|
};
|
|
44
55
|
export type GetResponseType = {
|
|
45
56
|
endpoint: ApiEndpoint;
|
|
57
|
+
response?: ApiResponse;
|
|
46
58
|
};
|
|
47
59
|
export type GetTypeUsage<TBuilder extends SourceBuilder> = {
|
|
48
60
|
schema: ApiSchema | undefined;
|
|
@@ -66,6 +78,9 @@ export type GetPathConstantName = {
|
|
|
66
78
|
endpoint: ApiEndpoint;
|
|
67
79
|
};
|
|
68
80
|
export type GetPackageName = object;
|
|
81
|
+
export type GetApiResponseEntityName = {
|
|
82
|
+
endpoint: ApiEndpoint;
|
|
83
|
+
};
|
|
69
84
|
export type GetApiInterfaceName = object;
|
|
70
85
|
export type GetApiDelegateInterfaceName = object;
|
|
71
86
|
export type GetApiControllerName = object;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3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AE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC"}
|
|
@@ -9,7 +9,8 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
|
|
|
9
9
|
pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
|
|
10
10
|
addSwaggerAnnotations: boolean;
|
|
11
11
|
addJakartaValidationAnnotations: boolean;
|
|
12
|
-
|
|
12
|
+
strictResponseEntities: boolean;
|
|
13
|
+
defaultStatusCodes: number[];
|
|
13
14
|
};
|
|
14
15
|
export declare const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConfig<KotlinServicesGeneratorConfig>;
|
|
15
16
|
export type KotlinServicesGeneratorInput = KotlinModelsGeneratorOutput;
|
|
@@ -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;AAEzE,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IAE1D,QAAQ,CAAC,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AAM,oCAAoC,EAAE,+BAA+B,CAAC,6BAA6B,CAW/G,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AAEvE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE;QACN,QAAQ,EAAE;YACR,CAAC,SAAS,EAAE,MAAM,GAAG,4BAA4B,CAAC;SACnD,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,YAAY,CAAC;IAC5B,WAAW,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,wCAAwC,CACnF,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,CAC7B,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,GAAG;IAC3E,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
|
|
@@ -15,7 +15,7 @@ export interface KotlinSpringControllerGenerator<TOutput extends Output = Output
|
|
|
15
15
|
export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<Context, Output> implements KotlinSpringControllerGenerator {
|
|
16
16
|
generate(ctx: KotlinServiceGeneratorContext): MaybePromise<KotlinServiceGeneratorOutput>;
|
|
17
17
|
protected generateApiInterfaceFile(ctx: Context, args: Args.GenerateApiInterfaceFile): KotlinImport;
|
|
18
|
-
protected getApiInterfaceFileContent(ctx: Context, args: Args.
|
|
18
|
+
protected getApiInterfaceFileContent(ctx: Context, args: Args.GetApiInterfaceFileContent): AppendValueGroup<Builder>;
|
|
19
19
|
protected getApiInterface(ctx: Context, args: Args.GetApiInterface): kt.Interface<Builder>;
|
|
20
20
|
private getApiInterfaceAnnotations;
|
|
21
21
|
private getApiInterfaceMembers;
|
|
@@ -23,6 +23,7 @@ export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGe
|
|
|
23
23
|
private getApiInterfaceEndpointMethodAnnnotations;
|
|
24
24
|
private getApiInterfaceEndpointMethodParameter;
|
|
25
25
|
private getApiInterfaceEndpointMethodBody;
|
|
26
|
+
private getApiResponseEntityClass;
|
|
26
27
|
protected generateApiControllerFile(ctx: Context, args: Args.GenerateApiControllerFile): KotlinImport;
|
|
27
28
|
protected getApiControllerFileContent(ctx: Context, args: Args.GetApiControllerFileContent): AppendValueGroup<Builder>;
|
|
28
29
|
protected getApiController(ctx: Context, args: Args.GetApiController): kt.Class<Builder>;
|
|
@@ -44,12 +45,13 @@ export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGe
|
|
|
44
45
|
protected getDirectoryPath(ctx: Context, args: Args.GetDirectoryPath): string;
|
|
45
46
|
protected getPathConstantName(ctx: Context, args: Args.GetPathConstantName): string;
|
|
46
47
|
protected getPackageName(ctx: Context, _args: Args.GetPackageName): string;
|
|
48
|
+
protected getApiResponseEntityName(ctx: Context, args: Args.GetApiResponseEntityName): string;
|
|
47
49
|
protected getApiInterfaceName(ctx: Context, _args: Args.GetApiInterfaceName): string;
|
|
48
50
|
protected getApiControllerName(ctx: Context, _args: Args.GetApiControllerName): string;
|
|
49
51
|
protected getApiDelegateInterfaceName(ctx: Context, _args: Args.GetApiDelegateInterfaceName): string;
|
|
50
52
|
protected getAllParameters(ctx: Context, args: Args.GetAllParameters): ApiParameterWithMultipartInfo[];
|
|
51
53
|
private createApiParameter;
|
|
52
54
|
}
|
|
53
|
-
export declare function
|
|
55
|
+
export declare function listToFlux<T>(type: T): T;
|
|
54
56
|
export {};
|
|
55
57
|
//# sourceMappingURL=spring-controller-generator.d.ts.map
|
|
@@ -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;
|
|
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,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC9E,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,sCAAuC,SAAQ,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,+BAA+B;IACnC,QAAQ,CAAC,GAAG,EAAE,6BAA6B,GAAG,YAAY,CAAC,4BAA4B,CAAC;IAc/F,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,wBAAwB,GAAG,YAAY;IAcnG,SAAS,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,0BAA0B,GAAG,gBAAgB,CA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AAI,CAAC,mBAAmB,GAAG,MAAM;IAKnF,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,GAAG,MAAM;IAO1E,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,wBAAwB,GAAG,MAAM;IAK7F,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM;IAIpF,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,oBAAoB,GAAG,MAAM;IAItF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,2BAA2B,GAAG,MAAM;IAIpG,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,GAAG,6BAA6B,EAAE;IAuDtG,OAAO,CAAC,kBAAkB;CAgB3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAExC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { appendValueGroup, builderTemplate as s, createOverwriteProxy, notNullish, resolveAnyOfAndAllOf, SourceBuilder, toCasing, } from '@goast/core';
|
|
3
|
+
import { getReasonPhrase } from 'http-status-codes';
|
|
3
4
|
import { kt } from '../../../ast/index.js';
|
|
4
5
|
import { KotlinFileBuilder } from '../../../file-builder.js';
|
|
5
6
|
import { modifyString } from '../../../utils.js';
|
|
@@ -65,6 +66,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
65
66
|
ctx.service.endpoints.forEach((endpoint) => {
|
|
66
67
|
members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
|
|
67
68
|
});
|
|
69
|
+
if (ctx.config.strictResponseEntities) {
|
|
70
|
+
members.push(...ctx.service.endpoints.map((endpoint) => this.getApiResponseEntityClass(ctx, { endpoint })));
|
|
71
|
+
}
|
|
68
72
|
return members;
|
|
69
73
|
}
|
|
70
74
|
getApiInterfaceEndpointMethod(ctx, args) {
|
|
@@ -74,7 +78,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
74
78
|
suspend: true,
|
|
75
79
|
annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
|
|
76
80
|
parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
|
|
77
|
-
returnType:
|
|
81
|
+
returnType: ctx.config.strictResponseEntities
|
|
82
|
+
? kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, { generics: ['*'] })
|
|
83
|
+
: kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
|
|
78
84
|
body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
|
|
79
85
|
});
|
|
80
86
|
}
|
|
@@ -187,6 +193,53 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
187
193
|
s `return ${kt.call([kt.call(kt.reference('getDelegate'), []), toCasing(endpoint.name, ctx.config.functionNameCasing)], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`,
|
|
188
194
|
], '\n');
|
|
189
195
|
}
|
|
196
|
+
getApiResponseEntityClass(ctx, args) {
|
|
197
|
+
const { endpoint } = args;
|
|
198
|
+
const name = this.getApiResponseEntityName(ctx, { endpoint });
|
|
199
|
+
return kt.class(name, {
|
|
200
|
+
doc: kt.doc(`Response entity for ${endpoint.name}.`),
|
|
201
|
+
generics: [kt.genericParameter('T')],
|
|
202
|
+
primaryConstructor: kt.constructor([
|
|
203
|
+
kt.parameter.class('body', kt.reference('T')),
|
|
204
|
+
kt.parameter.class('rawStatus', kt.refs.int()),
|
|
205
|
+
kt.parameter.class('headers', kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], { nullable: true }), { default: kt.toNode(null) }),
|
|
206
|
+
], null, {
|
|
207
|
+
accessModifier: endpoint.responses.length > 0 ? 'private' : null,
|
|
208
|
+
delegateTarget: 'super',
|
|
209
|
+
delegateArguments: [kt.argument('body'), kt.argument('headers'), kt.argument('rawStatus')],
|
|
210
|
+
}),
|
|
211
|
+
extends: kt.refs.spring.responseEntity([kt.reference('T')]),
|
|
212
|
+
companionObject: kt.object({
|
|
213
|
+
members: Array.from(new Set([
|
|
214
|
+
...ctx.config.defaultStatusCodes,
|
|
215
|
+
501,
|
|
216
|
+
...endpoint.responses.map((x) => x.statusCode),
|
|
217
|
+
].filter(notNullish)))
|
|
218
|
+
.map((code) => {
|
|
219
|
+
const fnName = toCasing(getReasonPhrase(code), ctx.config.functionNameCasing);
|
|
220
|
+
const response = endpoint.responses.find((x) => x.statusCode === code);
|
|
221
|
+
const responseType = response ? this.getResponseType(ctx, { endpoint, response }) : undefined;
|
|
222
|
+
const hasResponseBody = responseType && !kt.refs.unit.matches(responseType);
|
|
223
|
+
return kt.function(fnName, {
|
|
224
|
+
parameters: [
|
|
225
|
+
hasResponseBody ? kt.parameter.class('body', responseType) : null,
|
|
226
|
+
kt.parameter.class('headers', kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], { nullable: true }), { default: kt.toNode(null) }),
|
|
227
|
+
],
|
|
228
|
+
singleExpression: true,
|
|
229
|
+
body: kt.call([
|
|
230
|
+
kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, {
|
|
231
|
+
generics: [hasResponseBody ? responseType : kt.refs.unit({ nullable: true })],
|
|
232
|
+
}),
|
|
233
|
+
], [
|
|
234
|
+
hasResponseBody ? kt.argument('body') : kt.toNode(null),
|
|
235
|
+
kt.toNode(code),
|
|
236
|
+
kt.argument('headers'),
|
|
237
|
+
]),
|
|
238
|
+
});
|
|
239
|
+
}),
|
|
240
|
+
}),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
190
243
|
// #endregion
|
|
191
244
|
// #region API Controller
|
|
192
245
|
generateApiControllerFile(ctx, args) {
|
|
@@ -293,14 +346,25 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
293
346
|
getApiDelegateInterfaceEndpointMethod(ctx, args) {
|
|
294
347
|
const { endpoint } = args;
|
|
295
348
|
const parameters = this.getAllParameters(ctx, { endpoint });
|
|
296
|
-
|
|
349
|
+
const fn = kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
297
350
|
suspend: true,
|
|
298
351
|
parameters: parameters.map((parameter) => {
|
|
299
352
|
return kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }));
|
|
300
353
|
}),
|
|
301
|
-
returnType: kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
|
|
302
|
-
body: appendValueGroup([s `return ${kt.refs.spring.responseEntity.infer()}(${kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`], '\n'),
|
|
303
354
|
});
|
|
355
|
+
if (ctx.config.strictResponseEntities) {
|
|
356
|
+
const responseEntity = kt.reference.genericFactory(this.getApiResponseEntityName(ctx, { endpoint }), `${this.getPackageName(ctx, {})}.${this.getApiInterfaceName(ctx, {})}`);
|
|
357
|
+
fn.returnType = responseEntity(['*']);
|
|
358
|
+
fn.body = appendValueGroup([s `return ${kt.call([
|
|
359
|
+
responseEntity.infer(),
|
|
360
|
+
toCasing(getReasonPhrase(501), ctx.config.functionNameCasing),
|
|
361
|
+
], [])}`], '\n');
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
fn.returnType = kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]);
|
|
365
|
+
fn.body = appendValueGroup([s `return ${kt.refs.spring.responseEntity.infer()}(${kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`], '\n');
|
|
366
|
+
}
|
|
367
|
+
return fn;
|
|
304
368
|
}
|
|
305
369
|
// #endregion
|
|
306
370
|
getParameterType(ctx, args) {
|
|
@@ -313,11 +377,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
313
377
|
schema: parameter.schema,
|
|
314
378
|
nullable: (!parameter.required && ((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default) === undefined) || undefined,
|
|
315
379
|
});
|
|
316
|
-
return parameter.target === 'body' ?
|
|
380
|
+
return parameter.target === 'body' ? listToFlux(type) : type;
|
|
317
381
|
}
|
|
318
382
|
getResponseType(ctx, args) {
|
|
319
|
-
const { endpoint } = args;
|
|
320
|
-
const responseSchemas = endpoint.responses
|
|
383
|
+
const { endpoint, response } = args;
|
|
384
|
+
const responseSchemas = (response ? [response] : endpoint.responses)
|
|
321
385
|
.flatMap((x) => x.contentOptions.flatMap((x) => x.schema))
|
|
322
386
|
.filter(notNullish)
|
|
323
387
|
.filter((x, i, a) => a.findIndex((y) => {
|
|
@@ -326,7 +390,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
326
390
|
return (xType === null || xType === void 0 ? void 0 : xType.name) === (yType === null || yType === void 0 ? void 0 : yType.name) && (xType === null || xType === void 0 ? void 0 : xType.packageName) === (yType === null || yType === void 0 ? void 0 : yType.packageName);
|
|
327
391
|
}) === i);
|
|
328
392
|
if (responseSchemas.length === 1) {
|
|
329
|
-
return
|
|
393
|
+
return listToFlux(this.getTypeUsage(ctx, { schema: responseSchemas[0], fallback: kt.refs.unit() }));
|
|
330
394
|
}
|
|
331
395
|
else if (responseSchemas.length === 0) {
|
|
332
396
|
return kt.refs.unit();
|
|
@@ -374,6 +438,10 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
374
438
|
: ctx.config.packageSuffix(ctx.service);
|
|
375
439
|
return ctx.config.packageName + packageSuffix;
|
|
376
440
|
}
|
|
441
|
+
getApiResponseEntityName(ctx, args) {
|
|
442
|
+
const { endpoint } = args;
|
|
443
|
+
return toCasing(`${endpoint.name}_ResponseEntity`, ctx.config.typeNameCasing);
|
|
444
|
+
}
|
|
377
445
|
getApiInterfaceName(ctx, _args) {
|
|
378
446
|
return toCasing(ctx.service.name + '_Api', ctx.config.typeNameCasing);
|
|
379
447
|
}
|
|
@@ -445,13 +513,6 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
445
513
|
};
|
|
446
514
|
}
|
|
447
515
|
}
|
|
448
|
-
export function
|
|
449
|
-
|
|
450
|
-
return type;
|
|
451
|
-
switch (ctx.config.arrayType) {
|
|
452
|
-
case 'flux':
|
|
453
|
-
return kt.refs.reactor.flux([type.generics[0]]);
|
|
454
|
-
default:
|
|
455
|
-
return type;
|
|
456
|
-
}
|
|
516
|
+
export function listToFlux(type) {
|
|
517
|
+
return kt.refs.list.matches(type) ? kt.refs.reactor.flux([type.generics[0]]) : type;
|
|
457
518
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/kotlin",
|
|
3
|
-
"version": "0.4.7-
|
|
3
|
+
"version": "0.4.7-beta2",
|
|
4
4
|
"description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"tslib": "^2.6.2",
|
|
30
30
|
"fs-extra": "^11.2.0",
|
|
31
|
+
"http-status-codes": "^2.3.0",
|
|
31
32
|
"@goast/core": "0.4.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
@@ -4,6 +4,7 @@ export declare const httpStatus: KtReferenceFactory;
|
|
|
4
4
|
export declare const responseEntity: KtGenericReferenceFactory<1>;
|
|
5
5
|
export declare const filePart: KtReferenceFactory;
|
|
6
6
|
export declare const controller: KtReferenceFactory;
|
|
7
|
+
export declare const multiValueMap: KtGenericReferenceFactory<2>;
|
|
7
8
|
export declare const validated: KtReferenceFactory;
|
|
8
9
|
export declare const pathVariable: KtReferenceFactory;
|
|
9
10
|
export declare const requestBody: KtReferenceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/spring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,kBAAkF,CAAC;AAC5G,eAAO,MAAM,cAAc,EAAE,yBAAyB,CAAC,CAAC,CAGvD,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,kBAAgG,CAAC;AAGxH,eAAO,MAAM,UAAU,EAAE,kBAAwF,CAAC;AAGlH,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,kBAG5B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/spring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,kBAAkF,CAAC;AAC5G,eAAO,MAAM,cAAc,EAAE,yBAAyB,CAAC,CAAC,CAGvD,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,kBAAgG,CAAC;AAGxH,eAAO,MAAM,UAAU,EAAE,kBAAwF,CAAC;AAGlH,eAAO,MAAM,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAGtD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,kBAG5B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,kBAGzB,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nativeWebRequest = exports.requestPart = exports.requestParam = exports.requestMethod = exports.requestMapping = exports.requestBody = exports.pathVariable = exports.validated = exports.controller = exports.filePart = exports.responseEntity = exports.httpStatus = exports.autowired = void 0;
|
|
3
|
+
exports.nativeWebRequest = exports.requestPart = exports.requestParam = exports.requestMethod = exports.requestMapping = exports.requestBody = exports.pathVariable = exports.validated = exports.multiValueMap = exports.controller = exports.filePart = exports.responseEntity = exports.httpStatus = exports.autowired = void 0;
|
|
4
4
|
const reference_js_1 = require("../nodes/reference.js");
|
|
5
5
|
// org.springframework.beans.factory.annotation
|
|
6
6
|
exports.autowired = reference_js_1.ktReference.factory('Autowired', 'org.springframework.beans.factory.annotation');
|
|
@@ -11,6 +11,8 @@ exports.responseEntity = reference_js_1.ktReference.genericFactory('ResponseEnti
|
|
|
11
11
|
exports.filePart = reference_js_1.ktReference.factory('FilePart', 'org.springframework.http.codec.multipart');
|
|
12
12
|
// org.springframework.stereotype
|
|
13
13
|
exports.controller = reference_js_1.ktReference.factory('Controller', 'org.springframework.stereotype');
|
|
14
|
+
// org.springframework.util
|
|
15
|
+
exports.multiValueMap = reference_js_1.ktReference.genericFactory('MultiValueMap', 'org.springframework.util');
|
|
14
16
|
// org.springframework.validation.annotation
|
|
15
17
|
exports.validated = reference_js_1.ktReference.factory('Validated', 'org.springframework.validation.annotation');
|
|
16
18
|
// org.springframework.web.bind.annotation
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type { ApiEndpoint, ApiSchema, SourceBuilder } from '@goast/core';
|
|
1
|
+
import type { ApiEndpoint, ApiResponse, ApiSchema, SourceBuilder } from '@goast/core';
|
|
2
2
|
import type { kt } from '../../../ast/index.js';
|
|
3
3
|
import type { ApiParameterWithMultipartInfo } from '../../../types.js';
|
|
4
|
+
export type GenerateApiResponseEntitiesFile = {
|
|
5
|
+
dirPath: string;
|
|
6
|
+
packageName: string;
|
|
7
|
+
};
|
|
8
|
+
export type GetApiResponseEntitiesFileContent = {
|
|
9
|
+
packageName: string;
|
|
10
|
+
};
|
|
11
|
+
export type GetApiResponseEntities = object;
|
|
4
12
|
export type GenerateApiInterfaceFile = {
|
|
5
13
|
dirPath: string;
|
|
6
14
|
packageName: string;
|
|
7
15
|
};
|
|
8
|
-
export type
|
|
16
|
+
export type GetApiInterfaceFileContent = {
|
|
9
17
|
interfaceName: string;
|
|
10
18
|
};
|
|
11
19
|
export type GetApiInterface = {
|
|
@@ -14,6 +22,9 @@ export type GetApiInterface = {
|
|
|
14
22
|
export type GetApiInterfaceEndpointMethod = {
|
|
15
23
|
endpoint: ApiEndpoint;
|
|
16
24
|
};
|
|
25
|
+
export type GetApiResponseEntityClass = {
|
|
26
|
+
endpoint: ApiEndpoint;
|
|
27
|
+
};
|
|
17
28
|
export type GenerateApiControllerFile = {
|
|
18
29
|
dirPath: string;
|
|
19
30
|
packageName: string;
|
|
@@ -43,6 +54,7 @@ export type GetParameterType = {
|
|
|
43
54
|
};
|
|
44
55
|
export type GetResponseType = {
|
|
45
56
|
endpoint: ApiEndpoint;
|
|
57
|
+
response?: ApiResponse;
|
|
46
58
|
};
|
|
47
59
|
export type GetTypeUsage<TBuilder extends SourceBuilder> = {
|
|
48
60
|
schema: ApiSchema | undefined;
|
|
@@ -66,6 +78,9 @@ export type GetPathConstantName = {
|
|
|
66
78
|
endpoint: ApiEndpoint;
|
|
67
79
|
};
|
|
68
80
|
export type GetPackageName = object;
|
|
81
|
+
export type GetApiResponseEntityName = {
|
|
82
|
+
endpoint: ApiEndpoint;
|
|
83
|
+
};
|
|
69
84
|
export type GetApiInterfaceName = object;
|
|
70
85
|
export type GetApiDelegateInterfaceName = object;
|
|
71
86
|
export type GetApiControllerName = object;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAI5C,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC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B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,2BAA2B,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,MAAM,wBAAwB,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC"}
|
|
@@ -9,7 +9,8 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
|
|
|
9
9
|
pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
|
|
10
10
|
addSwaggerAnnotations: boolean;
|
|
11
11
|
addJakartaValidationAnnotations: boolean;
|
|
12
|
-
|
|
12
|
+
strictResponseEntities: boolean;
|
|
13
|
+
defaultStatusCodes: number[];
|
|
13
14
|
};
|
|
14
15
|
export declare const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConfig<KotlinServicesGeneratorConfig>;
|
|
15
16
|
export type KotlinServicesGeneratorInput = KotlinModelsGeneratorOutput;
|
|
@@ -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;AAEzE,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IAE1D,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IACjF,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC;IAE1E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,+BAA+B,EAAE,OAAO,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;AAC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
|
|
@@ -15,7 +15,7 @@ export interface KotlinSpringControllerGenerator<TOutput extends Output = Output
|
|
|
15
15
|
export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<Context, Output> implements KotlinSpringControllerGenerator {
|
|
16
16
|
generate(ctx: KotlinServiceGeneratorContext): MaybePromise<KotlinServiceGeneratorOutput>;
|
|
17
17
|
protected generateApiInterfaceFile(ctx: Context, args: Args.GenerateApiInterfaceFile): KotlinImport;
|
|
18
|
-
protected getApiInterfaceFileContent(ctx: Context, args: Args.
|
|
18
|
+
protected getApiInterfaceFileContent(ctx: Context, args: Args.GetApiInterfaceFileContent): AppendValueGroup<Builder>;
|
|
19
19
|
protected getApiInterface(ctx: Context, args: Args.GetApiInterface): kt.Interface<Builder>;
|
|
20
20
|
private getApiInterfaceAnnotations;
|
|
21
21
|
private getApiInterfaceMembers;
|
|
@@ -23,6 +23,7 @@ export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGe
|
|
|
23
23
|
private getApiInterfaceEndpointMethodAnnnotations;
|
|
24
24
|
private getApiInterfaceEndpointMethodParameter;
|
|
25
25
|
private getApiInterfaceEndpointMethodBody;
|
|
26
|
+
private getApiResponseEntityClass;
|
|
26
27
|
protected generateApiControllerFile(ctx: Context, args: Args.GenerateApiControllerFile): KotlinImport;
|
|
27
28
|
protected getApiControllerFileContent(ctx: Context, args: Args.GetApiControllerFileContent): AppendValueGroup<Builder>;
|
|
28
29
|
protected getApiController(ctx: Context, args: Args.GetApiController): kt.Class<Builder>;
|
|
@@ -44,12 +45,13 @@ export declare class DefaultKotlinSpringControllerGenerator extends KotlinFileGe
|
|
|
44
45
|
protected getDirectoryPath(ctx: Context, args: Args.GetDirectoryPath): string;
|
|
45
46
|
protected getPathConstantName(ctx: Context, args: Args.GetPathConstantName): string;
|
|
46
47
|
protected getPackageName(ctx: Context, _args: Args.GetPackageName): string;
|
|
48
|
+
protected getApiResponseEntityName(ctx: Context, args: Args.GetApiResponseEntityName): string;
|
|
47
49
|
protected getApiInterfaceName(ctx: Context, _args: Args.GetApiInterfaceName): string;
|
|
48
50
|
protected getApiControllerName(ctx: Context, _args: Args.GetApiControllerName): string;
|
|
49
51
|
protected getApiDelegateInterfaceName(ctx: Context, _args: Args.GetApiDelegateInterfaceName): string;
|
|
50
52
|
protected getAllParameters(ctx: Context, args: Args.GetAllParameters): ApiParameterWithMultipartInfo[];
|
|
51
53
|
private createApiParameter;
|
|
52
54
|
}
|
|
53
|
-
export declare function
|
|
55
|
+
export declare function listToFlux<T>(type: T): T;
|
|
54
56
|
export {};
|
|
55
57
|
//# sourceMappingURL=spring-controller-generator.d.ts.map
|
package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map
CHANGED
|
@@ -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;
|
|
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,EA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C,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,GAAG,6BAA6B,EAAE;IAuDtG,OAAO,CAAC,kBAAkB;CAgB3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAExC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultKotlinSpringControllerGenerator = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.listToFlux = listToFlux;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
7
7
|
const core_1 = require("@goast/core");
|
|
8
|
+
const http_status_codes_1 = require("http-status-codes");
|
|
8
9
|
const index_js_1 = require("../../../ast/index.js");
|
|
9
10
|
const file_builder_js_1 = require("../../../file-builder.js");
|
|
10
11
|
const utils_js_1 = require("../../../utils.js");
|
|
@@ -70,6 +71,9 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
70
71
|
ctx.service.endpoints.forEach((endpoint) => {
|
|
71
72
|
members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
|
|
72
73
|
});
|
|
74
|
+
if (ctx.config.strictResponseEntities) {
|
|
75
|
+
members.push(...ctx.service.endpoints.map((endpoint) => this.getApiResponseEntityClass(ctx, { endpoint })));
|
|
76
|
+
}
|
|
73
77
|
return members;
|
|
74
78
|
}
|
|
75
79
|
getApiInterfaceEndpointMethod(ctx, args) {
|
|
@@ -79,7 +83,9 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
79
83
|
suspend: true,
|
|
80
84
|
annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
|
|
81
85
|
parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
|
|
82
|
-
returnType:
|
|
86
|
+
returnType: ctx.config.strictResponseEntities
|
|
87
|
+
? index_js_1.kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, { generics: ['*'] })
|
|
88
|
+
: index_js_1.kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
|
|
83
89
|
body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
|
|
84
90
|
});
|
|
85
91
|
}
|
|
@@ -192,6 +198,53 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
192
198
|
(0, core_1.builderTemplate) `return ${index_js_1.kt.call([index_js_1.kt.call(index_js_1.kt.reference('getDelegate'), []), (0, core_1.toCasing)(endpoint.name, ctx.config.functionNameCasing)], parameters.map((x) => (0, core_1.toCasing)(x.name, ctx.config.parameterNameCasing)))}`,
|
|
193
199
|
], '\n');
|
|
194
200
|
}
|
|
201
|
+
getApiResponseEntityClass(ctx, args) {
|
|
202
|
+
const { endpoint } = args;
|
|
203
|
+
const name = this.getApiResponseEntityName(ctx, { endpoint });
|
|
204
|
+
return index_js_1.kt.class(name, {
|
|
205
|
+
doc: index_js_1.kt.doc(`Response entity for ${endpoint.name}.`),
|
|
206
|
+
generics: [index_js_1.kt.genericParameter('T')],
|
|
207
|
+
primaryConstructor: index_js_1.kt.constructor([
|
|
208
|
+
index_js_1.kt.parameter.class('body', index_js_1.kt.reference('T')),
|
|
209
|
+
index_js_1.kt.parameter.class('rawStatus', index_js_1.kt.refs.int()),
|
|
210
|
+
index_js_1.kt.parameter.class('headers', index_js_1.kt.refs.spring.multiValueMap([index_js_1.kt.refs.string(), index_js_1.kt.refs.string()], { nullable: true }), { default: index_js_1.kt.toNode(null) }),
|
|
211
|
+
], null, {
|
|
212
|
+
accessModifier: endpoint.responses.length > 0 ? 'private' : null,
|
|
213
|
+
delegateTarget: 'super',
|
|
214
|
+
delegateArguments: [index_js_1.kt.argument('body'), index_js_1.kt.argument('headers'), index_js_1.kt.argument('rawStatus')],
|
|
215
|
+
}),
|
|
216
|
+
extends: index_js_1.kt.refs.spring.responseEntity([index_js_1.kt.reference('T')]),
|
|
217
|
+
companionObject: index_js_1.kt.object({
|
|
218
|
+
members: Array.from(new Set([
|
|
219
|
+
...ctx.config.defaultStatusCodes,
|
|
220
|
+
501,
|
|
221
|
+
...endpoint.responses.map((x) => x.statusCode),
|
|
222
|
+
].filter(core_1.notNullish)))
|
|
223
|
+
.map((code) => {
|
|
224
|
+
const fnName = (0, core_1.toCasing)((0, http_status_codes_1.getReasonPhrase)(code), ctx.config.functionNameCasing);
|
|
225
|
+
const response = endpoint.responses.find((x) => x.statusCode === code);
|
|
226
|
+
const responseType = response ? this.getResponseType(ctx, { endpoint, response }) : undefined;
|
|
227
|
+
const hasResponseBody = responseType && !index_js_1.kt.refs.unit.matches(responseType);
|
|
228
|
+
return index_js_1.kt.function(fnName, {
|
|
229
|
+
parameters: [
|
|
230
|
+
hasResponseBody ? index_js_1.kt.parameter.class('body', responseType) : null,
|
|
231
|
+
index_js_1.kt.parameter.class('headers', index_js_1.kt.refs.spring.multiValueMap([index_js_1.kt.refs.string(), index_js_1.kt.refs.string()], { nullable: true }), { default: index_js_1.kt.toNode(null) }),
|
|
232
|
+
],
|
|
233
|
+
singleExpression: true,
|
|
234
|
+
body: index_js_1.kt.call([
|
|
235
|
+
index_js_1.kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, {
|
|
236
|
+
generics: [hasResponseBody ? responseType : index_js_1.kt.refs.unit({ nullable: true })],
|
|
237
|
+
}),
|
|
238
|
+
], [
|
|
239
|
+
hasResponseBody ? index_js_1.kt.argument('body') : index_js_1.kt.toNode(null),
|
|
240
|
+
index_js_1.kt.toNode(code),
|
|
241
|
+
index_js_1.kt.argument('headers'),
|
|
242
|
+
]),
|
|
243
|
+
});
|
|
244
|
+
}),
|
|
245
|
+
}),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
195
248
|
// #endregion
|
|
196
249
|
// #region API Controller
|
|
197
250
|
generateApiControllerFile(ctx, args) {
|
|
@@ -298,14 +351,25 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
298
351
|
getApiDelegateInterfaceEndpointMethod(ctx, args) {
|
|
299
352
|
const { endpoint } = args;
|
|
300
353
|
const parameters = this.getAllParameters(ctx, { endpoint });
|
|
301
|
-
|
|
354
|
+
const fn = index_js_1.kt.function((0, core_1.toCasing)(endpoint.name, ctx.config.functionNameCasing), {
|
|
302
355
|
suspend: true,
|
|
303
356
|
parameters: parameters.map((parameter) => {
|
|
304
357
|
return index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }));
|
|
305
358
|
}),
|
|
306
|
-
returnType: index_js_1.kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
|
|
307
|
-
body: (0, core_1.appendValueGroup)([(0, core_1.builderTemplate) `return ${index_js_1.kt.refs.spring.responseEntity.infer()}(${index_js_1.kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`], '\n'),
|
|
308
359
|
});
|
|
360
|
+
if (ctx.config.strictResponseEntities) {
|
|
361
|
+
const responseEntity = index_js_1.kt.reference.genericFactory(this.getApiResponseEntityName(ctx, { endpoint }), `${this.getPackageName(ctx, {})}.${this.getApiInterfaceName(ctx, {})}`);
|
|
362
|
+
fn.returnType = responseEntity(['*']);
|
|
363
|
+
fn.body = (0, core_1.appendValueGroup)([(0, core_1.builderTemplate) `return ${index_js_1.kt.call([
|
|
364
|
+
responseEntity.infer(),
|
|
365
|
+
(0, core_1.toCasing)((0, http_status_codes_1.getReasonPhrase)(501), ctx.config.functionNameCasing),
|
|
366
|
+
], [])}`], '\n');
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
fn.returnType = index_js_1.kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]);
|
|
370
|
+
fn.body = (0, core_1.appendValueGroup)([(0, core_1.builderTemplate) `return ${index_js_1.kt.refs.spring.responseEntity.infer()}(${index_js_1.kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`], '\n');
|
|
371
|
+
}
|
|
372
|
+
return fn;
|
|
309
373
|
}
|
|
310
374
|
// #endregion
|
|
311
375
|
getParameterType(ctx, args) {
|
|
@@ -318,11 +382,11 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
318
382
|
schema: parameter.schema,
|
|
319
383
|
nullable: (!parameter.required && ((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default) === undefined) || undefined,
|
|
320
384
|
});
|
|
321
|
-
return parameter.target === 'body' ?
|
|
385
|
+
return parameter.target === 'body' ? listToFlux(type) : type;
|
|
322
386
|
}
|
|
323
387
|
getResponseType(ctx, args) {
|
|
324
|
-
const { endpoint } = args;
|
|
325
|
-
const responseSchemas = endpoint.responses
|
|
388
|
+
const { endpoint, response } = args;
|
|
389
|
+
const responseSchemas = (response ? [response] : endpoint.responses)
|
|
326
390
|
.flatMap((x) => x.contentOptions.flatMap((x) => x.schema))
|
|
327
391
|
.filter(core_1.notNullish)
|
|
328
392
|
.filter((x, i, a) => a.findIndex((y) => {
|
|
@@ -331,7 +395,7 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
331
395
|
return (xType === null || xType === void 0 ? void 0 : xType.name) === (yType === null || yType === void 0 ? void 0 : yType.name) && (xType === null || xType === void 0 ? void 0 : xType.packageName) === (yType === null || yType === void 0 ? void 0 : yType.packageName);
|
|
332
396
|
}) === i);
|
|
333
397
|
if (responseSchemas.length === 1) {
|
|
334
|
-
return
|
|
398
|
+
return listToFlux(this.getTypeUsage(ctx, { schema: responseSchemas[0], fallback: index_js_1.kt.refs.unit() }));
|
|
335
399
|
}
|
|
336
400
|
else if (responseSchemas.length === 0) {
|
|
337
401
|
return index_js_1.kt.refs.unit();
|
|
@@ -379,6 +443,10 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
379
443
|
: ctx.config.packageSuffix(ctx.service);
|
|
380
444
|
return ctx.config.packageName + packageSuffix;
|
|
381
445
|
}
|
|
446
|
+
getApiResponseEntityName(ctx, args) {
|
|
447
|
+
const { endpoint } = args;
|
|
448
|
+
return (0, core_1.toCasing)(`${endpoint.name}_ResponseEntity`, ctx.config.typeNameCasing);
|
|
449
|
+
}
|
|
382
450
|
getApiInterfaceName(ctx, _args) {
|
|
383
451
|
return (0, core_1.toCasing)(ctx.service.name + '_Api', ctx.config.typeNameCasing);
|
|
384
452
|
}
|
|
@@ -451,13 +519,6 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
|
|
|
451
519
|
}
|
|
452
520
|
}
|
|
453
521
|
exports.DefaultKotlinSpringControllerGenerator = DefaultKotlinSpringControllerGenerator;
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
return type;
|
|
457
|
-
switch (ctx.config.arrayType) {
|
|
458
|
-
case 'flux':
|
|
459
|
-
return index_js_1.kt.refs.reactor.flux([type.generics[0]]);
|
|
460
|
-
default:
|
|
461
|
-
return type;
|
|
462
|
-
}
|
|
522
|
+
function listToFlux(type) {
|
|
523
|
+
return index_js_1.kt.refs.list.matches(type) ? index_js_1.kt.refs.reactor.flux([type.generics[0]]) : type;
|
|
463
524
|
}
|