@goast/kotlin 0.4.12 → 0.4.13

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 (37) hide show
  1. package/esm/src/ast/nodes/function.d.ts.map +1 -1
  2. package/esm/src/ast/nodes/function.js +3 -1
  3. package/esm/src/ast/references/kotlin.d.ts +1 -0
  4. package/esm/src/ast/references/kotlin.d.ts.map +1 -1
  5. package/esm/src/ast/references/kotlin.js +1 -0
  6. package/esm/src/generators/services/spring-controllers/models.d.ts +5 -2
  7. package/esm/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  8. package/esm/src/generators/services/spring-controllers/refs.d.ts +6 -0
  9. package/esm/src/generators/services/spring-controllers/refs.d.ts.map +1 -0
  10. package/esm/src/generators/services/spring-controllers/refs.js +9 -0
  11. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  12. package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +23 -9
  13. package/esm/src/generators/services/spring-controllers/spring-controllers-generator.d.ts +7 -1
  14. package/esm/src/generators/services/spring-controllers/spring-controllers-generator.d.ts.map +1 -1
  15. package/esm/src/generators/services/spring-controllers/spring-controllers-generator.js +41 -2
  16. package/package.json +1 -1
  17. package/script/src/ast/nodes/function.d.ts.map +1 -1
  18. package/script/src/ast/nodes/function.js +3 -1
  19. package/script/src/ast/references/kotlin.d.ts +1 -0
  20. package/script/src/ast/references/kotlin.d.ts.map +1 -1
  21. package/script/src/ast/references/kotlin.js +2 -1
  22. package/script/src/generators/services/spring-controllers/models.d.ts +5 -2
  23. package/script/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  24. package/script/src/generators/services/spring-controllers/refs.d.ts +6 -0
  25. package/script/src/generators/services/spring-controllers/refs.d.ts.map +1 -0
  26. package/script/src/generators/services/spring-controllers/refs.js +12 -0
  27. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  28. package/script/src/generators/services/spring-controllers/spring-controller-generator.js +23 -9
  29. package/script/src/generators/services/spring-controllers/spring-controllers-generator.d.ts +7 -1
  30. package/script/src/generators/services/spring-controllers/spring-controllers-generator.d.ts.map +1 -1
  31. package/script/src/generators/services/spring-controllers/spring-controllers-generator.js +41 -1
  32. package/src/src/ast/nodes/function.ts +3 -1
  33. package/src/src/ast/references/kotlin.ts +1 -0
  34. package/src/src/generators/services/spring-controllers/models.ts +12 -7
  35. package/src/src/generators/services/spring-controllers/refs.ts +17 -0
  36. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +30 -16
  37. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +48 -1
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/nodes/function.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAErB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAe,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,KAAK,OAAO,GACR,KAAK,GACL,aAAa,GACb,WAAW,GACX,UAAU,GACV,qBAAqB,GACrB,cAAc,GACd,MAAM,GACN,YAAY,GACZ,YAAY,CAAC;AAEjB,KAAK,OAAO,CAAC,QAAQ,SAAS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B,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;gBAEb,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;cAuB7B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;CAiEpD;AAED,QAAA,MAAM,cAAc,GAAI,QAAQ,SAAS,aAAa,QAC9C,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YACrB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,KAClD,UAAU,CAAC,QAAQ,CAAmD,CAAC;AAE1E,eAAO,MAAM,UAAU,EAAE,OAAO,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,YAAY,CAAA;CAE3E,CAAC"}
@@ -4,6 +4,7 @@ import { writeKtNode, writeKtNodes } from '../utils/write-kt-node.js';
4
4
  import { ktAnnotation } from './annotation.js';
5
5
  import { ktDoc } from './doc.js';
6
6
  import { ktGenericParameter } from './generic-parameter.js';
7
+ import { KtInterface } from './interface.js';
7
8
  import { ktParameter } from './parameter.js';
8
9
  export class KtFunction extends KtNode {
9
10
  constructor(options) {
@@ -196,7 +197,8 @@ export class KtFunction extends KtNode {
196
197
  writeKtNode(builder, this.returnType);
197
198
  builder.append(this.inject.afterReturnType);
198
199
  }
199
- if (!this.abstract) {
200
+ const isInInterface = this.getParentNode(builder) instanceof KtInterface;
201
+ if (!this.abstract && (this.body || !isInInterface)) {
200
202
  builder.append(' ');
201
203
  if (this.singleExpression && this.body) {
202
204
  builder.append('= ');
@@ -11,6 +11,7 @@ export declare const boolean: KtReferenceFactory;
11
11
  export declare const lazyFun: KtGenericReferenceFactory<1>;
12
12
  export declare const throws: KtReferenceFactory;
13
13
  export declare const deprecated: KtReferenceFactory;
14
+ export declare const throwable: KtReferenceFactory;
14
15
  export declare const list: KtGenericReferenceFactory<1>;
15
16
  export declare const mutableList: KtGenericReferenceFactory<1>;
16
17
  export declare const map: KtGenericReferenceFactory<2>;
@@ -1 +1 @@
1
- {"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/kotlin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,GAAG,EAAE,kBAAyD,CAAC;AAC5E,eAAO,MAAM,OAAO,EAAE,kBAA6D,CAAC;AACpF,eAAO,MAAM,IAAI,EAAE,kBAA0D,CAAC;AAC9E,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,GAAG,EAAE,kBAAyD,CAAC;AAC5E,eAAO,MAAM,IAAI,EAAE,kBAA0D,CAAC;AAC9E,eAAO,MAAM,KAAK,EAAE,kBAA2D,CAAC;AAChF,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,OAAO,EAAE,kBAA6D,CAAC;AACpF,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAmD,CAAC;AACrG,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,UAAU,EAAE,kBAAgE,CAAC;AAG1F,eAAO,MAAM,IAAI,EAAE,yBAAyB,CAAC,CAAC,CAA+D,CAAC;AAC9G,eAAO,MAAM,WAAW,EAAE,yBAAyB,CAAC,CAAC,CAGpD,CAAC;AACF,eAAO,MAAM,GAAG,EAAE,yBAAyB,CAAC,CAAC,CAA8D,CAAC;AAC5G,eAAO,MAAM,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAGnD,CAAC;AACF,eAAO,MA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C,CAA8D,CAAC;AAC5G,eAAO,MAAM,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAGnD,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAiE,CAAC;AAClH,eAAO,MAAM,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAGtD,CAAC;AACF,eAAO,MAAM,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAgE,CAAC;AAChH,eAAO,MAAM,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAGrD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,kBAAmE,CAAC"}
@@ -12,6 +12,7 @@ export const boolean = ktReference.factory('Boolean', 'kotlin');
12
12
  export const lazyFun = ktReference.genericFactory('lazy', 'kotlin');
13
13
  export const throws = ktReference.factory('Throws', 'kotlin');
14
14
  export const deprecated = ktReference.factory('Deprecated', 'kotlin');
15
+ export const throwable = ktReference.factory('Throwable', 'kotlin');
15
16
  // kotlin.collections
16
17
  export const list = ktReference.genericFactory('List', 'kotlin.collections');
17
18
  export const mutableList = ktReference.genericFactory('MutableList', 'kotlin.collections');
@@ -2,9 +2,10 @@ import type { ApiEndpoint, ApiService, DefaultGenerationProviderConfig, OpenApiS
2
2
  import type { KotlinImport } from '../../../common-results.js';
3
3
  import { type KotlinGeneratorConfig } from '../../../config.js';
4
4
  import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
5
+ import type { getReferenceFactories } from './refs.js';
5
6
  export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
6
7
  packageName: string;
7
- packageSuffix: string | ((service: ApiService) => string);
8
+ packageSuffix: string | ((service: ApiService | null) => string);
8
9
  basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
9
10
  pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
10
11
  addSwaggerAnnotations: boolean;
@@ -27,7 +28,9 @@ export type KotlinServiceGeneratorOutput = {
27
28
  apiController: KotlinImport;
28
29
  apiDelegate: KotlinImport;
29
30
  };
30
- export type KotlinServicesGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinServicesGeneratorInput, KotlinServicesGeneratorOutput, KotlinServicesGeneratorConfig, KotlinServiceGeneratorOutput>;
31
+ export type KotlinServicesGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinServicesGeneratorInput, KotlinServicesGeneratorOutput, KotlinServicesGeneratorConfig, KotlinServiceGeneratorOutput> & {
32
+ refs: ReturnType<typeof getReferenceFactories>;
33
+ };
31
34
  export type KotlinServiceGeneratorContext = KotlinServicesGeneratorContext & {
32
35
  service: ApiService;
33
36
  };
@@ -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;IAE3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,MAAM,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"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EA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kt } from '../../../ast/index.js';
2
+ import type { KotlinServicesGeneratorConfig } from './models.js';
3
+ export declare function getReferenceFactories(options: KotlinServicesGeneratorConfig): {
4
+ apiExceptionHandler: kt.ReferenceFactory;
5
+ };
6
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,6BAA6B,GAAG;IAC7E,mBAAmB,EAAE,EAAE,CAAC,gBAAgB,CAAC;CAC1C,CAUA"}
@@ -0,0 +1,9 @@
1
+ import { toCasing } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ export function getReferenceFactories(options) {
4
+ const packageSuffix = typeof options.packageSuffix === 'string' ? options.packageSuffix : options.packageSuffix(null);
5
+ const packageName = options.packageName + packageSuffix;
6
+ return {
7
+ apiExceptionHandler: kt.reference.factory(toCasing('ApiExceptionHandler', options.typeNameCasing), packageName),
8
+ };
9
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EA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F,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
+ {"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,qBA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terfaceName],
64
64
  }),
65
+ }), kt.function('getExceptionHandler', {
66
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
67
+ singleExpression: true,
68
+ body: kt.toNode(null),
65
69
  }));
66
70
  ctx.service.endpoints.forEach((endpoint) => {
67
71
  members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
@@ -78,9 +82,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
78
82
  suspend: true,
79
83
  annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
80
84
  parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
81
- returnType: ctx.config.strictResponseEntities
82
- ? kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, { generics: ['*'] })
83
- : kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
85
+ returnType: kt.refs.spring.responseEntity(['*']),
84
86
  body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
85
87
  });
86
88
  }
@@ -194,7 +196,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
194
196
  }
195
197
  getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters) {
196
198
  return appendValueGroup([
197
- s `return ${kt.call([kt.call(kt.reference('getDelegate'), []), toCasing(endpoint.name, ctx.config.functionNameCasing)], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`,
199
+ s `try {${s.indent `
200
+ return ${kt.call([kt.call(kt.reference('getDelegate'), []), toCasing(endpoint.name, ctx.config.functionNameCasing)], parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)))}`}
201
+ } catch (e: ${kt.refs.throwable()}) {${s.indent `
202
+ return getExceptionHandler()?.handleApiException(e) ?: throw e`}
203
+ }`,
198
204
  ], '\n');
199
205
  }
200
206
  getApiResponseEntityClass(ctx, args) {
@@ -278,6 +284,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
278
284
  kt.parameter.class('delegate', kt.reference(this.getApiDelegateInterfaceName(ctx, {}), null, { nullable: true }), {
279
285
  annotations: [kt.annotation(kt.refs.spring.autowired(), [kt.argument.named('required', 'false')])],
280
286
  }),
287
+ kt.parameter.class('exceptionHandler', ctx.refs.apiExceptionHandler({ nullable: true }), {
288
+ annotations: [kt.annotation(kt.refs.spring.autowired(), [kt.argument.named('required', 'false')])],
289
+ accessModifier: 'private',
290
+ property: 'readonly',
291
+ }),
281
292
  ]),
282
293
  implements: [this.getApiInterfaceName(ctx, {})],
283
294
  members: this.getApiControllerMembers(ctx),
@@ -298,18 +309,21 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
298
309
  const delegateInterfaceName = this.getApiDelegateInterfaceName(ctx, {});
299
310
  const delegateProp = kt.property('delegate', {
300
311
  accessModifier: 'private',
301
- type: kt.reference(delegateInterfaceName),
312
+ default: s `delegate ?: ${kt.object({ implements: [delegateInterfaceName] })}`,
302
313
  });
303
- const initBlock = kt.initBlock(appendValueGroup([
304
- s `this.delegate = ${kt.refs.java.optional.infer()}.ofNullable(delegate).orElse(object : ${delegateInterfaceName} {})`,
305
- ], '\n'));
306
314
  const getDelegateFun = kt.function('getDelegate', {
307
315
  override: true,
308
316
  returnType: delegateInterfaceName,
309
317
  singleExpression: true,
310
318
  body: kt.reference('delegate'),
311
319
  });
312
- return [delegateProp, initBlock, getDelegateFun];
320
+ const getExceptionHandlerFun = kt.function('getExceptionHandler', {
321
+ override: true,
322
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
323
+ singleExpression: true,
324
+ body: kt.reference('exceptionHandler'),
325
+ });
326
+ return [delegateProp, getDelegateFun, getExceptionHandlerFun];
313
327
  }
314
328
  // #endregion
315
329
  // #region API Delegate Interface
@@ -1,4 +1,6 @@
1
- import { type ApiService, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
1
+ import { type ApiService, type AppendValueGroup, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ import { KotlinFileBuilder } from '../../../file-builder.js';
2
4
  import { type KotlinServiceGeneratorOutput, type KotlinServicesGeneratorConfig, type KotlinServicesGeneratorContext, type KotlinServicesGeneratorInput, type KotlinServicesGeneratorOutput } from './models.js';
3
5
  import { type KotlinSpringControllerGenerator } from './spring-controller-generator.js';
4
6
  type Input = KotlinServicesGeneratorInput;
@@ -13,6 +15,10 @@ export declare class KotlinSpringControllersGenerator extends OpenApiServicesGen
13
15
  protected generateService(ctx: Context, service: ApiService): MaybePromise<ServiceOutput>;
14
16
  protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
15
17
  protected buildContext(context: OpenApiGeneratorContext<KotlinServicesGeneratorInput>, config?: Partial<Config> | undefined): Context;
18
+ protected generateAdditionalFiles(ctx: KotlinServicesGeneratorContext): void;
19
+ protected generateApiExceptionHandler(ctx: Context): void;
20
+ protected getApiExceptionHandlerFileContent(ctx: Context): AppendValueGroup<KotlinFileBuilder>;
21
+ protected getApiExceptionHandlerInterface(ctx: Context): kt.Interface<KotlinFileBuilder>;
16
22
  }
17
23
  export {};
18
24
  //# sourceMappingURL=spring-controllers-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,kCAAkC,CAAC;AAE1C,KAAK,KAAK,GAAG,4BAA4B,CAAC;AAC1C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,aAAa,GAAG,4BAA4B,CAAC;AAClD,KAAK,OAAO,GAAG,8BAA8B,CAAC;AAE9C,qBAAa,gCAAiC,SAAQ,qCAAqC,CACzF,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA+C;gBAE5E,uBAAuB,CAAC,EAAE,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC;IAMlF,SAAS,CAAC,UAAU,IAAI,MAAM;IAQ9B,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC;IAQzF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAI1F,SAAS,CAAC,YAAY,CACpB,OAAO,EAAE,uBAAuB,CAAC,4BAA4B,CAAC,EAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GACnC,OAAO;CAIX"}
1
+ {"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAA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
@@ -1,5 +1,9 @@
1
- import { Factory, OpenApiServicesGenerationProviderBase, } from '@goast/core';
1
+ import fs from 'fs-extra';
2
+ import { appendValueGroup, Factory, OpenApiServicesGenerationProviderBase, } from '@goast/core';
3
+ import { kt } from '../../../ast/index.js';
4
+ import { KotlinFileBuilder } from '../../../file-builder.js';
2
5
  import { defaultKotlinServicesGeneratorConfig, } from './models.js';
6
+ import { getReferenceFactories } from './refs.js';
3
7
  import { DefaultKotlinSpringControllerGenerator, } from './spring-controller-generator.js';
4
8
  export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationProviderBase {
5
9
  constructor(serviceGeneratorFactory) {
@@ -31,6 +35,41 @@ export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationP
31
35
  }
32
36
  buildContext(context, config) {
33
37
  context.data.services = context.data.services.filter((x) => x.name !== 'exclude-from-generation');
34
- return this.getProviderContext(context, config, defaultKotlinServicesGeneratorConfig);
38
+ const providerContext = this.getProviderContext(context, config, defaultKotlinServicesGeneratorConfig);
39
+ return Object.assign(providerContext, {
40
+ refs: getReferenceFactories(providerContext.config),
41
+ });
42
+ }
43
+ generateAdditionalFiles(ctx) {
44
+ this.generateApiExceptionHandler(ctx);
45
+ }
46
+ generateApiExceptionHandler(ctx) {
47
+ var _a;
48
+ const packageName = (_a = ctx.refs.apiExceptionHandler.packageName) !== null && _a !== void 0 ? _a : ctx.config.packageName;
49
+ const dir = `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}`;
50
+ const fileName = `${ctx.refs.apiExceptionHandler.refName}.kt`;
51
+ console.log(`Generating Api Exception Handler to ${fileName}...`);
52
+ const builder = new KotlinFileBuilder(packageName, ctx.config);
53
+ builder.append(this.getApiExceptionHandlerInterface(ctx));
54
+ fs.writeFileSync(`${dir}/${fileName}`, builder.toString());
55
+ }
56
+ getApiExceptionHandlerFileContent(ctx) {
57
+ return appendValueGroup([this.getApiExceptionHandlerInterface(ctx)], '\n');
58
+ }
59
+ getApiExceptionHandlerInterface(ctx) {
60
+ return kt.interface(ctx.refs.apiExceptionHandler.refName, {
61
+ members: [
62
+ kt.function('handleApiException', {
63
+ doc: kt.doc('Handler for API exceptions.', [kt.docTag('return', 'Response entity.')]),
64
+ suspend: true,
65
+ parameters: [
66
+ kt.parameter('exception', kt.refs.throwable(), {
67
+ description: 'Exception that has been thrown by the API.',
68
+ }),
69
+ ],
70
+ returnType: kt.refs.spring.responseEntity(['*']),
71
+ }),
72
+ ],
73
+ });
35
74
  }
36
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/nodes/function.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAErB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAe,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,KAAK,OAAO,GACR,KAAK,GACL,aAAa,GACb,WAAW,GACX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,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACtC,mBAAmB,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC9C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;gBAEb,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;cAuB7B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;CAiEpD;AAED,QAAA,MAAM,cAAc,GAAI,QAAQ,SAAS,aAAa,QAC9C,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YACrB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,KAClD,UAAU,CAAC,QAAQ,CAAmD,CAAC;AAE1E,eAAO,MAAM,UAAU,EAAE,OAAO,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,YAAY,CAAA;CAE3E,CAAC"}
@@ -7,6 +7,7 @@ const write_kt_node_js_1 = require("../utils/write-kt-node.js");
7
7
  const annotation_js_1 = require("./annotation.js");
8
8
  const doc_js_1 = require("./doc.js");
9
9
  const generic_parameter_js_1 = require("./generic-parameter.js");
10
+ const interface_js_1 = require("./interface.js");
10
11
  const parameter_js_1 = require("./parameter.js");
11
12
  class KtFunction extends node_js_1.KtNode {
12
13
  constructor(options) {
@@ -199,7 +200,8 @@ class KtFunction extends node_js_1.KtNode {
199
200
  (0, write_kt_node_js_1.writeKtNode)(builder, this.returnType);
200
201
  builder.append(this.inject.afterReturnType);
201
202
  }
202
- if (!this.abstract) {
203
+ const isInInterface = this.getParentNode(builder) instanceof interface_js_1.KtInterface;
204
+ if (!this.abstract && (this.body || !isInInterface)) {
203
205
  builder.append(' ');
204
206
  if (this.singleExpression && this.body) {
205
207
  builder.append('= ');
@@ -11,6 +11,7 @@ export declare const boolean: KtReferenceFactory;
11
11
  export declare const lazyFun: KtGenericReferenceFactory<1>;
12
12
  export declare const throws: KtReferenceFactory;
13
13
  export declare const deprecated: KtReferenceFactory;
14
+ export declare const throwable: KtReferenceFactory;
14
15
  export declare const list: KtGenericReferenceFactory<1>;
15
16
  export declare const mutableList: KtGenericReferenceFactory<1>;
16
17
  export declare const map: KtGenericReferenceFactory<2>;
@@ -1 +1 @@
1
- {"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/kotlin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,GAAG,EAAE,kBAAyD,CAAC;AAC5E,eAAO,MAAM,OAAO,EAAE,kBAA6D,CAAC;AACpF,eAAO,MAAM,IAAI,EAAE,kBAA0D,CAAC;AAC9E,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,GAAG,EAAE,kBAAyD,CAAC;AAC5E,eAAO,MAAM,IAAI,EAAE,kBAA0D,CAAC;AAC9E,eAAO,MAAM,KAAK,EAAE,kBAA2D,CAAC;AAChF,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,OAAO,EAAE,kBAA6D,CAAC;AACpF,eAAO,MAAM,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAmD,CAAC;AACrG,eAAO,MAAM,MAAM,EAAE,kBAA4D,CAAC;AAClF,eAAO,MAAM,UAAU,EAAE,kBAAgE,CAAC;AAG1F,eAAO,MAAM,IAAI,EAAE,yBAAyB,CAAC,CAAC,CAA+D,CAAC;AAC9G,eAAO,MAAM,WAAW,EAAE,yBAAyB,CAAC,CAA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AAI,EAAE,yBAAyB,CAAC,CAAC,CAA+D,CAAC;AAC9G,eAAO,MAAM,WAAW,EAAE,yBAAyB,CAAC,CAAC,CAGpD,CAAC;AACF,eAAO,MAAM,GAAG,EAAE,yBAAyB,CAAC,CAAC,CAA8D,CAAC;AAC5G,eAAO,MAAM,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAGnD,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAiE,CAAC;AAClH,eAAO,MAAM,aAAa,EAAE,yBAAyB,CAAC,CAAC,CAGtD,CAAC;AACF,eAAO,MAAM,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAgE,CAAC;AAChH,eAAO,MAAM,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAGrD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,kBAAmE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jvmStatic = exports.mutableMapOf = exports.mapOf = exports.mutableListOf = exports.listOf = exports.mutableMap = exports.map = exports.mutableList = exports.list = exports.deprecated = exports.throws = exports.lazyFun = exports.boolean = exports.double = exports.float = exports.long = exports.int = exports.string = exports.unit = exports.nothing = exports.any = void 0;
3
+ exports.jvmStatic = exports.mutableMapOf = exports.mapOf = exports.mutableListOf = exports.listOf = exports.mutableMap = exports.map = exports.mutableList = exports.list = exports.throwable = exports.deprecated = exports.throws = exports.lazyFun = exports.boolean = exports.double = exports.float = exports.long = exports.int = exports.string = exports.unit = exports.nothing = exports.any = void 0;
4
4
  const reference_js_1 = require("../nodes/reference.js");
5
5
  // kotlin
6
6
  exports.any = reference_js_1.ktReference.factory('Any', 'kotlin');
@@ -15,6 +15,7 @@ exports.boolean = reference_js_1.ktReference.factory('Boolean', 'kotlin');
15
15
  exports.lazyFun = reference_js_1.ktReference.genericFactory('lazy', 'kotlin');
16
16
  exports.throws = reference_js_1.ktReference.factory('Throws', 'kotlin');
17
17
  exports.deprecated = reference_js_1.ktReference.factory('Deprecated', 'kotlin');
18
+ exports.throwable = reference_js_1.ktReference.factory('Throwable', 'kotlin');
18
19
  // kotlin.collections
19
20
  exports.list = reference_js_1.ktReference.genericFactory('List', 'kotlin.collections');
20
21
  exports.mutableList = reference_js_1.ktReference.genericFactory('MutableList', 'kotlin.collections');
@@ -2,9 +2,10 @@ import type { ApiEndpoint, ApiService, DefaultGenerationProviderConfig, OpenApiS
2
2
  import type { KotlinImport } from '../../../common-results.js';
3
3
  import { type KotlinGeneratorConfig } from '../../../config.js';
4
4
  import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
5
+ import type { getReferenceFactories } from './refs.js';
5
6
  export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
6
7
  packageName: string;
7
- packageSuffix: string | ((service: ApiService) => string);
8
+ packageSuffix: string | ((service: ApiService | null) => string);
8
9
  basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
9
10
  pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
10
11
  addSwaggerAnnotations: boolean;
@@ -27,7 +28,9 @@ export type KotlinServiceGeneratorOutput = {
27
28
  apiController: KotlinImport;
28
29
  apiDelegate: KotlinImport;
29
30
  };
30
- export type KotlinServicesGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinServicesGeneratorInput, KotlinServicesGeneratorOutput, KotlinServicesGeneratorConfig, KotlinServiceGeneratorOutput>;
31
+ export type KotlinServicesGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinServicesGeneratorInput, KotlinServicesGeneratorOutput, KotlinServicesGeneratorConfig, KotlinServiceGeneratorOutput> & {
32
+ refs: ReturnType<typeof getReferenceFactories>;
33
+ };
31
34
  export type KotlinServiceGeneratorContext = KotlinServicesGeneratorContext & {
32
35
  service: ApiService;
33
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/models.ts"],"names":[],"mappings":"AAA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AChC,kBAAkB,EAAE,MAAM,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,GACtC,wCAAwC,CACxC,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,CAC7B,GACC;IACA,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEJ,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,GAAG;IAC3E,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { kt } from '../../../ast/index.js';
2
+ import type { KotlinServicesGeneratorConfig } from './models.js';
3
+ export declare function getReferenceFactories(options: KotlinServicesGeneratorConfig): {
4
+ apiExceptionHandler: kt.ReferenceFactory;
5
+ };
6
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEjE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,6BAA6B,GAAG;IAC7E,mBAAmB,EAAE,EAAE,CAAC,gBAAgB,CAAC;CAC1C,CAUA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReferenceFactories = getReferenceFactories;
4
+ const core_1 = require("@goast/core");
5
+ const index_js_1 = require("../../../ast/index.js");
6
+ function getReferenceFactories(options) {
7
+ const packageSuffix = typeof options.packageSuffix === 'string' ? options.packageSuffix : options.packageSuffix(null);
8
+ const packageName = options.packageName + packageSuffix;
9
+ return {
10
+ apiExceptionHandler: index_js_1.kt.reference.factory((0, core_1.toCasing)('ApiExceptionHandler', options.typeNameCasing), packageName),
11
+ };
12
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"spring-controller-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controller-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAGjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,0CAA0C,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE/F,KAAK,OAAO,GAAG,6BAA6B,CAAC;AAC7C,KAAK,MAAM,GAAG,4BAA4B,CAAC;AAC3C,KAAK,OAAO,GAAG,iBAAiB,CAAC;AAEjC,MAAM,WAAW,+BAA+B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC9E,QAAQ,CAAC,GAAG,EAA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G,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"}
@@ -67,6 +67,10 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
67
67
  body: index_js_1.kt.object({
68
68
  implements: [delegateInterfaceName],
69
69
  }),
70
+ }), index_js_1.kt.function('getExceptionHandler', {
71
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
72
+ singleExpression: true,
73
+ body: index_js_1.kt.toNode(null),
70
74
  }));
71
75
  ctx.service.endpoints.forEach((endpoint) => {
72
76
  members.push(this.getApiInterfaceEndpointMethod(ctx, { endpoint }));
@@ -83,9 +87,7 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
83
87
  suspend: true,
84
88
  annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
85
89
  parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
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 })]),
90
+ returnType: index_js_1.kt.refs.spring.responseEntity(['*']),
89
91
  body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
90
92
  });
91
93
  }
@@ -199,7 +201,11 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
199
201
  }
200
202
  getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters) {
201
203
  return (0, core_1.appendValueGroup)([
202
- (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)))}`,
204
+ (0, core_1.builderTemplate) `try {${core_1.builderTemplate.indent `
205
+ 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)))}`}
206
+ } catch (e: ${index_js_1.kt.refs.throwable()}) {${core_1.builderTemplate.indent `
207
+ return getExceptionHandler()?.handleApiException(e) ?: throw e`}
208
+ }`,
203
209
  ], '\n');
204
210
  }
205
211
  getApiResponseEntityClass(ctx, args) {
@@ -283,6 +289,11 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
283
289
  index_js_1.kt.parameter.class('delegate', index_js_1.kt.reference(this.getApiDelegateInterfaceName(ctx, {}), null, { nullable: true }), {
284
290
  annotations: [index_js_1.kt.annotation(index_js_1.kt.refs.spring.autowired(), [index_js_1.kt.argument.named('required', 'false')])],
285
291
  }),
292
+ index_js_1.kt.parameter.class('exceptionHandler', ctx.refs.apiExceptionHandler({ nullable: true }), {
293
+ annotations: [index_js_1.kt.annotation(index_js_1.kt.refs.spring.autowired(), [index_js_1.kt.argument.named('required', 'false')])],
294
+ accessModifier: 'private',
295
+ property: 'readonly',
296
+ }),
286
297
  ]),
287
298
  implements: [this.getApiInterfaceName(ctx, {})],
288
299
  members: this.getApiControllerMembers(ctx),
@@ -303,18 +314,21 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
303
314
  const delegateInterfaceName = this.getApiDelegateInterfaceName(ctx, {});
304
315
  const delegateProp = index_js_1.kt.property('delegate', {
305
316
  accessModifier: 'private',
306
- type: index_js_1.kt.reference(delegateInterfaceName),
317
+ default: (0, core_1.builderTemplate) `delegate ?: ${index_js_1.kt.object({ implements: [delegateInterfaceName] })}`,
307
318
  });
308
- const initBlock = index_js_1.kt.initBlock((0, core_1.appendValueGroup)([
309
- (0, core_1.builderTemplate) `this.delegate = ${index_js_1.kt.refs.java.optional.infer()}.ofNullable(delegate).orElse(object : ${delegateInterfaceName} {})`,
310
- ], '\n'));
311
319
  const getDelegateFun = index_js_1.kt.function('getDelegate', {
312
320
  override: true,
313
321
  returnType: delegateInterfaceName,
314
322
  singleExpression: true,
315
323
  body: index_js_1.kt.reference('delegate'),
316
324
  });
317
- return [delegateProp, initBlock, getDelegateFun];
325
+ const getExceptionHandlerFun = index_js_1.kt.function('getExceptionHandler', {
326
+ override: true,
327
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
328
+ singleExpression: true,
329
+ body: index_js_1.kt.reference('exceptionHandler'),
330
+ });
331
+ return [delegateProp, getDelegateFun, getExceptionHandlerFun];
318
332
  }
319
333
  // #endregion
320
334
  // #region API Delegate Interface
@@ -1,4 +1,6 @@
1
- import { type ApiService, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
1
+ import { type ApiService, type AppendValueGroup, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ import { KotlinFileBuilder } from '../../../file-builder.js';
2
4
  import { type KotlinServiceGeneratorOutput, type KotlinServicesGeneratorConfig, type KotlinServicesGeneratorContext, type KotlinServicesGeneratorInput, type KotlinServicesGeneratorOutput } from './models.js';
3
5
  import { type KotlinSpringControllerGenerator } from './spring-controller-generator.js';
4
6
  type Input = KotlinServicesGeneratorInput;
@@ -13,6 +15,10 @@ export declare class KotlinSpringControllersGenerator extends OpenApiServicesGen
13
15
  protected generateService(ctx: Context, service: ApiService): MaybePromise<ServiceOutput>;
14
16
  protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
15
17
  protected buildContext(context: OpenApiGeneratorContext<KotlinServicesGeneratorInput>, config?: Partial<Config> | undefined): Context;
18
+ protected generateAdditionalFiles(ctx: KotlinServicesGeneratorContext): void;
19
+ protected generateApiExceptionHandler(ctx: Context): void;
20
+ protected getApiExceptionHandlerFileContent(ctx: Context): AppendValueGroup<KotlinFileBuilder>;
21
+ protected getApiExceptionHandlerInterface(ctx: Context): kt.Interface<KotlinFileBuilder>;
16
22
  }
17
23
  export {};
18
24
  //# sourceMappingURL=spring-controllers-generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,kCAAkC,CAAC;AAE1C,KAAK,KAAK,GAAG,4BAA4B,CAAC;AAC1C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,MAAM,GAAG,6BAA6B,CAAC;AAC5C,KAAK,aAAa,GAAG,4BAA4B,CAAC;AAClD,KAAK,OAAO,GAAG,8BAA8B,CAAC;AAE9C,qBAAa,gCAAiC,SAAQ,qCAAqC,CACzF,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA+C;gBAE5E,uBAAuB,CAAC,EAAE,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC;IAMlF,SAAS,CAAC,UAAU,IAAI,MAAM;IAQ9B,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC;IAQzF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAI1F,SAAS,CAAC,YAAY,CACpB,OAAO,EAAE,uBAAuB,CAAC,4BAA4B,CAAC,EAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GACnC,OAAO;CAIX"}
1
+ {"version":3,"file":"spring-controllers-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-controllers/spring-controllers-generator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC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zF"}
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KotlinSpringControllersGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
4
6
  const core_1 = require("@goast/core");
7
+ const index_js_1 = require("../../../ast/index.js");
8
+ const file_builder_js_1 = require("../../../file-builder.js");
5
9
  const models_js_1 = require("./models.js");
10
+ const refs_js_1 = require("./refs.js");
6
11
  const spring_controller_generator_js_1 = require("./spring-controller-generator.js");
7
12
  class KotlinSpringControllersGenerator extends core_1.OpenApiServicesGenerationProviderBase {
8
13
  constructor(serviceGeneratorFactory) {
@@ -34,7 +39,42 @@ class KotlinSpringControllersGenerator extends core_1.OpenApiServicesGenerationP
34
39
  }
35
40
  buildContext(context, config) {
36
41
  context.data.services = context.data.services.filter((x) => x.name !== 'exclude-from-generation');
37
- return this.getProviderContext(context, config, models_js_1.defaultKotlinServicesGeneratorConfig);
42
+ const providerContext = this.getProviderContext(context, config, models_js_1.defaultKotlinServicesGeneratorConfig);
43
+ return Object.assign(providerContext, {
44
+ refs: (0, refs_js_1.getReferenceFactories)(providerContext.config),
45
+ });
46
+ }
47
+ generateAdditionalFiles(ctx) {
48
+ this.generateApiExceptionHandler(ctx);
49
+ }
50
+ generateApiExceptionHandler(ctx) {
51
+ var _a;
52
+ const packageName = (_a = ctx.refs.apiExceptionHandler.packageName) !== null && _a !== void 0 ? _a : ctx.config.packageName;
53
+ const dir = `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}`;
54
+ const fileName = `${ctx.refs.apiExceptionHandler.refName}.kt`;
55
+ console.log(`Generating Api Exception Handler to ${fileName}...`);
56
+ const builder = new file_builder_js_1.KotlinFileBuilder(packageName, ctx.config);
57
+ builder.append(this.getApiExceptionHandlerInterface(ctx));
58
+ fs_extra_1.default.writeFileSync(`${dir}/${fileName}`, builder.toString());
59
+ }
60
+ getApiExceptionHandlerFileContent(ctx) {
61
+ return (0, core_1.appendValueGroup)([this.getApiExceptionHandlerInterface(ctx)], '\n');
62
+ }
63
+ getApiExceptionHandlerInterface(ctx) {
64
+ return index_js_1.kt.interface(ctx.refs.apiExceptionHandler.refName, {
65
+ members: [
66
+ index_js_1.kt.function('handleApiException', {
67
+ doc: index_js_1.kt.doc('Handler for API exceptions.', [index_js_1.kt.docTag('return', 'Response entity.')]),
68
+ suspend: true,
69
+ parameters: [
70
+ index_js_1.kt.parameter('exception', index_js_1.kt.refs.throwable(), {
71
+ description: 'Exception that has been thrown by the API.',
72
+ }),
73
+ ],
74
+ returnType: index_js_1.kt.refs.spring.responseEntity(['*']),
75
+ }),
76
+ ],
77
+ });
38
78
  }
39
79
  }
40
80
  exports.KotlinSpringControllersGenerator = KotlinSpringControllersGenerator;
@@ -14,6 +14,7 @@ import { writeKtNode, writeKtNodes } from '../utils/write-kt-node.js';
14
14
  import { type KtAnnotation, ktAnnotation } from './annotation.js';
15
15
  import { type KtDoc, ktDoc } from './doc.js';
16
16
  import { type KtGenericParameter, ktGenericParameter } from './generic-parameter.js';
17
+ import { KtInterface } from './interface.js';
17
18
  import { type KtParameter, ktParameter } from './parameter.js';
18
19
  import type { KtType } from './types.js';
19
20
 
@@ -152,7 +153,8 @@ export class KtFunction<TBuilder extends SourceBuilder, TInjects extends string
152
153
  builder.append(this.inject.afterReturnType);
153
154
  }
154
155
 
155
- if (!this.abstract) {
156
+ const isInInterface = this.getParentNode(builder) instanceof KtInterface;
157
+ if (!this.abstract && (this.body || !isInInterface)) {
156
158
  builder.append(' ');
157
159
  if (this.singleExpression && this.body) {
158
160
  builder.append('= ');
@@ -13,6 +13,7 @@ export const boolean: KtReferenceFactory = ktReference.factory('Boolean', 'kotli
13
13
  export const lazyFun: KtGenericReferenceFactory<1> = ktReference.genericFactory<1>('lazy', 'kotlin');
14
14
  export const throws: KtReferenceFactory = ktReference.factory('Throws', 'kotlin');
15
15
  export const deprecated: KtReferenceFactory = ktReference.factory('Deprecated', 'kotlin');
16
+ export const throwable: KtReferenceFactory = ktReference.factory('Throwable', 'kotlin');
16
17
 
17
18
  // kotlin.collections
18
19
  export const list: KtGenericReferenceFactory<1> = ktReference.genericFactory<1>('List', 'kotlin.collections');
@@ -8,10 +8,11 @@ import type {
8
8
  import type { KotlinImport } from '../../../common-results.js';
9
9
  import { defaultKotlinGeneratorConfig, type KotlinGeneratorConfig } from '../../../config.js';
10
10
  import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
11
+ import type { getReferenceFactories } from './refs.js';
11
12
 
12
13
  export type KotlinServicesGeneratorConfig = KotlinGeneratorConfig & {
13
14
  packageName: string;
14
- packageSuffix: string | ((service: ApiService) => string);
15
+ packageSuffix: string | ((service: ApiService | null) => string);
15
16
 
16
17
  basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
17
18
  pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
@@ -54,12 +55,16 @@ export type KotlinServiceGeneratorOutput = {
54
55
  apiDelegate: KotlinImport;
55
56
  };
56
57
 
57
- export type KotlinServicesGeneratorContext = OpenApiServicesGenerationProviderContext<
58
- KotlinServicesGeneratorInput,
59
- KotlinServicesGeneratorOutput,
60
- KotlinServicesGeneratorConfig,
61
- KotlinServiceGeneratorOutput
62
- >;
58
+ export type KotlinServicesGeneratorContext =
59
+ & OpenApiServicesGenerationProviderContext<
60
+ KotlinServicesGeneratorInput,
61
+ KotlinServicesGeneratorOutput,
62
+ KotlinServicesGeneratorConfig,
63
+ KotlinServiceGeneratorOutput
64
+ >
65
+ & {
66
+ refs: ReturnType<typeof getReferenceFactories>;
67
+ };
63
68
 
64
69
  export type KotlinServiceGeneratorContext = KotlinServicesGeneratorContext & {
65
70
  service: ApiService;
@@ -0,0 +1,17 @@
1
+ import { toCasing } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ import type { KotlinServicesGeneratorConfig } from './models.js';
4
+
5
+ export function getReferenceFactories(options: KotlinServicesGeneratorConfig): {
6
+ apiExceptionHandler: kt.ReferenceFactory;
7
+ } {
8
+ const packageSuffix = typeof options.packageSuffix === 'string' ? options.packageSuffix : options.packageSuffix(null);
9
+ const packageName = options.packageName + packageSuffix;
10
+
11
+ return {
12
+ apiExceptionHandler: kt.reference.factory(
13
+ toCasing('ApiExceptionHandler', options.typeNameCasing),
14
+ packageName,
15
+ ),
16
+ };
17
+ }
@@ -105,6 +105,11 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
105
105
  implements: [delegateInterfaceName],
106
106
  }),
107
107
  }),
108
+ kt.function('getExceptionHandler', {
109
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
110
+ singleExpression: true,
111
+ body: kt.toNode(null),
112
+ }),
108
113
  );
109
114
 
110
115
  ctx.service.endpoints.forEach((endpoint) => {
@@ -131,9 +136,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
131
136
  suspend: true,
132
137
  annotations: this.getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint),
133
138
  parameters: parameters.map((parameter) => this.getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter)),
134
- returnType: ctx.config.strictResponseEntities
135
- ? kt.reference(this.getApiResponseEntityName(ctx, { endpoint }), null, { generics: ['*'] })
136
- : kt.refs.spring.responseEntity([this.getResponseType(ctx, { endpoint })]),
139
+ returnType: kt.refs.spring.responseEntity(['*']),
137
140
  body: this.getApiInterfaceEndpointMethodBody(ctx, endpoint, parameters),
138
141
  });
139
142
  }
@@ -307,12 +310,16 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
307
310
  ): AppendValueGroup<Builder> {
308
311
  return appendValueGroup(
309
312
  [
310
- s`return ${
313
+ s`try {${s.indent`
314
+ return ${
311
315
  kt.call(
312
316
  [kt.call(kt.reference('getDelegate'), []), toCasing(endpoint.name, ctx.config.functionNameCasing)],
313
317
  parameters.map((x) => toCasing(x.name, ctx.config.parameterNameCasing)),
314
318
  )
315
- }`,
319
+ }`}
320
+ } catch (e: ${kt.refs.throwable()}) {${s.indent`
321
+ return getExceptionHandler()?.handleApiException(e) ?: throw e`}
322
+ }`,
316
323
  ],
317
324
  '\n',
318
325
  );
@@ -427,6 +434,15 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
427
434
  annotations: [kt.annotation(kt.refs.spring.autowired(), [kt.argument.named('required', 'false')])],
428
435
  },
429
436
  ),
437
+ kt.parameter.class(
438
+ 'exceptionHandler',
439
+ ctx.refs.apiExceptionHandler({ nullable: true }),
440
+ {
441
+ annotations: [kt.annotation(kt.refs.spring.autowired(), [kt.argument.named('required', 'false')])],
442
+ accessModifier: 'private',
443
+ property: 'readonly',
444
+ },
445
+ ),
430
446
  ]),
431
447
  implements: [this.getApiInterfaceName(ctx, {})],
432
448
  members: this.getApiControllerMembers(ctx),
@@ -452,18 +468,9 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
452
468
 
453
469
  const delegateProp = kt.property<Builder>('delegate', {
454
470
  accessModifier: 'private',
455
- type: kt.reference(delegateInterfaceName),
471
+ default: s`delegate ?: ${kt.object({ implements: [delegateInterfaceName] })}`,
456
472
  });
457
473
 
458
- const initBlock = kt.initBlock<Builder>(
459
- appendValueGroup(
460
- [
461
- s`this.delegate = ${kt.refs.java.optional.infer()}.ofNullable(delegate).orElse(object : ${delegateInterfaceName} {})`,
462
- ],
463
- '\n',
464
- ),
465
- );
466
-
467
474
  const getDelegateFun = kt.function<Builder>('getDelegate', {
468
475
  override: true,
469
476
  returnType: delegateInterfaceName,
@@ -471,7 +478,14 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
471
478
  body: kt.reference('delegate'),
472
479
  });
473
480
 
474
- return [delegateProp, initBlock, getDelegateFun];
481
+ const getExceptionHandlerFun = kt.function<Builder>('getExceptionHandler', {
482
+ override: true,
483
+ returnType: ctx.refs.apiExceptionHandler({ nullable: true }),
484
+ singleExpression: true,
485
+ body: kt.reference('exceptionHandler'),
486
+ });
487
+
488
+ return [delegateProp, getDelegateFun, getExceptionHandlerFun];
475
489
  }
476
490
  // #endregion
477
491
 
@@ -1,11 +1,18 @@
1
+
2
+ import fs from 'fs-extra';
3
+
1
4
  import {
2
5
  type ApiService,
6
+ type AppendValueGroup,
7
+ appendValueGroup,
3
8
  Factory,
4
9
  type MaybePromise,
5
10
  type OpenApiGeneratorContext,
6
11
  OpenApiServicesGenerationProviderBase,
7
12
  } from '@goast/core';
8
13
 
14
+ import { kt } from '../../../ast/index.js';
15
+ import { KotlinFileBuilder } from '../../../file-builder.js';
9
16
  import {
10
17
  defaultKotlinServicesGeneratorConfig,
11
18
  type KotlinServiceGeneratorOutput,
@@ -14,6 +21,7 @@ import {
14
21
  type KotlinServicesGeneratorInput,
15
22
  type KotlinServicesGeneratorOutput,
16
23
  } from './models.js';
24
+ import { getReferenceFactories } from './refs.js';
17
25
  import {
18
26
  DefaultKotlinSpringControllerGenerator,
19
27
  type KotlinSpringControllerGenerator,
@@ -65,6 +73,45 @@ export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationP
65
73
  config?: Partial<Config> | undefined,
66
74
  ): Context {
67
75
  context.data.services = context.data.services.filter((x) => x.name !== 'exclude-from-generation');
68
- return this.getProviderContext(context, config, defaultKotlinServicesGeneratorConfig);
76
+ const providerContext = this.getProviderContext(context, config, defaultKotlinServicesGeneratorConfig);
77
+ return Object.assign(providerContext, {
78
+ refs: getReferenceFactories(providerContext.config),
79
+ });
80
+ }
81
+
82
+ protected override generateAdditionalFiles(ctx: KotlinServicesGeneratorContext): void {
83
+ this.generateApiExceptionHandler(ctx);
84
+ }
85
+
86
+ protected generateApiExceptionHandler(ctx: Context): void {
87
+ const packageName = ctx.refs.apiExceptionHandler.packageName ?? ctx.config.packageName;
88
+ const dir = `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}`;
89
+ const fileName = `${ctx.refs.apiExceptionHandler.refName}.kt`;
90
+ console.log(`Generating Api Exception Handler to ${fileName}...`);
91
+
92
+ const builder = new KotlinFileBuilder(packageName, ctx.config);
93
+ builder.append(this.getApiExceptionHandlerInterface(ctx));
94
+ fs.writeFileSync(`${dir}/${fileName}`, builder.toString());
95
+ }
96
+
97
+ protected getApiExceptionHandlerFileContent(ctx: Context): AppendValueGroup<KotlinFileBuilder> {
98
+ return appendValueGroup([this.getApiExceptionHandlerInterface(ctx)], '\n');
99
+ }
100
+
101
+ protected getApiExceptionHandlerInterface(ctx: Context): kt.Interface<KotlinFileBuilder> {
102
+ return kt.interface(ctx.refs.apiExceptionHandler.refName, {
103
+ members: [
104
+ kt.function('handleApiException', {
105
+ doc: kt.doc('Handler for API exceptions.', [kt.docTag('return', 'Response entity.')]),
106
+ suspend: true,
107
+ parameters: [
108
+ kt.parameter('exception', kt.refs.throwable(), {
109
+ description: 'Exception that has been thrown by the API.',
110
+ }),
111
+ ],
112
+ returnType: kt.refs.spring.responseEntity(['*']),
113
+ }),
114
+ ],
115
+ });
69
116
  }
70
117
  }