@goast/kotlin 0.5.0 → 0.5.1-beta.1

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 (94) hide show
  1. package/LICENSE +21 -21
  2. package/assets/client/okhttp3/ApiAbstractions.kt +30 -30
  3. package/assets/client/okhttp3/ApiClient.kt +253 -253
  4. package/assets/client/okhttp3/ApiResponse.kt +43 -43
  5. package/assets/client/okhttp3/Errors.kt +21 -21
  6. package/assets/client/okhttp3/PartConfig.kt +11 -11
  7. package/assets/client/okhttp3/RequestConfig.kt +18 -18
  8. package/assets/client/okhttp3/RequestMethod.kt +8 -8
  9. package/assets/client/okhttp3/ResponseExtensions.kt +24 -24
  10. package/assets/client/spring-reactive-web-clients/ApiRequestFile.kt +33 -33
  11. package/esm/src/generators/models/model-generator.d.ts.map +1 -1
  12. package/esm/src/generators/models/model-generator.js +10 -5
  13. package/package.json +2 -2
  14. package/script/src/generators/models/model-generator.d.ts.map +1 -1
  15. package/script/src/generators/models/model-generator.js +10 -5
  16. package/src/mod.ts +0 -8
  17. package/src/src/assets.ts +0 -9
  18. package/src/src/ast/_index.ts +0 -66
  19. package/src/src/ast/common.ts +0 -1
  20. package/src/src/ast/index.ts +0 -1
  21. package/src/src/ast/node.ts +0 -10
  22. package/src/src/ast/nodes/annotation.ts +0 -79
  23. package/src/src/ast/nodes/argument.ts +0 -62
  24. package/src/src/ast/nodes/call.ts +0 -75
  25. package/src/src/ast/nodes/class.ts +0 -178
  26. package/src/src/ast/nodes/collection-literal.ts +0 -49
  27. package/src/src/ast/nodes/constructor.ts +0 -126
  28. package/src/src/ast/nodes/doc-tag.ts +0 -138
  29. package/src/src/ast/nodes/doc.ts +0 -111
  30. package/src/src/ast/nodes/enum-value.ts +0 -100
  31. package/src/src/ast/nodes/enum.ts +0 -163
  32. package/src/src/ast/nodes/function.ts +0 -178
  33. package/src/src/ast/nodes/generic-parameter.ts +0 -54
  34. package/src/src/ast/nodes/init-block.ts +0 -38
  35. package/src/src/ast/nodes/interface.ts +0 -133
  36. package/src/src/ast/nodes/lambda-type.ts +0 -73
  37. package/src/src/ast/nodes/lambda.ts +0 -74
  38. package/src/src/ast/nodes/object.ts +0 -102
  39. package/src/src/ast/nodes/parameter.ts +0 -118
  40. package/src/src/ast/nodes/property.ts +0 -225
  41. package/src/src/ast/nodes/reference.ts +0 -178
  42. package/src/src/ast/nodes/string.ts +0 -114
  43. package/src/src/ast/nodes/types.ts +0 -23
  44. package/src/src/ast/references/index.ts +0 -10
  45. package/src/src/ast/references/jackson.ts +0 -44
  46. package/src/src/ast/references/jakarta.ts +0 -14
  47. package/src/src/ast/references/java.ts +0 -20
  48. package/src/src/ast/references/kotlin.ts +0 -41
  49. package/src/src/ast/references/kotlinx.ts +0 -14
  50. package/src/src/ast/references/okhttp3.ts +0 -5
  51. package/src/src/ast/references/reactor.ts +0 -5
  52. package/src/src/ast/references/spring-reactive.ts +0 -33
  53. package/src/src/ast/references/spring.ts +0 -86
  54. package/src/src/ast/references/swagger.ts +0 -23
  55. package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
  56. package/src/src/ast/utils/to-kt-node.ts +0 -31
  57. package/src/src/ast/utils/write-kt-annotations.ts +0 -15
  58. package/src/src/ast/utils/write-kt-arguments.ts +0 -45
  59. package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
  60. package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
  61. package/src/src/ast/utils/write-kt-members.ts +0 -25
  62. package/src/src/ast/utils/write-kt-node.ts +0 -37
  63. package/src/src/ast/utils/write-kt-parameters.ts +0 -25
  64. package/src/src/common-results.ts +0 -4
  65. package/src/src/config.ts +0 -41
  66. package/src/src/file-builder.ts +0 -112
  67. package/src/src/generators/file-generator.ts +0 -29
  68. package/src/src/generators/index.ts +0 -5
  69. package/src/src/generators/models/args.ts +0 -132
  70. package/src/src/generators/models/index.ts +0 -4
  71. package/src/src/generators/models/model-generator.ts +0 -695
  72. package/src/src/generators/models/models-generator.ts +0 -65
  73. package/src/src/generators/models/models.ts +0 -95
  74. package/src/src/generators/services/okhttp3-clients/args.ts +0 -88
  75. package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
  76. package/src/src/generators/services/okhttp3-clients/models.ts +0 -73
  77. package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -597
  78. package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -169
  79. package/src/src/generators/services/okhttp3-clients/refs.ts +0 -59
  80. package/src/src/generators/services/spring-controllers/args.ts +0 -93
  81. package/src/src/generators/services/spring-controllers/index.ts +0 -4
  82. package/src/src/generators/services/spring-controllers/models.ts +0 -76
  83. package/src/src/generators/services/spring-controllers/refs.ts +0 -17
  84. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -1084
  85. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -140
  86. package/src/src/generators/services/spring-reactive-web-clients/args.ts +0 -101
  87. package/src/src/generators/services/spring-reactive-web-clients/index.ts +0 -4
  88. package/src/src/generators/services/spring-reactive-web-clients/models.ts +0 -62
  89. package/src/src/generators/services/spring-reactive-web-clients/refs.ts +0 -11
  90. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +0 -571
  91. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +0 -125
  92. package/src/src/import-collection.ts +0 -98
  93. package/src/src/types.ts +0 -3
  94. package/src/src/utils.ts +0 -39
@@ -1,65 +0,0 @@
1
- import {
2
- type ApiSchema,
3
- Factory,
4
- type MaybePromise,
5
- type OpenApiGeneratorContext,
6
- OpenApiSchemasGenerationProviderBase,
7
- } from '@goast/core';
8
-
9
- import { DefaultKotlinModelGenerator, type KotlinModelGenerator } from './model-generator.js';
10
- import {
11
- defaultKotlinModelsGeneratorConfig,
12
- type KotlinModelGeneratorOutput,
13
- type KotlinModelsGeneratorConfig,
14
- type KotlinModelsGeneratorContext,
15
- type KotlinModelsGeneratorInput,
16
- type KotlinModelsGeneratorOutput,
17
- } from './models.js';
18
-
19
- type Input = KotlinModelsGeneratorInput;
20
- type Output = KotlinModelsGeneratorOutput;
21
- type Config = KotlinModelsGeneratorConfig;
22
- type SchemaOutput = KotlinModelGeneratorOutput;
23
- type Context = KotlinModelsGeneratorContext;
24
-
25
- export class KotlinModelsGenerator extends OpenApiSchemasGenerationProviderBase<
26
- Input,
27
- Output,
28
- Config,
29
- SchemaOutput,
30
- Context
31
- > {
32
- private readonly _modelGeneratorFactory: Factory<KotlinModelGenerator, []>;
33
-
34
- constructor(modelGeneratorFactory?: Factory<KotlinModelGenerator, []>) {
35
- super();
36
- this._modelGeneratorFactory = modelGeneratorFactory ?? Factory.fromValue(new DefaultKotlinModelGenerator());
37
- }
38
-
39
- protected override initResult(): Output {
40
- return {
41
- kotlin: {
42
- models: {},
43
- },
44
- };
45
- }
46
-
47
- protected override buildContext(
48
- context: OpenApiGeneratorContext<KotlinModelsGeneratorInput>,
49
- config?: Partial<Config> | undefined,
50
- ): Context {
51
- return this.getProviderContext(context, config, defaultKotlinModelsGeneratorConfig);
52
- }
53
-
54
- protected override generateSchema(ctx: Context, schema: ApiSchema): MaybePromise<SchemaOutput> {
55
- const modelGenerator = this._modelGeneratorFactory.create();
56
- return modelGenerator.generate({
57
- ...ctx,
58
- schema,
59
- });
60
- }
61
-
62
- protected override addSchemaResult(ctx: Context, schema: ApiSchema, result: SchemaOutput): void {
63
- ctx.output.kotlin.models[schema.id] = result;
64
- }
65
- }
@@ -1,95 +0,0 @@
1
- import type {
2
- ApiSchema,
3
- DefaultGenerationProviderConfig,
4
- OpenApiSchemasGenerationProviderContext,
5
- SourceBuilder,
6
- } from '@goast/core';
7
-
8
- import type { kt } from '../../ast/index.js';
9
- import { defaultKotlinGeneratorConfig, type KotlinGeneratorConfig } from '../../config.js';
10
-
11
- export type KotlinModelsGeneratorConfig = KotlinGeneratorConfig & {
12
- /**
13
- * The package name for generated models.
14
- * @default 'com.openapi.generated'
15
- */
16
- packageName: string;
17
-
18
- /**
19
- * The suffix to append to the package name for generated models.
20
- * @default '.model'
21
- */
22
- packageSuffix: string | ((schema: ApiSchema) => string);
23
-
24
- /**
25
- * Determines how `oneOf` schemas should be treated.
26
- * - `treat-as-any-of`: Treat `oneOf` schemas as `anyOf` schemas.
27
- * - `treat-as-all-of`: Treat `oneOf` schemas as `allOf` schemas.
28
- * @default 'treat-as-any-of'
29
- */
30
- oneOfBehavior: 'treat-as-any-of' | 'treat-as-all-of';
31
-
32
- /**
33
- * Determines how schemas of type `object` without properties should be treated.
34
- * - `use-any`: Generate `Any` type for empty object schemas.
35
- * - `generate-empty-class`: Generate an empty class for empty object schemas.
36
- * @default 'generate-empty-class'
37
- */
38
- emptyObjectTypeBehavior: 'use-any' | 'generate-empty-class';
39
-
40
- /**
41
- * Whether to add Jackson annotations to generated models.
42
- * @default true
43
- */
44
- addJacksonAnnotations: boolean;
45
-
46
- /**
47
- * Whether to add Jakarta Validation annotations to generated models.
48
- * @default true
49
- */
50
- addJakartaValidationAnnotations: boolean;
51
-
52
- /**
53
- * Whether to add Swagger annotations to generated models.
54
- * @default true
55
- */
56
- addSwaggerAnnotations: boolean;
57
- };
58
-
59
- export const defaultKotlinModelsGeneratorConfig: DefaultGenerationProviderConfig<KotlinModelsGeneratorConfig> = {
60
- ...defaultKotlinGeneratorConfig,
61
-
62
- packageName: 'com.openapi.generated',
63
- packageSuffix: '.model',
64
- oneOfBehavior: 'treat-as-any-of',
65
-
66
- emptyObjectTypeBehavior: 'generate-empty-class',
67
-
68
- addJacksonAnnotations: true,
69
- addJakartaValidationAnnotations: true,
70
- addSwaggerAnnotations: true,
71
- };
72
-
73
- // deno-lint-ignore ban-types
74
- export type KotlinModelsGeneratorInput = {};
75
-
76
- export type KotlinModelsGeneratorOutput = {
77
- kotlin: {
78
- models: {
79
- [schemaId: string]: KotlinModelGeneratorOutput;
80
- };
81
- };
82
- };
83
-
84
- export type KotlinModelGeneratorOutput = { type: kt.Reference<SourceBuilder> };
85
-
86
- export type KotlinModelsGeneratorContext = OpenApiSchemasGenerationProviderContext<
87
- KotlinModelsGeneratorInput,
88
- KotlinModelsGeneratorOutput,
89
- KotlinModelsGeneratorConfig,
90
- KotlinModelGeneratorOutput
91
- >;
92
-
93
- export type KotlinModelGeneratorContext = KotlinModelsGeneratorContext & {
94
- schema: ApiSchema;
95
- };
@@ -1,88 +0,0 @@
1
- import type { ApiEndpoint, ApiParameter, ApiSchema, SourceBuilder } from '@goast/core';
2
-
3
- import type { kt } from '../../../ast/index.js';
4
- import type { ApiParameterWithMultipartInfo } from '../../../types.js';
5
-
6
- export type GetClientFileContent = object;
7
-
8
- export type GetClientClass = object;
9
-
10
- export type GetClientCompanionObject = object;
11
-
12
- export type GetEndpointClientMembers = { endpoint: ApiEndpoint; parameters: ApiParameter[] };
13
-
14
- export type GetEndpointClientMethod = {
15
- endpoint: ApiEndpoint;
16
- parameters: ApiParameter[];
17
- responseSchema: ApiSchema | undefined;
18
- };
19
-
20
- export type GetEndpointClientMethodBody = {
21
- endpoint: ApiEndpoint;
22
- parameters: ApiParameter[];
23
- responseSchema: ApiSchema | undefined;
24
- };
25
-
26
- export type GetEndpointClientHttpInfoMethod = {
27
- endpoint: ApiEndpoint;
28
- parameters: ApiParameter[];
29
- responseSchema: ApiSchema | undefined;
30
- };
31
-
32
- export type GetEndpointClientHttpInfoMethodBody = {
33
- endpoint: ApiEndpoint;
34
- parameters: ApiParameter[];
35
- responseSchema: ApiSchema | undefined;
36
- };
37
-
38
- export type GetEndpointClientRequestConfigMethod = {
39
- endpoint: ApiEndpoint;
40
- parameters: ApiParameter[];
41
- };
42
-
43
- export type GetEndpointClientRequestConfigMethodBody = {
44
- endpoint: ApiEndpoint;
45
- parameters: ApiParameterWithMultipartInfo[];
46
- };
47
-
48
- export type GetParameterToString = {
49
- endpoint: ApiEndpoint;
50
- parameter: ApiParameter;
51
- };
52
-
53
- export type GetAdditionalClientMembers = object;
54
-
55
- export type GetParameterType = { endpoint: ApiEndpoint; parameter: ApiParameterWithMultipartInfo };
56
-
57
- export type GetRequestBodyType = { endpoint: ApiEndpoint };
58
-
59
- export type GetParameterDefaultValue = {
60
- endpoint: ApiEndpoint;
61
- parameter: ApiParameter;
62
- };
63
-
64
- export type GetTypeUsage<TBuilder extends SourceBuilder> = {
65
- schema: ApiSchema | undefined;
66
- nullable?: boolean;
67
- fallback?: kt.Type<TBuilder>;
68
- };
69
-
70
- export type GetPackageName = object;
71
-
72
- export type GetPathWithInterpolation = { endpoint: ApiEndpoint };
73
-
74
- export type GetResponseSchema = { endpoint: ApiEndpoint };
75
-
76
- export type GetSchemaType = { schema: ApiSchema | undefined };
77
-
78
- export type GetAllParameters = { endpoint: ApiEndpoint };
79
-
80
- export type GetRequestBodyParamName = { endpoint: ApiEndpoint };
81
-
82
- export type GetBasePath = object;
83
-
84
- export type GetEndpointPath = { endpoint: ApiEndpoint };
85
-
86
- export type GetFilePath = { packageName: string };
87
-
88
- export type GetApiClientName = object;
@@ -1,4 +0,0 @@
1
- export * as DefaultKotlinOkHttp3GeneratorArgs from './args.js';
2
- export * from './models.js';
3
- export * from './okhttp3-client-generator.js';
4
- export * from './okhttp3-clients-generator.js';
@@ -1,73 +0,0 @@
1
- import type {
2
- ApiEndpoint,
3
- ApiService,
4
- AppendValue,
5
- DefaultGenerationProviderConfig,
6
- OpenApiServicesGenerationProviderContext,
7
- } from '@goast/core';
8
-
9
- import type { KotlinImport } from '../../../common-results.js';
10
- import { defaultKotlinGeneratorConfig, type KotlinGeneratorConfig } from '../../../config.js';
11
- import type { KotlinFileBuilder } from '../../../file-builder.js';
12
- import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
13
- import type { getReferenceFactories } from './refs.js';
14
-
15
- export type KotlinOkHttp3ClientsGeneratorConfig = KotlinGeneratorConfig & {
16
- packageName: string;
17
- packageSuffix: string | ((service?: ApiService) => string);
18
- infrastructurePackageName:
19
- | string
20
- | { mode: 'append-package-name' | 'append-full-package-name' | 'replace'; value: string };
21
-
22
- basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
23
- pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
24
- serializerJsonInclude: 'always' | 'non-null' | 'non-absent' | 'non-default' | 'non-empty' | 'use-defaults';
25
- /**
26
- * Determines how the serializer is provided to the client.
27
- * - `static`: A static instance is created in the infrastructure package and used by all clients.
28
- * - `parameter`: The serializer is provided as a required constructor parameter to the client.
29
- * - `{ mode: 'static', factory: ... }`: A static instance is created using the provided factory function.
30
- * @default 'static'
31
- */
32
- serializer: 'static' | 'parameter' | { mode: 'static'; factory: AppendValue<KotlinFileBuilder> };
33
- };
34
-
35
- export const defaultKotlinOkHttp3ClientsGeneratorConfig: DefaultGenerationProviderConfig<
36
- KotlinOkHttp3ClientsGeneratorConfig
37
- > = {
38
- ...defaultKotlinGeneratorConfig,
39
-
40
- packageName: 'com.openapi.generated',
41
- packageSuffix: '.api.client',
42
- infrastructurePackageName: { mode: 'append-full-package-name', value: '.infrastructure' },
43
- serializerJsonInclude: 'non-absent',
44
- serializer: 'static',
45
- };
46
-
47
- export type KotlinOkHttp3ClientsGeneratorInput = KotlinModelsGeneratorOutput;
48
-
49
- export type KotlinOkHttp3ClientsGeneratorOutput = {
50
- kotlin: {
51
- clients: {
52
- [serviceId: string]: KotlinOkHttp3ClientGeneratorOutput;
53
- };
54
- };
55
- };
56
-
57
- export type KotlinOkHttp3ClientGeneratorOutput = KotlinImport;
58
-
59
- export type KotlinOkHttp3ClientsGeneratorContext =
60
- & OpenApiServicesGenerationProviderContext<
61
- KotlinOkHttp3ClientsGeneratorInput,
62
- KotlinOkHttp3ClientsGeneratorOutput,
63
- KotlinOkHttp3ClientsGeneratorConfig,
64
- KotlinOkHttp3ClientGeneratorOutput
65
- >
66
- & {
67
- infrastructurePackageName: string;
68
- refs: ReturnType<typeof getReferenceFactories>;
69
- };
70
-
71
- export type KotlinOkHttp3ClientGeneratorContext = KotlinOkHttp3ClientsGeneratorContext & {
72
- service: ApiService;
73
- };