@goast/kotlin 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/esm/src/ast/references/spring.d.ts +1 -0
  2. package/esm/src/ast/references/spring.d.ts.map +1 -1
  3. package/esm/src/ast/references/spring.js +2 -0
  4. package/esm/src/generators/services/spring-controllers/args.d.ts +17 -2
  5. package/esm/src/generators/services/spring-controllers/args.d.ts.map +1 -1
  6. package/esm/src/generators/services/spring-controllers/models.d.ts +2 -0
  7. package/esm/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  8. package/esm/src/generators/services/spring-controllers/models.js +2 -0
  9. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts +3 -1
  10. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  11. package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +74 -6
  12. package/package.json +2 -1
  13. package/script/src/ast/references/spring.d.ts +1 -0
  14. package/script/src/ast/references/spring.d.ts.map +1 -1
  15. package/script/src/ast/references/spring.js +3 -1
  16. package/script/src/generators/services/spring-controllers/args.d.ts +17 -2
  17. package/script/src/generators/services/spring-controllers/args.d.ts.map +1 -1
  18. package/script/src/generators/services/spring-controllers/models.d.ts +2 -0
  19. package/script/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  20. package/script/src/generators/services/spring-controllers/models.js +2 -0
  21. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts +3 -1
  22. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  23. package/script/src/generators/services/spring-controllers/spring-controller-generator.js +74 -6
  24. package/src/src/ast/references/spring.ts +6 -0
  25. package/src/src/generators/services/spring-controllers/args.ts +18 -3
  26. package/src/src/generators/services/spring-controllers/models.ts +6 -0
  27. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +107 -12
@@ -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 GetApiinterfaceFileContent = {
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;AAEzE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IAAE,aAAa,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SAAS,CAAC;IAC9B,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"}
@@ -10,6 +10,8 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
10
10
  addSwaggerAnnotations: boolean;
11
11
  addJakartaValidationAnnotations: boolean;
12
12
  arrayType: 'list' | 'flux';
13
+ strictResponseEntities: boolean;
14
+ defaultStatusCodes: number[];
13
15
  };
14
16
  export declare const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConfig<KotlinServicesGeneratorConfig>;
15
17
  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;IACzC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,+BAA+B,CAAC,6BAA6B,CAS/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,E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EF,eAAO,MAAM,oCAAoC,EAAE,+BAA+B,CAAC,6BAA6B,CAY/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"}
@@ -6,4 +6,6 @@ export const defaultKotlinServicesGeneratorConfig = {
6
6
  addSwaggerAnnotations: true,
7
7
  addJakartaValidationAnnotations: true,
8
8
  arrayType: 'flux',
9
+ strictResponseEntities: false,
10
+ defaultStatusCodes: [400, 401, 403, 500, 501],
9
11
  };
@@ -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.GetApiinterfaceFileContent): AppendValueGroup<Builder>;
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,6 +45,7 @@ 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;
@@ -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;AAErB,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,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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,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ1D"}
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,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,WAAW,GAAG,MAAM;IAQpE,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,GAAG,MAAM;IAK3E,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,GAAG,MAAM;IAK7E,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,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,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ1D"}
@@ -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: kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
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
- return kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
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) {
@@ -316,8 +380,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
316
380
  return parameter.target === 'body' ? adjustListType(ctx, 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) => {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
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,eAA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C;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 GetApiinterfaceFileContent = {
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;AAEzE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAGvE,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAA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ACzD,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,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"}
@@ -10,6 +10,8 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
10
10
  addSwaggerAnnotations: boolean;
11
11
  addJakartaValidationAnnotations: boolean;
12
12
  arrayType: 'list' | 'flux';
13
+ strictResponseEntities: boolean;
14
+ defaultStatusCodes: number[];
13
15
  };
14
16
  export declare const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConfig<KotlinServicesGeneratorConfig>;
15
17
  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;IACzC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,+BAA+B,CAAC,6BAA6B,CAS/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,EAA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,EAAE,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,+BAA+B,CAAC,6BAA6B,CAY/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"}
@@ -9,4 +9,6 @@ exports.defaultKotlinServicesGeneratorConfig = {
9
9
  addSwaggerAnnotations: true,
10
10
  addJakartaValidationAnnotations: true,
11
11
  arrayType: 'flux',
12
+ strictResponseEntities: false,
13
+ defaultStatusCodes: [400, 401, 403, 500, 501],
12
14
  };
@@ -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.GetApiinterfaceFileContent): AppendValueGroup<Builder>;
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,6 +45,7 @@ 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;
@@ -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;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,C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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,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ1D"}
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,O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ast/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: index_js_1.kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
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
- return index_js_1.kt.function((0, core_1.toCasing)(endpoint.name, ctx.config.functionNameCasing), {
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) {
@@ -321,8 +385,8 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
321
385
  return parameter.target === 'body' ? adjustListType(ctx, 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) => {
@@ -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
  }
@@ -19,6 +19,12 @@ export const filePart: KtReferenceFactory = ktReference.factory('FilePart', 'org
19
19
  // org.springframework.stereotype
20
20
  export const controller: KtReferenceFactory = ktReference.factory('Controller', 'org.springframework.stereotype');
21
21
 
22
+ // org.springframework.util
23
+ export const multiValueMap: KtGenericReferenceFactory<2> = ktReference.genericFactory<2>(
24
+ 'MultiValueMap',
25
+ 'org.springframework.util',
26
+ );
27
+
22
28
  // org.springframework.validation.annotation
23
29
  export const validated: KtReferenceFactory = ktReference.factory(
24
30
  'Validated',
@@ -1,19 +1,32 @@
1
- import type { ApiEndpoint, ApiSchema, SourceBuilder } from '@goast/core';
1
+ import type { ApiEndpoint, ApiResponse, ApiSchema, SourceBuilder } from '@goast/core';
2
2
 
3
3
  import type { kt } from '../../../ast/index.js';
4
4
  import type { ApiParameterWithMultipartInfo } from '../../../types.js';
5
5
 
6
+ // #region API Response Entities
7
+ export type GenerateApiResponseEntitiesFile = {
8
+ dirPath: string;
9
+ packageName: string;
10
+ };
11
+
12
+ export type GetApiResponseEntitiesFileContent = { packageName: string };
13
+
14
+ export type GetApiResponseEntities = object;
15
+ // #endregion
16
+
6
17
  // #region API Interface
7
18
  export type GenerateApiInterfaceFile = {
8
19
  dirPath: string;
9
20
  packageName: string;
10
21
  };
11
22
 
12
- export type GetApiinterfaceFileContent = { interfaceName: string };
23
+ export type GetApiInterfaceFileContent = { interfaceName: string };
13
24
 
14
25
  export type GetApiInterface = { interfaceName: string };
15
26
 
16
27
  export type GetApiInterfaceEndpointMethod = { endpoint: ApiEndpoint };
28
+
29
+ export type GetApiResponseEntityClass = { endpoint: ApiEndpoint };
17
30
  // #endregion
18
31
 
19
32
  // #region API Controller
@@ -42,7 +55,7 @@ export type GetApiDelegateInterfaceEndpointMethod = { endpoint: ApiEndpoint };
42
55
 
43
56
  export type GetParameterType = { endpoint: ApiEndpoint; parameter: ApiParameterWithMultipartInfo };
44
57
 
45
- export type GetResponseType = { endpoint: ApiEndpoint };
58
+ export type GetResponseType = { endpoint: ApiEndpoint; response?: ApiResponse };
46
59
 
47
60
  export type GetTypeUsage<TBuilder extends SourceBuilder> = {
48
61
  schema: ApiSchema | undefined;
@@ -64,6 +77,8 @@ export type GetPathConstantName = { endpoint: ApiEndpoint };
64
77
 
65
78
  export type GetPackageName = object;
66
79
 
80
+ export type GetApiResponseEntityName = { endpoint: ApiEndpoint };
81
+
67
82
  export type GetApiInterfaceName = object;
68
83
 
69
84
  export type GetApiDelegateInterfaceName = object;
@@ -19,6 +19,9 @@ export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
19
19
  addSwaggerAnnotations: boolean;
20
20
  addJakartaValidationAnnotations: boolean;
21
21
  arrayType: 'list' | 'flux';
22
+
23
+ strictResponseEntities: boolean;
24
+ defaultStatusCodes: number[];
22
25
  };
23
26
 
24
27
  export const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConfig<KotlinServicesGeneratorConfig> = {
@@ -30,6 +33,9 @@ export const defaultKotlinServicesGeneratorConfig: DefaultGenerationProviderConf
30
33
  addSwaggerAnnotations: true,
31
34
  addJakartaValidationAnnotations: true,
32
35
  arrayType: 'flux',
36
+
37
+ strictResponseEntities: false,
38
+ defaultStatusCodes: [400, 401, 403, 500, 501],
33
39
  };
34
40
 
35
41
  export type KotlinServicesGeneratorInput = KotlinModelsGeneratorOutput;
@@ -15,6 +15,7 @@ import {
15
15
  toCasing,
16
16
  } from '@goast/core';
17
17
 
18
+ import { getReasonPhrase } from 'http-status-codes';
18
19
  import { kt } from '../../../ast/index.js';
19
20
  import type { KotlinImport } from '../../../common-results.js';
20
21
  import { KotlinFileBuilder } from '../../../file-builder.js';
@@ -34,7 +35,7 @@ export interface KotlinSpringControllerGenerator<TOutput extends Output = Output
34
35
 
35
36
  export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<Context, Output>
36
37
  implements KotlinSpringControllerGenerator {
37
- generate(ctx: KotlinServiceGeneratorContext): MaybePromise<KotlinServiceGeneratorOutput> {
38
+ public generate(ctx: KotlinServiceGeneratorContext): MaybePromise<KotlinServiceGeneratorOutput> {
38
39
  const packageName = this.getPackageName(ctx, {});
39
40
  const dirPath = this.getDirectoryPath(ctx, { packageName });
40
41
  fs.ensureDirSync(dirPath);
@@ -62,10 +63,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
62
63
  return { typeName, packageName };
63
64
  }
64
65
 
65
- protected getApiInterfaceFileContent(ctx: Context, args: Args.GetApiinterfaceFileContent): AppendValueGroup<Builder> {
66
+ protected getApiInterfaceFileContent(ctx: Context, args: Args.GetApiInterfaceFileContent): AppendValueGroup<Builder> {
66
67
  const { interfaceName } = args;
67
-
68
- return appendValueGroup([this.getApiInterface(ctx, { interfaceName })], '\n');
68
+ return appendValueGroup<Builder>([this.getApiInterface(ctx, { interfaceName })], '\n');
69
69
  }
70
70
 
71
71
  protected getApiInterface(ctx: Context, args: Args.GetApiInterface): kt.Interface<Builder> {
@@ -111,6 +111,12 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
111
111
  members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
112
112
  });
113
113
 
114
+ if (ctx.config.strictResponseEntities) {
115
+ members.push(
116
+ ...ctx.service.endpoints.map((endpoint) => this.getApiResponseEntityClass(ctx, { endpoint })),
117
+ );
118
+ }
119
+
114
120
  return members;
115
121
  }
116
122
 
@@ -125,7 +131,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
125
131
  suspend: true,
126
132
  annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
127
133
  parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
128
- returnType: kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
134
+ returnType: ctx.config.strictResponseEntities
135
+ ? kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, { generics: ['*'] })
136
+ : kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
129
137
  body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
130
138
  });
131
139
  }
@@ -304,6 +312,68 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
304
312
  '\n',
305
313
  );
306
314
  }
315
+
316
+ private getApiResponseEntityClass(ctx: Context, args: Args.GetApiResponseEntityClass): kt.Class<Builder> {
317
+ const { endpoint } = args;
318
+ const name = this.getApiResponseEntityName(ctx, { endpoint });
319
+ return kt.class(name, {
320
+ doc: kt.doc(`Response entity for ${endpoint.name}.`),
321
+ generics: [kt.genericParameter('T')],
322
+ primaryConstructor: kt.constructor(
323
+ [
324
+ kt.parameter.class('body', kt.reference('T')),
325
+ kt.parameter.class('rawStatus', kt.refs.int()),
326
+ kt.parameter.class(
327
+ 'headers',
328
+ kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], { nullable: true }),
329
+ { default: kt.toNode(null) },
330
+ ),
331
+ ],
332
+ null,
333
+ {
334
+ accessModifier: endpoint.responses.length > 0 ? 'private' : null,
335
+ delegateTarget: 'super',
336
+ delegateArguments: [kt.argument('body'), kt.argument('headers'), kt.argument('rawStatus')],
337
+ },
338
+ ),
339
+ extends: kt.refs.spring.responseEntity([kt.reference('T')]),
340
+ companionObject: kt.object({
341
+ members: Array.from(
342
+ new Set([
343
+ ...ctx.config.defaultStatusCodes,
344
+ 501,
345
+ ...endpoint.responses.map((x) => x.statusCode),
346
+ ].filter(notNullish)),
347
+ )
348
+ .map((code) => {
349
+ const fnName = toCasing(getReasonPhrase(code), ctx.config.functionNameCasing);
350
+ const response = endpoint.responses.find((x) => x.statusCode === code);
351
+ const responseType = response ? this.getResponseType(ctx, { endpoint, response }) : undefined;
352
+ const hasResponseBody = responseType && !kt.refs.unit.matches(responseType);
353
+ return kt.function(fnName, {
354
+ parameters: [
355
+ hasResponseBody ? kt.parameter.class('body', responseType) : null,
356
+ kt.parameter.class(
357
+ 'headers',
358
+ kt.refs.spring.multiValueMap([kt.refs.string(), kt.refs.string()], { nullable: true }),
359
+ { default: kt.toNode(null) },
360
+ ),
361
+ ],
362
+ singleExpression: true,
363
+ body: kt.call([
364
+ kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, {
365
+ generics: [hasResponseBody ? responseType : kt.refs.unit({ nullable: true })],
366
+ }),
367
+ ], [
368
+ hasResponseBody ? kt.argument('body') : kt.toNode(null),
369
+ kt.toNode(code),
370
+ kt.argument('headers'),
371
+ ]),
372
+ });
373
+ }),
374
+ }),
375
+ });
376
+ }
307
377
  // #endregion
308
378
 
309
379
  // #region API Controller
@@ -461,7 +531,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
461
531
  const { endpoint } = args;
462
532
  const parameters = this.getAllParameters(ctx, { endpoint });
463
533
 
464
- return kt.function(toCasing(endpoint.name, ctx.config.functionNameCasing), {
534
+ const fn = kt.function<Builder>(toCasing(endpoint.name, ctx.config.functionNameCasing), {
465
535
  suspend: true,
466
536
  parameters: parameters.map((parameter) => {
467
537
  return kt.parameter(
@@ -469,12 +539,32 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
469
539
  this.getParameterType(ctx, { endpoint, parameter }),
470
540
  );
471
541
  }),
472
- returnType: kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
473
- body: appendValueGroup(
542
+ });
543
+
544
+ if (ctx.config.strictResponseEntities) {
545
+ const responseEntity = kt.reference.genericFactory(
546
+ this.getApiResponseEntityName(ctx, { endpoint }),
547
+ `${this.getPackageName(ctx, {})}.${this.getApiInterfaceName(ctx, {})}`,
548
+ );
549
+ fn.returnType = responseEntity(['*']);
550
+ fn.body = appendValueGroup(
551
+ [s`return ${
552
+ kt.call([
553
+ responseEntity.infer(),
554
+ toCasing(getReasonPhrase(501), ctx.config.functionNameCasing),
555
+ ], [])
556
+ }`],
557
+ '\n',
558
+ );
559
+ } else {
560
+ fn.returnType = kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]);
561
+ fn.body = appendValueGroup(
474
562
  [s`return ${kt.refs.spring.responseEntity.infer()}(${kt.refs.spring.httpStatus()}.NOT_IMPLEMENTED)`],
475
563
  '\n',
476
- ),
477
- });
564
+ );
565
+ }
566
+
567
+ return fn;
478
568
  }
479
569
  // #endregion
480
570
 
@@ -491,8 +581,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
491
581
  }
492
582
 
493
583
  protected getResponseType(ctx: Context, args: Args.GetResponseType): kt.Type<Builder> {
494
- const { endpoint } = args;
495
- const responseSchemas = endpoint.responses
584
+ const { endpoint, response } = args;
585
+ const responseSchemas = (response ? [response] : endpoint.responses)
496
586
  .flatMap((x) => x.contentOptions.flatMap((x) => x.schema))
497
587
  .filter(notNullish)
498
588
  .filter(
@@ -563,6 +653,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
563
653
  return ctx.config.packageName + packageSuffix;
564
654
  }
565
655
 
656
+ protected getApiResponseEntityName(ctx: Context, args: Args.GetApiResponseEntityName): string {
657
+ const { endpoint } = args;
658
+ return toCasing(`${endpoint.name}_ResponseEntity`, ctx.config.typeNameCasing);
659
+ }
660
+
566
661
  protected getApiInterfaceName(ctx: Context, _args: Args.GetApiInterfaceName): string {
567
662
  return toCasing(ctx.service.name + '_Api', ctx.config.typeNameCasing);
568
663
  }