@goast/kotlin 0.4.18-beta5 → 0.4.18-springwebclient1

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 (98) hide show
  1. package/assets/client/spring-reactive-web-clients/ApiRequestFile.kt +33 -0
  2. package/esm/src/ast/nodes/call.d.ts.map +1 -1
  3. package/esm/src/ast/nodes/call.js +11 -1
  4. package/esm/src/ast/nodes/lambda-type.d.ts +2 -0
  5. package/esm/src/ast/nodes/lambda-type.d.ts.map +1 -1
  6. package/esm/src/ast/nodes/lambda-type.js +11 -4
  7. package/esm/src/ast/nodes/lambda.d.ts.map +1 -1
  8. package/esm/src/ast/nodes/lambda.js +10 -5
  9. package/esm/src/ast/references/index.d.ts +2 -0
  10. package/esm/src/ast/references/index.d.ts.map +1 -1
  11. package/esm/src/ast/references/index.js +2 -0
  12. package/esm/src/ast/references/java.d.ts +1 -0
  13. package/esm/src/ast/references/java.d.ts.map +1 -1
  14. package/esm/src/ast/references/java.js +1 -0
  15. package/esm/src/ast/references/kotlinx.d.ts +5 -0
  16. package/esm/src/ast/references/kotlinx.d.ts.map +1 -0
  17. package/esm/src/ast/references/kotlinx.js +6 -0
  18. package/esm/src/ast/references/spring-reactive.d.ts +9 -0
  19. package/esm/src/ast/references/spring-reactive.d.ts.map +1 -0
  20. package/esm/src/ast/references/spring-reactive.js +10 -0
  21. package/esm/src/ast/references/spring.d.ts +4 -0
  22. package/esm/src/ast/references/spring.d.ts.map +1 -1
  23. package/esm/src/ast/references/spring.js +6 -0
  24. package/esm/src/generators/index.d.ts +1 -0
  25. package/esm/src/generators/index.d.ts.map +1 -1
  26. package/esm/src/generators/index.js +1 -0
  27. package/esm/src/generators/services/okhttp3-clients/args.d.ts +4 -0
  28. package/esm/src/generators/services/okhttp3-clients/args.d.ts.map +1 -1
  29. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +2 -2
  30. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  31. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +18 -20
  32. package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts +99 -0
  33. package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -0
  34. package/esm/src/generators/services/spring-reactive-web-clients/args.js +1 -0
  35. package/esm/src/generators/services/spring-reactive-web-clients/index.d.ts +5 -0
  36. package/esm/src/generators/services/spring-reactive-web-clients/index.d.ts.map +1 -0
  37. package/esm/src/generators/services/spring-reactive-web-clients/index.js +4 -0
  38. package/esm/src/generators/services/spring-reactive-web-clients/models.d.ts +34 -0
  39. package/esm/src/generators/services/spring-reactive-web-clients/models.d.ts.map +1 -0
  40. package/esm/src/generators/services/spring-reactive-web-clients/models.js +8 -0
  41. package/esm/src/generators/services/spring-reactive-web-clients/refs.d.ts +5 -0
  42. package/esm/src/generators/services/spring-reactive-web-clients/refs.d.ts.map +1 -0
  43. package/esm/src/generators/services/spring-reactive-web-clients/refs.js +8 -0
  44. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +46 -0
  45. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -0
  46. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +383 -0
  47. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts +23 -0
  48. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts.map +1 -0
  49. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.js +79 -0
  50. package/package.json +2 -5
  51. package/script/src/ast/nodes/call.d.ts.map +1 -1
  52. package/script/src/ast/nodes/call.js +11 -1
  53. package/script/src/ast/nodes/lambda-type.d.ts +2 -0
  54. package/script/src/ast/nodes/lambda-type.d.ts.map +1 -1
  55. package/script/src/ast/nodes/lambda-type.js +11 -4
  56. package/script/src/ast/nodes/lambda.d.ts.map +1 -1
  57. package/script/src/ast/nodes/lambda.js +10 -5
  58. package/script/src/ast/references/index.d.ts +2 -0
  59. package/script/src/ast/references/index.d.ts.map +1 -1
  60. package/script/src/ast/references/index.js +3 -1
  61. package/script/src/ast/references/java.d.ts +1 -0
  62. package/script/src/ast/references/java.d.ts.map +1 -1
  63. package/script/src/ast/references/java.js +2 -1
  64. package/script/src/ast/references/kotlinx.d.ts +5 -0
  65. package/script/src/ast/references/kotlinx.d.ts.map +1 -0
  66. package/script/src/ast/references/kotlinx.js +9 -0
  67. package/script/src/ast/references/spring-reactive.d.ts +9 -0
  68. package/script/src/ast/references/spring-reactive.d.ts.map +1 -0
  69. package/script/src/ast/references/spring-reactive.js +13 -0
  70. package/script/src/ast/references/spring.d.ts +4 -0
  71. package/script/src/ast/references/spring.d.ts.map +1 -1
  72. package/script/src/ast/references/spring.js +7 -1
  73. package/script/src/generators/index.d.ts +1 -0
  74. package/script/src/generators/index.d.ts.map +1 -1
  75. package/script/src/generators/index.js +1 -0
  76. package/script/src/generators/services/okhttp3-clients/args.d.ts +4 -0
  77. package/script/src/generators/services/okhttp3-clients/args.d.ts.map +1 -1
  78. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +2 -2
  79. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  80. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +18 -20
  81. package/script/src/generators/services/spring-reactive-web-clients/args.d.ts +99 -0
  82. package/script/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -0
  83. package/script/src/generators/services/spring-reactive-web-clients/args.js +2 -0
  84. package/script/src/generators/services/spring-reactive-web-clients/index.d.ts +5 -0
  85. package/script/src/generators/services/spring-reactive-web-clients/index.d.ts.map +1 -0
  86. package/script/src/generators/services/spring-reactive-web-clients/index.js +8 -0
  87. package/script/src/generators/services/spring-reactive-web-clients/models.d.ts +34 -0
  88. package/script/src/generators/services/spring-reactive-web-clients/models.d.ts.map +1 -0
  89. package/script/src/generators/services/spring-reactive-web-clients/models.js +11 -0
  90. package/script/src/generators/services/spring-reactive-web-clients/refs.d.ts +5 -0
  91. package/script/src/generators/services/spring-reactive-web-clients/refs.d.ts.map +1 -0
  92. package/script/src/generators/services/spring-reactive-web-clients/refs.js +11 -0
  93. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +46 -0
  94. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -0
  95. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +388 -0
  96. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts +23 -0
  97. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts.map +1 -0
  98. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.js +84 -0
@@ -0,0 +1,34 @@
1
+ import type { ApiEndpoint, ApiService, DefaultGenerationProviderConfig, OpenApiServicesGenerationProviderContext } from '@goast/core';
2
+ import type { KotlinImport } from '../../../common-results.js';
3
+ import { type KotlinGeneratorConfig } from '../../../config.js';
4
+ import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
5
+ import { getReferenceFactories } from './refs.js';
6
+ export type KotlinSpringReactiveWebClientsGeneratorConfig = KotlinGeneratorConfig & {
7
+ packageName: string;
8
+ packageSuffix: string | ((service?: ApiService) => string);
9
+ infrastructurePackageName: string | {
10
+ mode: 'append-package-name' | 'append-full-package-name' | 'replace';
11
+ value: string;
12
+ };
13
+ basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
14
+ pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
15
+ serializerJsonInclude: 'always' | 'non-null' | 'non-absent' | 'non-default' | 'non-empty' | 'use-defaults';
16
+ };
17
+ export declare const defaultKotlinSpringReactiveWebClientsGeneratorConfig: DefaultGenerationProviderConfig<KotlinSpringReactiveWebClientsGeneratorConfig>;
18
+ export type KotlinSpringReactiveWebClientsGeneratorInput = KotlinModelsGeneratorOutput;
19
+ export type KotlinSpringReactiveWebClientsGeneratorOutput = {
20
+ kotlin: {
21
+ clients: {
22
+ [serviceId: string]: KotlinSpringReactiveWebClientGeneratorOutput;
23
+ };
24
+ };
25
+ };
26
+ export type KotlinSpringReactiveWebClientGeneratorOutput = KotlinImport;
27
+ export type KotlinSpringReactiveWebClientsGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinSpringReactiveWebClientsGeneratorInput, KotlinSpringReactiveWebClientsGeneratorOutput, KotlinSpringReactiveWebClientsGeneratorConfig, KotlinSpringReactiveWebClientGeneratorOutput> & {
28
+ infrastructurePackageName: string;
29
+ refs: ReturnType<typeof getReferenceFactories>;
30
+ };
31
+ export type KotlinSpringReactiveWebClientGeneratorContext = KotlinSpringReactiveWebClientsGeneratorContext & {
32
+ service: ApiService;
33
+ };
34
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/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,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,6CAA6C,GAAG,qBAAqB,GAAG;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IAC3D,yBAAyB,EACrB,MAAM,GACN;QAAE,IAAI,EAAE,qBAAqB,GAAG,0BAA0B,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAE5F,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;IAC1E,qBAAqB,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,cAAc,CAAC;CAC5G,CAAC;AAEF,eAAO,MAAM,oDAAoD,EAAE,+BAA+B,CAChG,6CAA6C,CAQ9C,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG,2BAA2B,CAAC;AAEvF,MAAM,MAAM,6CAA6C,GAAG;IAC1D,MAAM,EAAE;QACN,OAAO,EAAE;YACP,CAAC,SAAS,EAAE,MAAM,GAAG,4CAA4C,CAAC;SACnE,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG,YAAY,CAAC;AAExE,MAAM,MAAM,8CAA8C,GACtD,wCAAwC,CACxC,4CAA4C,EAC5C,6CAA6C,EAC7C,6CAA6C,EAC7C,4CAA4C,CAC7C,GACC;IACA,yBAAyB,EAAE,MAAM,CAAC;IAClC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEJ,MAAM,MAAM,6CAA6C,GAAG,8CAA8C,GAAG;IAC3G,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { defaultKotlinGeneratorConfig } from '../../../config.js';
2
+ export const defaultKotlinSpringReactiveWebClientsGeneratorConfig = {
3
+ ...defaultKotlinGeneratorConfig,
4
+ packageName: 'com.openapi.generated',
5
+ packageSuffix: '.api.client',
6
+ infrastructurePackageName: { mode: 'append-full-package-name', value: '.infrastructure' },
7
+ serializerJsonInclude: 'non-absent',
8
+ };
@@ -0,0 +1,5 @@
1
+ import { kt } from '../../../ast/index.js';
2
+ export declare function getReferenceFactories(infrastructurePackageName: string): {
3
+ apiRequestFile: kt.ReferenceFactory;
4
+ };
5
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAG3C,wBAAgB,qBAAqB,CAAC,yBAAyB,EAAE,MAAM,GAAG;IACxE,cAAc,EAAE,EAAE,CAAC,gBAAgB,CAAC;CACrC,CAKA"}
@@ -0,0 +1,8 @@
1
+ import { kt } from '../../../ast/index.js';
2
+ // See packages/kotlin/assets/client/spring-reactive-web-clients for reference
3
+ export function getReferenceFactories(infrastructurePackageName) {
4
+ return {
5
+ // ApiRequestFile.kt
6
+ apiRequestFile: kt.reference.factory('ApiRequestFile', infrastructurePackageName),
7
+ };
8
+ }
@@ -0,0 +1,46 @@
1
+ import { type ApiSchema, type AppendValueGroup, type MaybePromise, SourceBuilder } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ import { KotlinFileBuilder } from '../../../file-builder.js';
4
+ import type { ApiParameterWithMultipartInfo } from '../../../types.js';
5
+ import { KotlinFileGenerator } from '../../file-generator.js';
6
+ import type { DefaultKotlinSpringReactiveWebClientGeneratorArgs as Args } from './index.js';
7
+ import type { KotlinSpringReactiveWebClientGeneratorContext, KotlinSpringReactiveWebClientGeneratorOutput } from './models.js';
8
+ type Context = KotlinSpringReactiveWebClientGeneratorContext;
9
+ type Output = KotlinSpringReactiveWebClientGeneratorOutput;
10
+ type Builder = KotlinFileBuilder;
11
+ export interface KotlinSpringReactiveWebClientGenerator<TOutput extends Output = Output> {
12
+ generate(ctx: Context): MaybePromise<TOutput>;
13
+ }
14
+ export declare class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGenerator<Context, Output> implements KotlinSpringReactiveWebClientGenerator {
15
+ generate(ctx: Context): MaybePromise<Output>;
16
+ protected getClientFileContent(ctx: Context, args: Args.GetClientFileContent): AppendValueGroup<Builder>;
17
+ protected getRequestsObject(ctx: Context, args: Args.GetRequestsObject): kt.Object<Builder>;
18
+ protected getEndpointMembers(ctx: Context, args: Args.GetEndpointMembers): kt.ObjectMember<Builder>[];
19
+ protected getEndpointFunctionName(ctx: Context, args: Args.GetEndpointFunctionName): string;
20
+ protected getEndpointFunction(ctx: Context, args: Args.GetEndpointFunction): kt.Function<Builder>;
21
+ protected getEndpointFunctionBody(ctx: Context, args: Args.GetEndpointFunctionBody): AppendValueGroup<Builder>;
22
+ protected getEndpointFunctionWithHandler(ctx: Context, args: Args.GetEndpointFunctionWithHandler): kt.Function<Builder>;
23
+ protected getEndpointFunctionWithHandlerBody(ctx: Context, args: Args.GetEndpointFunctionWithHandlerBody): AppendValueGroup<Builder>;
24
+ protected getEndpointRequestFunctionName(ctx: Context, args: Args.GetEndpointRequestFunctionName): string;
25
+ protected getEndpointRequestFunction(ctx: Context, args: Args.GetEndpointRequestFunction): kt.Function<Builder>;
26
+ protected getEndpointRequestFunctionBody(ctx: Context, args: Args.GetEndpointRequestFunctionBody): AppendValueGroup<Builder>;
27
+ protected getEndpointUriFunctionName(ctx: Context, args: Args.GetEndpointUriFunctionName): string;
28
+ protected getEndpointUriFunction(ctx: Context, args: Args.GetEndpointUriFunction): kt.Function<Builder>;
29
+ protected getEndpointUriFunctionBody(ctx: Context, args: Args.GetEndpointUriFunctionBody): AppendValueGroup<Builder>;
30
+ protected getParameterToString(ctx: Context, args: Args.GetParameterToString): kt.Value<Builder>;
31
+ protected getParameterType(ctx: Context, args: Args.GetParameterType): kt.Type<Builder>;
32
+ protected getParameterDefaultValue(ctx: Context, args: Args.GetParameterDefaultValue): kt.Value<Builder> | null;
33
+ protected getTypeUsage(ctx: Context, args: Args.GetTypeUsage<Builder>): kt.Type<Builder>;
34
+ protected getPackageName(ctx: Context, args: Args.GetPackageName): string;
35
+ protected getResponseSchema(_ctx: Context, args: Args.GetResponseSchema): ApiSchema | undefined;
36
+ protected getSchemaType(ctx: Context, args: Args.GetSchemaType): kt.Reference<SourceBuilder> | undefined;
37
+ protected getAllParameters(ctx: Context, args: Args.GetAllParameters): ApiParameterWithMultipartInfo[];
38
+ protected getRequestBodyParamName(ctx: Context, args: Args.GetRequestBodyParamName): string;
39
+ protected getBasePath(ctx: Context, _args: Args.GetBasePath): string;
40
+ protected getEndpointPath(ctx: Context, args: Args.GetEndpointPath): string;
41
+ protected getFilePath(ctx: Context, args: Args.GetFilePath): string;
42
+ protected getRequestsObjectName(ctx: Context, args: Args.GetRequestsObjectName): string;
43
+ private createApiParameter;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=spring-reactive-web-client-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-reactive-web-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAEjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,iDAAiD,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EACV,6CAA6C,EAC7C,4CAA4C,EAC7C,MAAM,aAAa,CAAC;AAErB,KAAK,OAAO,GAAG,6CAA6C,C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2
+ import fs from 'fs-extra';
3
+ import { appendValueGroup, builderTemplate as s, createOverwriteProxy, resolveAnyOfAndAllOf, SourceBuilder, toCasing, } from '@goast/core';
4
+ import { kt } from '../../../ast/index.js';
5
+ import { KotlinFileBuilder } from '../../../file-builder.js';
6
+ import { modifyString } from '../../../utils.js';
7
+ import { KotlinFileGenerator } from '../../file-generator.js';
8
+ export class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGenerator {
9
+ generate(ctx) {
10
+ const typeName = this.getRequestsObjectName(ctx, {});
11
+ const packageName = this.getPackageName(ctx, {});
12
+ const filePath = this.getFilePath(ctx, { packageName });
13
+ fs.ensureDirSync(dirname(filePath));
14
+ console.log(`Generating client for service ${ctx.service.name} to ${filePath}...`);
15
+ const builder = new KotlinFileBuilder(packageName, ctx.config);
16
+ builder.append(this.getClientFileContent(ctx, {}));
17
+ fs.writeFileSync(filePath, builder.toString());
18
+ return { typeName, packageName };
19
+ }
20
+ // deno-lint-ignore no-unused-vars
21
+ getClientFileContent(ctx, args) {
22
+ return appendValueGroup([this.getRequestsObject(ctx, {})], '\n\n');
23
+ }
24
+ // deno-lint-ignore no-unused-vars
25
+ getRequestsObject(ctx, args) {
26
+ return kt.object({
27
+ name: this.getRequestsObjectName(ctx, {}),
28
+ members: ctx.service.endpoints.flatMap((endpoint) => this.getEndpointMembers(ctx, { endpoint, parameters: this.getAllParameters(ctx, { endpoint }) })),
29
+ });
30
+ }
31
+ getEndpointMembers(ctx, args) {
32
+ const { endpoint, parameters } = args;
33
+ const responseSchema = this.getResponseSchema(ctx, { endpoint });
34
+ return [
35
+ this.getEndpointFunction(ctx, { endpoint, parameters, responseSchema }),
36
+ this.getEndpointFunctionWithHandler(ctx, { endpoint, parameters, responseSchema }),
37
+ this.getEndpointUriFunction(ctx, { endpoint, parameters }),
38
+ this.getEndpointRequestFunction(ctx, { endpoint, parameters, responseSchema }),
39
+ ];
40
+ }
41
+ getEndpointFunctionName(ctx, args) {
42
+ const { endpoint } = args;
43
+ return toCasing(endpoint.name, ctx.config.functionNameCasing);
44
+ }
45
+ getEndpointFunction(ctx, args) {
46
+ const { endpoint, parameters, responseSchema } = args;
47
+ const functionName = this.getEndpointFunctionName(ctx, { endpoint });
48
+ return kt.function(functionName, {
49
+ doc: kt.doc(endpoint.description),
50
+ suspend: true,
51
+ receiverType: kt.refs.springReactive.webClient(),
52
+ parameters: parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
53
+ returnType: this.getTypeUsage(ctx, { schema: responseSchema, fallback: kt.refs.unit() }),
54
+ body: this.getEndpointFunctionBody(ctx, { endpoint, parameters, responseSchema }),
55
+ });
56
+ }
57
+ getEndpointFunctionBody(ctx, args) {
58
+ const { endpoint, parameters, responseSchema } = args;
59
+ const result = appendValueGroup([], '\n');
60
+ const requestFunctionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
61
+ const parameterNames = parameters.map((p) => toCasing(p.name, ctx.config.parameterNameCasing));
62
+ const call = kt.call([
63
+ 'this',
64
+ kt.call(requestFunctionName, parameterNames),
65
+ kt.call('retrieve', []),
66
+ responseSchema
67
+ ? kt.call(kt.refs.springReactive.awaitBody([
68
+ this.getTypeUsage(ctx, { schema: responseSchema, fallback: kt.refs.unit() }),
69
+ ]), [])
70
+ : kt.call(kt.refs.springReactive.awaitBodilessEntity(), []),
71
+ ]);
72
+ if (responseSchema) {
73
+ result.values.push(s `return ${call}`);
74
+ }
75
+ else {
76
+ result.values.push(call);
77
+ }
78
+ return result;
79
+ }
80
+ getEndpointFunctionWithHandler(ctx, args) {
81
+ const { endpoint, parameters, responseSchema } = args;
82
+ const functionName = this.getEndpointFunctionName(ctx, { endpoint });
83
+ return kt.function(functionName, {
84
+ doc: kt.doc(endpoint.description),
85
+ suspend: true,
86
+ generics: [kt.genericParameter('T')],
87
+ receiverType: kt.refs.springReactive.webClient(),
88
+ parameters: [
89
+ ...parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
90
+ kt.parameter('responseHandler', kt.lambdaType([kt.refs.springReactive.clientResponse()], 'T', { suspend: true })),
91
+ ],
92
+ returnType: 'T',
93
+ body: this.getEndpointFunctionWithHandlerBody(ctx, { endpoint, parameters, responseSchema }),
94
+ });
95
+ }
96
+ getEndpointFunctionWithHandlerBody(ctx, args) {
97
+ const { endpoint, parameters } = args;
98
+ const result = appendValueGroup([], '\n');
99
+ const requestFunctionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
100
+ const parameterNames = parameters.map((p) => toCasing(p.name, ctx.config.parameterNameCasing));
101
+ result.values.push(s `return ${kt.call([
102
+ kt.call(['this', requestFunctionName], parameterNames),
103
+ kt.call(['exchangeToMono'], [
104
+ kt.lambda([], kt.call(kt.refs.kotlinx.mono.infer(), [kt.lambda([], 'responseHandler(it)', { singleline: true })]), { singleline: true }),
105
+ ]),
106
+ kt.call([kt.refs.kotlinx.awaitFirstOrNull.infer()], []),
107
+ ])} as T`);
108
+ return result;
109
+ }
110
+ getEndpointRequestFunctionName(ctx, args) {
111
+ const { endpoint } = args;
112
+ return toCasing(`${this.getEndpointFunctionName(ctx, { endpoint })}_request`, ctx.config.functionNameCasing);
113
+ }
114
+ getEndpointRequestFunction(ctx, args) {
115
+ const { endpoint, parameters, responseSchema } = args;
116
+ const functionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
117
+ return kt.function(functionName, {
118
+ doc: kt.doc(endpoint.description),
119
+ receiverType: kt.refs.springReactive.webClient(),
120
+ parameters: parameters.map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
121
+ returnType: kt.refs.springReactive.requestHeadersSpec(['*']),
122
+ body: this.getEndpointRequestFunctionBody(ctx, { endpoint, parameters, responseSchema }),
123
+ });
124
+ }
125
+ getEndpointRequestFunctionBody(ctx, args) {
126
+ var _a, _b;
127
+ const { endpoint, parameters, responseSchema } = args;
128
+ const result = appendValueGroup([], '\n');
129
+ const callChain = [];
130
+ callChain.push(s `return this.method(${kt.refs.spring.httpMethod()}.${endpoint.method.toUpperCase()})`, kt.call('uri', [kt.call([this.getEndpointUriFunctionName(ctx, { endpoint })], parameters.filter((p) => p.target === 'path' || p.target === 'query').map((p) => toCasing(p.name, ctx.config.parameterNameCasing)))]));
131
+ if (responseSchema) {
132
+ callChain.push(s `accept(${kt.refs.spring.mediaType()}.APPLICATION_JSON)`);
133
+ }
134
+ if (((_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0]) !== undefined) {
135
+ callChain.push(s `contentType(${kt.refs.spring.mediaType()}.parseMediaType(${kt.string(endpoint.requestBody.content[0].type)}))`);
136
+ }
137
+ if ((_b = endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0]) {
138
+ if (endpoint.requestBody.content[0].type === 'multipart/form-data') {
139
+ callChain.push(kt.call('body', [
140
+ kt.call([kt.refs.springReactive.bodyInserters(), 'fromMultipartData'], [
141
+ kt.call([
142
+ kt.call(kt.refs.spring.multipartBodyBuilder(), []),
143
+ kt.call('apply', [
144
+ kt.lambda([], appendValueGroup(parameters.filter((x) => x.multipart).map((p) => {
145
+ var _a, _b, _c;
146
+ const parameterName = toCasing(p.name, ctx.config.parameterNameCasing);
147
+ if ((_a = p.multipart) === null || _a === void 0 ? void 0 : _a.isFile) {
148
+ return kt.call([
149
+ p.required && !((_b = p.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? parameterName : `${parameterName}?`,
150
+ 'addToBuilder',
151
+ ], ['this']);
152
+ }
153
+ else {
154
+ const call = kt.call([
155
+ kt.call('part', [kt.string(p.multipart.name), parameterName]),
156
+ kt.call('contentType', [
157
+ kt.call([
158
+ kt.refs.spring.mediaType(),
159
+ 'APPLICATION_JSON',
160
+ ]),
161
+ ]),
162
+ ]);
163
+ return p.required && !((_c = p.schema) === null || _c === void 0 ? void 0 : _c.nullable) ? call : kt.call([`${parameterName}?`, 'also'], [
164
+ kt.lambda([parameterName], call, { singleline: true }),
165
+ ]);
166
+ }
167
+ }), '\n')),
168
+ ]),
169
+ 'build',
170
+ ], []),
171
+ ]),
172
+ ]));
173
+ }
174
+ else {
175
+ const bodySchema = endpoint.requestBody.content[0].schema;
176
+ const parameterName = this.getRequestBodyParamName(ctx, { endpoint });
177
+ const call = kt.call('bodyValue', [
178
+ toCasing(parameterName, ctx.config.parameterNameCasing),
179
+ ]);
180
+ callChain.push(endpoint.requestBody.required && !(bodySchema === null || bodySchema === void 0 ? void 0 : bodySchema.nullable) ? call : kt.call('apply', [
181
+ kt.lambda([], kt.call([`${parameterName}?`, 'also'], [kt.lambda([parameterName], call, { singleline: true })]), { singleline: true }),
182
+ ]));
183
+ }
184
+ }
185
+ if (parameters.some((x) => x.target === 'header')) {
186
+ callChain.push(kt.call('headers', [
187
+ kt.lambda(['headers'], appendValueGroup(parameters.filter((x) => x.target === 'header').map((p) => {
188
+ var _a;
189
+ const parameterName = toCasing(p.name, ctx.config.parameterNameCasing);
190
+ const toString = this.getParameterToString(ctx, { endpoint, parameter: p });
191
+ return p.required && !((_a = p.schema) === null || _a === void 0 ? void 0 : _a.nullable)
192
+ ? kt.call(['headers', 'add'], [kt.string(p.name), parameterName + toString])
193
+ : kt.call([`${parameterName}?`, 'also'], [
194
+ kt.lambda([], kt.call(['headers', 'add'], [kt.string(p.name), 'it' + toString]), {
195
+ singleline: true,
196
+ }),
197
+ ]);
198
+ }), '\n')),
199
+ ]));
200
+ }
201
+ result.values.push(kt.call(callChain));
202
+ return result;
203
+ }
204
+ getEndpointUriFunctionName(ctx, args) {
205
+ const { endpoint } = args;
206
+ return toCasing(`${this.getEndpointFunctionName(ctx, { endpoint })}_uri`, ctx.config.functionNameCasing);
207
+ }
208
+ getEndpointUriFunction(ctx, args) {
209
+ const { endpoint, parameters } = args;
210
+ const functionName = this.getEndpointUriFunctionName(ctx, { endpoint });
211
+ return kt.function(functionName, {
212
+ parameters: parameters.filter((p) => p.target === 'path' || p.target === 'query').map((parameter) => kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
213
+ returnType: kt.refs.string(),
214
+ body: this.getEndpointUriFunctionBody(ctx, { endpoint, parameters }),
215
+ });
216
+ }
217
+ getEndpointUriFunctionBody(ctx, args) {
218
+ const { endpoint } = args;
219
+ const result = appendValueGroup([], '\n');
220
+ const callChain = [];
221
+ callChain.push(s `${kt.refs.spring.uriComponentsBuilder()}.fromPath(${kt.string(this.getEndpointPath(ctx, { endpoint }))})`);
222
+ if (endpoint.parameters.some((x) => x.target === 'query')) {
223
+ callChain.push(kt.call('apply', [kt.lambda([], appendValueGroup(endpoint.parameters.filter((x) => x.target === 'query').map((p) => {
224
+ var _a;
225
+ const parameterName = toCasing(p.name, ctx.config.parameterNameCasing);
226
+ const toString = this.getParameterToString(ctx, { endpoint, parameter: p });
227
+ return p.required && !((_a = p.schema) === null || _a === void 0 ? void 0 : _a.nullable)
228
+ ? kt.call('queryParam', [kt.string(p.name), parameterName + toString])
229
+ : kt.call([`${parameterName}?`, 'also'], [
230
+ kt.lambda([], kt.call('queryParam', [kt.string(p.name), 'it' + toString]), { singleline: true }),
231
+ ]);
232
+ }), '\n'))]));
233
+ }
234
+ if (endpoint.parameters.some((x) => x.target === 'path')) {
235
+ callChain.push(kt.call('buildAndExpand', [
236
+ kt.call([kt.refs.mapOf.infer()], endpoint.parameters.filter((p) => p.target === 'path').map((p) => s `${kt.string(p.name)} to ${toCasing(p.name, ctx.config.parameterNameCasing)}${this.getParameterToString(ctx, { endpoint, parameter: p })}`)),
237
+ ]));
238
+ }
239
+ else {
240
+ callChain.push(kt.call('build', []));
241
+ }
242
+ callChain.push('toUriString');
243
+ result.values.push(s `return ${kt.call(callChain, [])}`);
244
+ return result;
245
+ }
246
+ getParameterToString(ctx, args) {
247
+ var _a, _b, _c;
248
+ const { parameter } = args;
249
+ if (((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'array') {
250
+ return '.joinToString()';
251
+ }
252
+ else if (((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.kind) === 'string' && ((_c = parameter.schema.enum) === null || _c === void 0 ? void 0 : _c.length) &&
253
+ this.getSchemaType(ctx, { schema: parameter.schema })) {
254
+ return '.value';
255
+ }
256
+ else {
257
+ return '.toString()';
258
+ }
259
+ }
260
+ getParameterType(ctx, args) {
261
+ var _a;
262
+ const { parameter } = args;
263
+ if ((_a = parameter.multipart) === null || _a === void 0 ? void 0 : _a.isFile) {
264
+ return ctx.refs.apiRequestFile();
265
+ }
266
+ return this.getTypeUsage(ctx, {
267
+ schema: parameter.schema,
268
+ nullable: !parameter.required,
269
+ });
270
+ }
271
+ getParameterDefaultValue(ctx, args) {
272
+ var _a, _b;
273
+ const { parameter } = args;
274
+ return !parameter.required
275
+ ? ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && parameter.schema.enum && parameter.schema.default
276
+ ? s `${this.getTypeUsage(ctx, { schema: parameter.schema, nullable: false })}.${toCasing(String(parameter.schema.default), ctx.config.enumValueNameCasing)}`
277
+ : kt.toNode((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default)
278
+ : null;
279
+ }
280
+ getTypeUsage(ctx, args) {
281
+ const { schema, nullable, fallback } = args;
282
+ const type = this.getSchemaType(ctx, { schema });
283
+ return type
284
+ ? createOverwriteProxy(type, { nullable: nullable !== null && nullable !== void 0 ? nullable : type.nullable })
285
+ : (fallback !== null && fallback !== void 0 ? fallback : kt.refs.any({ nullable }));
286
+ }
287
+ // deno-lint-ignore no-unused-vars
288
+ getPackageName(ctx, args) {
289
+ const packageSuffix = typeof ctx.config.packageSuffix === 'string'
290
+ ? ctx.config.packageSuffix
291
+ : ctx.config.packageSuffix(ctx.service);
292
+ return ctx.config.packageName + packageSuffix;
293
+ }
294
+ getResponseSchema(_ctx, args) {
295
+ var _a, _b;
296
+ const { endpoint } = args;
297
+ return (_b = (_a = endpoint.responses.find((x) => !x.statusCode || (x.statusCode >= 200 && x.statusCode < 300))) === null || _a === void 0 ? void 0 : _a.contentOptions[0]) === null || _b === void 0 ? void 0 : _b.schema;
298
+ }
299
+ getSchemaType(ctx, args) {
300
+ const { schema } = args;
301
+ return schema && ctx.input.kotlin.models[schema.id].type;
302
+ }
303
+ getAllParameters(ctx, args) {
304
+ var _a, _b;
305
+ const { endpoint } = args;
306
+ const parameters = endpoint.parameters.filter((parameter) => parameter.target === 'query' || parameter.target === 'path' || parameter.target === 'header');
307
+ if (endpoint.requestBody) {
308
+ const content = endpoint.requestBody.content[0];
309
+ let schema = content.schema;
310
+ if (content.type === 'multipart/form-data') {
311
+ if (schema && schema.kind === 'object') {
312
+ schema = (_a = resolveAnyOfAndAllOf(schema, true)) !== null && _a !== void 0 ? _a : schema;
313
+ const properties = (_b = schema.properties) !== null && _b !== void 0 ? _b : {};
314
+ for (const [name, property] of properties.entries()) {
315
+ parameters.push(Object.assign(this.createApiParameter({
316
+ id: `multipart-${name}`,
317
+ name,
318
+ target: 'body',
319
+ schema: property.schema,
320
+ required: schema.required.has(name),
321
+ description: property.schema.description,
322
+ }), {
323
+ multipart: {
324
+ name,
325
+ isFile: property.schema.kind === 'string' && property.schema.format === 'binary',
326
+ },
327
+ }));
328
+ }
329
+ }
330
+ }
331
+ else {
332
+ parameters.push(this.createApiParameter({
333
+ id: 'body',
334
+ name: this.getRequestBodyParamName(ctx, { endpoint }),
335
+ target: 'body',
336
+ schema,
337
+ required: endpoint.requestBody.required,
338
+ description: endpoint.requestBody.description,
339
+ }));
340
+ }
341
+ }
342
+ return parameters.sort((a, b) => (a.required === b.required ? 0 : a.required ? -1 : 1));
343
+ }
344
+ getRequestBodyParamName(ctx, args) {
345
+ var _a;
346
+ const { endpoint } = args;
347
+ const schema = (_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0].schema;
348
+ const schemaInfo = this.getSchemaType(ctx, { schema });
349
+ return toCasing(schemaInfo && schemaInfo.name !== 'Any' ? SourceBuilder.build((b) => kt.reference.write(b, schemaInfo)) : 'body', ctx.config.parameterNameCasing);
350
+ }
351
+ getBasePath(ctx, _args) {
352
+ var _a, _b, _c, _d, _e, _f;
353
+ return modifyString((_f = (_e = (_d = (_c = ((_a = ctx.service.$src) !== null && _a !== void 0 ? _a : (_b = ctx.service.endpoints[0]) === null || _b === void 0 ? void 0 : _b.$src)) === null || _c === void 0 ? void 0 : _c.document.servers) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : '/', ctx.config.basePath, ctx.service);
354
+ }
355
+ getEndpointPath(ctx, args) {
356
+ const { endpoint } = args;
357
+ return modifyString(endpoint.path.replace(/^\/*/, ''), ctx.config.pathModifier, endpoint);
358
+ }
359
+ getFilePath(ctx, args) {
360
+ const { packageName } = args;
361
+ return `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}/${this.getRequestsObjectName(ctx, {})}.kt`;
362
+ }
363
+ // deno-lint-ignore no-unused-vars
364
+ getRequestsObjectName(ctx, args) {
365
+ return toCasing(`${ctx.service.name}_Requests`, ctx.config.typeNameCasing);
366
+ }
367
+ createApiParameter(data) {
368
+ return {
369
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
370
+ $src: undefined,
371
+ $ref: undefined,
372
+ schema: undefined,
373
+ required: false,
374
+ description: undefined,
375
+ allowEmptyValue: undefined,
376
+ allowReserved: undefined,
377
+ deprecated: false,
378
+ explode: undefined,
379
+ style: undefined,
380
+ ...data,
381
+ };
382
+ }
383
+ }
@@ -0,0 +1,23 @@
1
+ import { type ApiService, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
2
+ import type { KotlinServicesGeneratorInput } from '../spring-controllers/index.js';
3
+ import { type KotlinSpringReactiveWebClientGeneratorOutput, type KotlinSpringReactiveWebClientsGeneratorConfig, type KotlinSpringReactiveWebClientsGeneratorContext, type KotlinSpringReactiveWebClientsGeneratorInput, type KotlinSpringReactiveWebClientsGeneratorOutput } from './models.js';
4
+ import { type KotlinSpringReactiveWebClientGenerator } from './spring-reactive-web-client-generator.js';
5
+ type Input = KotlinSpringReactiveWebClientsGeneratorInput;
6
+ type Output = KotlinSpringReactiveWebClientsGeneratorOutput;
7
+ type Config = KotlinSpringReactiveWebClientsGeneratorConfig;
8
+ type ServiceOutput = KotlinSpringReactiveWebClientGeneratorOutput;
9
+ type Context = KotlinSpringReactiveWebClientsGeneratorContext;
10
+ export declare class KotlinSpringReactiveWebClientsGenerator extends OpenApiServicesGenerationProviderBase<Input, Output, Config, ServiceOutput, Context> {
11
+ private readonly _serviceGeneratorFactory;
12
+ constructor(serviceGeneratorFactory?: Factory<KotlinSpringReactiveWebClientGenerator, []>);
13
+ protected generateAdditionalFiles(ctx: Context): Promise<void>;
14
+ protected initResult(): Output;
15
+ protected generateService(ctx: Context, service: ApiService): MaybePromise<ServiceOutput>;
16
+ protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
17
+ protected buildContext(context: OpenApiGeneratorContext<KotlinServicesGeneratorInput>, config?: Partial<Config> | undefined): Context;
18
+ protected getInfrastructurePackageName(config: Config): string;
19
+ protected getPackageName(config: Config): string;
20
+ private copyInfrastructureFiles;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=spring-reactive-web-clients-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-reactive-web-clients-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCA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9D,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAKlC,uBAAuB;CAiBtC"}
@@ -0,0 +1,79 @@
1
+ import { resolve } from 'node:path';
2
+ import fs from 'fs-extra';
3
+ import { Factory, OpenApiServicesGenerationProviderBase, } from '@goast/core';
4
+ import { getAssetFileContent } from '../../../assets.js';
5
+ import { defaultKotlinSpringReactiveWebClientsGeneratorConfig, } from './models.js';
6
+ import { getReferenceFactories } from './refs.js';
7
+ import { DefaultKotlinSpringReactiveWebClientGenerator, } from './spring-reactive-web-client-generator.js';
8
+ export class KotlinSpringReactiveWebClientsGenerator extends OpenApiServicesGenerationProviderBase {
9
+ constructor(serviceGeneratorFactory) {
10
+ super();
11
+ Object.defineProperty(this, "_serviceGeneratorFactory", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ this._serviceGeneratorFactory = serviceGeneratorFactory !== null && serviceGeneratorFactory !== void 0 ? serviceGeneratorFactory : Factory.fromValue(new DefaultKotlinSpringReactiveWebClientGenerator());
18
+ }
19
+ async generateAdditionalFiles(ctx) {
20
+ await this.copyInfrastructureFiles(ctx);
21
+ }
22
+ initResult() {
23
+ return {
24
+ kotlin: {
25
+ clients: {},
26
+ },
27
+ };
28
+ }
29
+ generateService(ctx, service) {
30
+ const serviceGenerator = this._serviceGeneratorFactory.create();
31
+ return serviceGenerator.generate({
32
+ ...ctx,
33
+ service,
34
+ });
35
+ }
36
+ addServiceResult(ctx, service, result) {
37
+ ctx.output.kotlin.clients[service.id] = result;
38
+ }
39
+ buildContext(context, config) {
40
+ context.data.services = context.data.services.filter((x) => x.name !== 'exclude-from-generation');
41
+ const providerContext = this.getProviderContext(context, config, defaultKotlinSpringReactiveWebClientsGeneratorConfig);
42
+ const infrastructurePackageName = this.getInfrastructurePackageName(providerContext.config);
43
+ return Object.assign(providerContext, {
44
+ infrastructurePackageName,
45
+ refs: getReferenceFactories(infrastructurePackageName),
46
+ });
47
+ }
48
+ getInfrastructurePackageName(config) {
49
+ if (typeof config.infrastructurePackageName === 'string') {
50
+ return config.infrastructurePackageName;
51
+ }
52
+ if (config.infrastructurePackageName.mode === 'append-package-name') {
53
+ return config.packageName + config.infrastructurePackageName.value;
54
+ }
55
+ if (config.infrastructurePackageName.mode === 'append-full-package-name') {
56
+ return this.getPackageName(config) + config.infrastructurePackageName.value;
57
+ }
58
+ return config.infrastructurePackageName.value;
59
+ }
60
+ getPackageName(config) {
61
+ const packageSuffix = typeof config.packageSuffix === 'string' ? config.packageSuffix : config.packageSuffix();
62
+ return config.packageName + packageSuffix;
63
+ }
64
+ async copyInfrastructureFiles(ctx) {
65
+ const targetDir = resolve(ctx.config.outputDir, ctx.infrastructurePackageName.replace(/\./g, '/'));
66
+ await fs.ensureDir(targetDir);
67
+ const files = [
68
+ 'ApiRequestFile.kt',
69
+ ];
70
+ for (const file of files) {
71
+ const sourcePath = `client/spring-reactive-web-clients/${file}`;
72
+ const targetPath = resolve(targetDir, file);
73
+ console.log(`Copying asset file "${sourcePath}" to "${targetPath}"`);
74
+ const fileContent = (await getAssetFileContent(sourcePath))
75
+ .replace(/@PACKAGE_NAME@/g, ctx.infrastructurePackageName);
76
+ fs.writeFileSync(targetPath, fileContent);
77
+ }
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.4.18-beta5",
3
+ "version": "0.4.18-springwebclient1",
4
4
  "description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -22,14 +22,11 @@
22
22
  "require": "./script/mod.js"
23
23
  }
24
24
  },
25
- "scripts": {
26
- "test": "node test_runner.js"
27
- },
28
25
  "dependencies": {
29
26
  "tslib": "^2.6.2",
30
27
  "fs-extra": "^11.2.0",
31
28
  "http-status-codes": "^2.3.0",
32
- "@goast/core": "0.4.0"
29
+ "@goast/core": "0.4.1-springwebclient1"
33
30
  },
34
31
  "devDependencies": {
35
32
  "@types/node": "^20.9.0",