@goast/kotlin 0.3.13 → 0.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/lib/ast/references/swagger.js +3 -1
- package/cjs/lib/generators/services/spring-controllers/spring-controller-generator.js +37 -14
- package/esm/lib/ast/node.js +1 -1
- package/esm/lib/ast/nodes/annotation.js +1 -1
- package/esm/lib/ast/nodes/call.js +1 -1
- package/esm/lib/ast/nodes/class.js +1 -1
- package/esm/lib/ast/nodes/collection-literal.js +1 -1
- package/esm/lib/ast/nodes/constructor.js +1 -1
- package/esm/lib/ast/nodes/doc-tag.js +1 -1
- package/esm/lib/ast/nodes/doc.js +1 -1
- package/esm/lib/ast/nodes/enum-value.js +1 -1
- package/esm/lib/ast/nodes/enum.js +1 -1
- package/esm/lib/ast/nodes/function.js +1 -1
- package/esm/lib/ast/nodes/interface.js +1 -1
- package/esm/lib/ast/nodes/lambda-type.js +1 -1
- package/esm/lib/ast/nodes/lambda.js +1 -1
- package/esm/lib/ast/nodes/object.js +1 -1
- package/esm/lib/ast/nodes/parameter.js +1 -1
- package/esm/lib/ast/nodes/property.js +1 -1
- package/esm/lib/ast/nodes/reference.js +1 -1
- package/esm/lib/ast/nodes/string.js +1 -1
- package/esm/lib/ast/references/swagger.js +2 -0
- package/esm/lib/ast/utils/get-kotlin-builder-options.js +1 -1
- package/esm/lib/ast/utils/write-kt-annotations.js +1 -1
- package/esm/lib/ast/utils/write-kt-arguments.js +1 -1
- package/esm/lib/ast/utils/write-kt-enum-values.js +1 -1
- package/esm/lib/ast/utils/write-kt-generic-parameters.js +1 -1
- package/esm/lib/ast/utils/write-kt-members.js +1 -1
- package/esm/lib/ast/utils/write-kt-node.js +1 -1
- package/esm/lib/ast/utils/write-kt-parameters.js +1 -1
- package/esm/lib/file-builder.js +1 -1
- package/esm/lib/generators/file-generator.js +1 -1
- package/esm/lib/generators/models/model-generator.js +1 -1
- package/esm/lib/generators/models/models-generator.js +1 -1
- package/esm/lib/generators/services/okhttp3-clients/okhttp3-client-generator.js +1 -1
- package/esm/lib/generators/services/okhttp3-clients/okhttp3-clients-generator.js +1 -1
- package/esm/lib/generators/services/spring-controllers/spring-controller-generator.js +38 -15
- package/esm/lib/generators/services/spring-controllers/spring-controllers-generator.js +1 -1
- package/esm/lib/import-collection.js +1 -1
- package/package.json +1 -1
- package/types/lib/ast/node.d.ts +1 -1
- package/types/lib/ast/nodes/annotation.d.ts +1 -1
- package/types/lib/ast/nodes/argument.d.ts +1 -1
- package/types/lib/ast/nodes/call.d.ts +1 -1
- package/types/lib/ast/nodes/class.d.ts +1 -1
- package/types/lib/ast/nodes/collection-literal.d.ts +1 -1
- package/types/lib/ast/nodes/constructor.d.ts +1 -1
- package/types/lib/ast/nodes/doc-tag.d.ts +1 -1
- package/types/lib/ast/nodes/doc.d.ts +1 -1
- package/types/lib/ast/nodes/enum-value.d.ts +1 -1
- package/types/lib/ast/nodes/enum.d.ts +1 -1
- package/types/lib/ast/nodes/function.d.ts +1 -1
- package/types/lib/ast/nodes/generic-parameter.d.ts +1 -1
- package/types/lib/ast/nodes/init-block.d.ts +1 -1
- package/types/lib/ast/nodes/interface.d.ts +1 -1
- package/types/lib/ast/nodes/lambda-type.d.ts +1 -1
- package/types/lib/ast/nodes/lambda.d.ts +1 -1
- package/types/lib/ast/nodes/object.d.ts +1 -1
- package/types/lib/ast/nodes/parameter.d.ts +1 -1
- package/types/lib/ast/nodes/property.d.ts +1 -1
- package/types/lib/ast/nodes/reference.d.ts +1 -1
- package/types/lib/ast/nodes/string.d.ts +1 -1
- package/types/lib/ast/nodes/types.d.ts +1 -1
- package/types/lib/ast/references/jackson.d.ts +56 -56
- package/types/lib/ast/references/jakarta.d.ts +24 -24
- package/types/lib/ast/references/java.d.ts +59 -59
- package/types/lib/ast/references/kotlin.d.ts +195 -195
- package/types/lib/ast/references/okhttp3.d.ts +16 -16
- package/types/lib/ast/references/reactor.d.ts +22 -22
- package/types/lib/ast/references/spring.d.ts +107 -107
- package/types/lib/ast/references/swagger.d.ts +58 -32
- package/types/lib/ast/utils/get-kotlin-builder-options.d.ts +1 -1
- package/types/lib/ast/utils/to-kt-node.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-annotations.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-arguments.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-enum-values.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-generic-parameters.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-members.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-node.d.ts +1 -1
- package/types/lib/ast/utils/write-kt-parameters.d.ts +1 -1
- package/types/lib/config.d.ts +1 -1
- package/types/lib/file-builder.d.ts +1 -1
- package/types/lib/generators/file-generator.d.ts +1 -1
- package/types/lib/generators/models/args.d.ts +1 -1
- package/types/lib/generators/models/model-generator.d.ts +2 -2
- package/types/lib/generators/models/models-generator.d.ts +1 -1
- package/types/lib/generators/models/models.d.ts +1 -1
- package/types/lib/generators/services/okhttp3-clients/args.d.ts +1 -1
- package/types/lib/generators/services/okhttp3-clients/models.d.ts +1 -1
- package/types/lib/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +1 -1
- package/types/lib/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts +1 -1
- package/types/lib/generators/services/okhttp3-clients/refs.d.ts +163 -163
- package/types/lib/generators/services/spring-controllers/args.d.ts +1 -1
- package/types/lib/generators/services/spring-controllers/models.d.ts +1 -1
- package/types/lib/generators/services/spring-controllers/spring-controller-generator.d.ts +1 -1
- package/types/lib/generators/services/spring-controllers/spring-controllers-generator.d.ts +1 -1
- package/types/lib/import-collection.d.ts +1 -1
- package/types/lib/types.d.ts +1 -1
- package/types/lib/utils.d.ts +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apiResponse = exports.schema = exports.operation = exports.parameter = void 0;
|
|
3
|
+
exports.apiResponses = exports.apiResponse = exports.content = exports.schema = exports.operation = exports.parameter = void 0;
|
|
4
4
|
const reference_1 = require("../nodes/reference");
|
|
5
5
|
// io.swagger.v3.oas.annotations
|
|
6
6
|
exports.parameter = reference_1.ktReference.factory('Parameter', 'io.swagger.v3.oas.annotations');
|
|
7
7
|
exports.operation = reference_1.ktReference.factory('Operation', 'io.swagger.v3.oas.annotations');
|
|
8
8
|
// io.swagger.v3.oas.annotations.media
|
|
9
9
|
exports.schema = reference_1.ktReference.factory('Schema', 'io.swagger.v3.oas.annotations.media');
|
|
10
|
+
exports.content = reference_1.ktReference.factory('Content', 'io.swagger.v3.oas.annotations.media');
|
|
10
11
|
// io.swagger.v3.oas.annotations.responses
|
|
11
12
|
exports.apiResponse = reference_1.ktReference.factory('ApiResponse', 'io.swagger.v3.oas.annotations.responses');
|
|
13
|
+
exports.apiResponses = reference_1.ktReference.factory('ApiResponses', 'io.swagger.v3.oas.annotations.responses');
|
|
@@ -80,19 +80,41 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_1.KotlinFile
|
|
|
80
80
|
}
|
|
81
81
|
getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint) {
|
|
82
82
|
var _a, _b, _c;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
ast_1.kt.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
const annotations = [];
|
|
84
|
+
if (ctx.config.addSwaggerAnnotations) {
|
|
85
|
+
annotations.push(ast_1.kt.annotation(ast_1.kt.refs.swagger.operation(), [
|
|
86
|
+
endpoint.summary ? ast_1.kt.argument.named('summary', ast_1.kt.string((_a = endpoint.summary) === null || _a === void 0 ? void 0 : _a.trim())) : null,
|
|
87
|
+
ast_1.kt.argument.named('operationId', ast_1.kt.string(endpoint.name)),
|
|
88
|
+
endpoint.description ? ast_1.kt.argument.named('description', ast_1.kt.string((_b = endpoint.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
|
|
89
|
+
endpoint.deprecated !== undefined ? ast_1.kt.argument.named('deprecated', ast_1.kt.toNode(endpoint.deprecated)) : null,
|
|
90
|
+
]));
|
|
91
|
+
if (endpoint.responses.length > 0) {
|
|
92
|
+
annotations.push(ast_1.kt.annotation(ast_1.kt.refs.swagger.apiResponses(), [
|
|
93
|
+
ast_1.kt.argument.named('value', ast_1.kt.collectionLiteral(endpoint.responses.map((response) => {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
return ast_1.kt.call(ast_1.kt.refs.swagger.apiResponse(), [
|
|
96
|
+
ast_1.kt.argument.named('responseCode', ast_1.kt.string((_a = response.statusCode) === null || _a === void 0 ? void 0 : _a.toString())),
|
|
97
|
+
response.description
|
|
98
|
+
? ast_1.kt.argument.named('description', ast_1.kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
99
|
+
: null,
|
|
100
|
+
ast_1.kt.argument.named('content', ast_1.kt.collectionLiteral((response.contentOptions.length === 0
|
|
101
|
+
? [{ schema: undefined, type: undefined }]
|
|
102
|
+
: response.contentOptions).map((content) => {
|
|
103
|
+
var _a;
|
|
104
|
+
return ast_1.kt.call(ast_1.kt.refs.swagger.content(), [
|
|
105
|
+
content.type ? ast_1.kt.argument.named('mediaType', ast_1.kt.string(content.type)) : null,
|
|
106
|
+
content.schema
|
|
107
|
+
? ast_1.kt.argument.named('schema', ast_1.kt.call(ast_1.kt.refs.swagger.schema(), [
|
|
108
|
+
ast_1.kt.argument.named('implementation', (0, core_1.builderTemplate) `${(_a = this.getSchemaType(ctx, { schema: content.schema })) !== null && _a !== void 0 ? _a : ast_1.kt.refs.any()}::class`),
|
|
109
|
+
]))
|
|
110
|
+
: null,
|
|
111
|
+
]);
|
|
112
|
+
}))),
|
|
113
|
+
]);
|
|
114
|
+
}))),
|
|
115
|
+
]));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
96
118
|
const requestMapping = ast_1.kt.annotation(ast_1.kt.refs.spring.requestMapping(), [
|
|
97
119
|
ast_1.kt.argument.named('method', ast_1.kt.collectionLiteral([ast_1.kt.call([ast_1.kt.refs.spring.requestMethod(), endpoint.method.toUpperCase()])])),
|
|
98
120
|
ast_1.kt.argument.named('value', ast_1.kt.collectionLiteral([ast_1.kt.string(this.getEndpointPath(ctx, { endpoint }))])),
|
|
@@ -100,7 +122,8 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_1.KotlinFile
|
|
|
100
122
|
if (endpoint.requestBody && endpoint.requestBody.content.length > 0) {
|
|
101
123
|
requestMapping.arguments.push(ast_1.kt.argument.named('consumes', ast_1.kt.collectionLiteral((_c = endpoint.requestBody) === null || _c === void 0 ? void 0 : _c.content.map((x) => ast_1.kt.string(x.type)))));
|
|
102
124
|
}
|
|
103
|
-
|
|
125
|
+
annotations.push(requestMapping);
|
|
126
|
+
return annotations;
|
|
104
127
|
}
|
|
105
128
|
getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter) {
|
|
106
129
|
var _a, _b, _c, _d, _e;
|
package/esm/lib/ast/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notNullish, basicAppendValueGroup, } from '
|
|
1
|
+
import { notNullish, basicAppendValueGroup, } from '@goast/core';
|
|
2
2
|
import { isKotlinAppendValue } from '../../file-builder.js';
|
|
3
3
|
import { KtNode } from '../node.js';
|
|
4
4
|
import { writeKtNodes } from '../utils/write-kt-node.js';
|
package/esm/lib/ast/nodes/doc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createOverwriteProxy, notNullish, getIsInstanceOf, } from '
|
|
1
|
+
import { createOverwriteProxy, notNullish, getIsInstanceOf, } from '@goast/core';
|
|
2
2
|
import { ktDocTag } from './doc-tag.js';
|
|
3
3
|
import { KtGenericParameter } from './generic-parameter.js';
|
|
4
4
|
import { KtParameter } from './parameter.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createOverwriteProxy, notNullish, } from '
|
|
1
|
+
import { createOverwriteProxy, notNullish, } from '@goast/core';
|
|
2
2
|
import { ktAnnotation } from './annotation.js';
|
|
3
3
|
import { ktDoc } from './doc.js';
|
|
4
4
|
import { ktEnumValue } from './enum-value.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notNullish, createOverwriteProxy, } from '
|
|
1
|
+
import { notNullish, createOverwriteProxy, } from '@goast/core';
|
|
2
2
|
import { ktAnnotation } from './annotation.js';
|
|
3
3
|
import { ktDoc } from './doc.js';
|
|
4
4
|
import { ktGenericParameter } from './generic-parameter.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { notNullish } from '
|
|
2
|
+
import { notNullish } from '@goast/core';
|
|
3
3
|
import { ktAnnotation } from './annotation.js';
|
|
4
4
|
import { ktArgument } from './argument.js';
|
|
5
5
|
import { KtNode } from '../node.js';
|
|
@@ -4,5 +4,7 @@ export const parameter = ktReference.factory('Parameter', 'io.swagger.v3.oas.ann
|
|
|
4
4
|
export const operation = ktReference.factory('Operation', 'io.swagger.v3.oas.annotations');
|
|
5
5
|
// io.swagger.v3.oas.annotations.media
|
|
6
6
|
export const schema = ktReference.factory('Schema', 'io.swagger.v3.oas.annotations.media');
|
|
7
|
+
export const content = ktReference.factory('Content', 'io.swagger.v3.oas.annotations.media');
|
|
7
8
|
// io.swagger.v3.oas.annotations.responses
|
|
8
9
|
export const apiResponse = ktReference.factory('ApiResponse', 'io.swagger.v3.oas.annotations.responses');
|
|
10
|
+
export const apiResponses = ktReference.factory('ApiResponses', 'io.swagger.v3.oas.annotations.responses');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultOpenApiGeneratorConfig } from '
|
|
1
|
+
import { defaultOpenApiGeneratorConfig } from '@goast/core';
|
|
2
2
|
import { defaultKotlinGeneratorConfig } from '../../config.js';
|
|
3
3
|
import { KotlinFileBuilder } from '../../file-builder.js';
|
|
4
4
|
const ktConfigSymbol = Symbol();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toArray, notNullish } from '
|
|
1
|
+
import { toArray, notNullish } from '@goast/core';
|
|
2
2
|
import { writeKtNode } from './write-kt-node.js';
|
|
3
3
|
export function writeKtAnnotations(builder, nodes, options) {
|
|
4
4
|
const filteredNodes = toArray(nodes).filter(notNullish);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notNullish, toArray } from '
|
|
1
|
+
import { notNullish, toArray } from '@goast/core';
|
|
2
2
|
import { writeKtNode, writeKtNodes } from './write-kt-node.js';
|
|
3
3
|
import { KtLambda } from '../nodes/lambda.js';
|
|
4
4
|
export function writeKtArguments(builder, nodes) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toArray, notNullish } from '
|
|
1
|
+
import { toArray, notNullish } from '@goast/core';
|
|
2
2
|
import { writeKtNode } from './write-kt-node.js';
|
|
3
3
|
export function writeKtEnumValues(builder, nodes) {
|
|
4
4
|
const filteredNodes = toArray(nodes).filter(notNullish);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toArray, notNullish } from '
|
|
1
|
+
import { toArray, notNullish } from '@goast/core';
|
|
2
2
|
import { writeKtNode } from './write-kt-node.js';
|
|
3
3
|
export function writeKtGenericParameters(builder, nodes) {
|
|
4
4
|
const filteredNodes = toArray(nodes).filter(notNullish);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notNullish, isAppendValue, isAppendValueGroup } from '
|
|
1
|
+
import { notNullish, isAppendValue, isAppendValueGroup } from '@goast/core';
|
|
2
2
|
import { writeKtNode } from './write-kt-node.js';
|
|
3
3
|
import { KtProperty } from '../nodes/property.js';
|
|
4
4
|
export function writeKtMembers(builder, members, options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toArray, notNullish } from '
|
|
1
|
+
import { toArray, notNullish } from '@goast/core';
|
|
2
2
|
import { writeKtNode } from './write-kt-node.js';
|
|
3
3
|
export function writeKtParameters(builder, nodes) {
|
|
4
4
|
const filteredNodes = toArray(nodes).filter(notNullish);
|
package/esm/lib/file-builder.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, isAppendValue } from '
|
|
1
|
+
import { SourceBuilder, isAppendValue } from '@goast/core';
|
|
2
2
|
import { KtNode } from './ast/node.js';
|
|
3
3
|
import { defaultKotlinGeneratorConfig } from './config.js';
|
|
4
4
|
import { ImportCollection } from './import-collection.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable unused-imports/no-unused-vars */
|
|
2
2
|
import { dirname } from 'path';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
-
import { appendValueGroup, createOverwriteProxy, getSchemaReference, modify, modifyEach, notNullish, resolveAnyOfAndAllOf, toCasing, } from '
|
|
4
|
+
import { appendValueGroup, createOverwriteProxy, getSchemaReference, modify, modifyEach, notNullish, resolveAnyOfAndAllOf, toCasing, } from '@goast/core';
|
|
5
5
|
import { kt } from '../../ast/index.js';
|
|
6
6
|
import { KotlinFileBuilder } from '../../file-builder.js';
|
|
7
7
|
import { KotlinFileGenerator } from '../file-generator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Factory, OpenApiSchemasGenerationProviderBase } from '
|
|
1
|
+
import { Factory, OpenApiSchemasGenerationProviderBase } from '@goast/core';
|
|
2
2
|
import { DefaultKotlinModelGenerator } from './model-generator.js';
|
|
3
3
|
import { defaultKotlinModelsGeneratorConfig, } from './models.js';
|
|
4
4
|
export class KotlinModelsGenerator extends OpenApiSchemasGenerationProviderBase {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { writeFileSync } from 'fs';
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import { SourceBuilder, appendValueGroup, builderTemplate as s, createOverwriteProxy, toCasing, resolveAnyOfAndAllOf, } from '
|
|
5
|
+
import { SourceBuilder, appendValueGroup, builderTemplate as s, createOverwriteProxy, toCasing, resolveAnyOfAndAllOf, } from '@goast/core';
|
|
6
6
|
import { kt } from '../../../ast/index.js';
|
|
7
7
|
import { KotlinFileBuilder } from '../../../file-builder.js';
|
|
8
8
|
import { modifyString } from '../../../utils.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeFileSync } from 'fs';
|
|
2
2
|
import { dirname, resolve } from 'path';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
-
import { Factory, OpenApiServicesGenerationProviderBase } from '
|
|
4
|
+
import { Factory, OpenApiServicesGenerationProviderBase } from '@goast/core';
|
|
5
5
|
import { defaultKotlinOkHttp3ClientsGeneratorConfig, } from './models.js';
|
|
6
6
|
import { DefaultKotlinOkHttp3Generator } from './okhttp3-client-generator.js';
|
|
7
7
|
import { getReferenceFactories } from './refs.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable unused-imports/no-unused-vars */
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
|
-
import { SourceBuilder, appendValueGroup, builderTemplate as s, createOverwriteProxy, notNullish, toCasing, resolveAnyOfAndAllOf, } from '
|
|
3
|
+
import { SourceBuilder, appendValueGroup, builderTemplate as s, createOverwriteProxy, notNullish, toCasing, resolveAnyOfAndAllOf, } from '@goast/core';
|
|
4
4
|
import { kt } from '../../../ast/index.js';
|
|
5
5
|
import { KotlinFileBuilder } from '../../../file-builder.js';
|
|
6
6
|
import { modifyString } from '../../../utils.js';
|
|
@@ -75,19 +75,41 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
75
75
|
}
|
|
76
76
|
getApiInterfaceEndpointMethodAnnnotations(ctx, endpoint) {
|
|
77
77
|
var _a, _b, _c;
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
kt.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
const annotations = [];
|
|
79
|
+
if (ctx.config.addSwaggerAnnotations) {
|
|
80
|
+
annotations.push(kt.annotation(kt.refs.swagger.operation(), [
|
|
81
|
+
endpoint.summary ? kt.argument.named('summary', kt.string((_a = endpoint.summary) === null || _a === void 0 ? void 0 : _a.trim())) : null,
|
|
82
|
+
kt.argument.named('operationId', kt.string(endpoint.name)),
|
|
83
|
+
endpoint.description ? kt.argument.named('description', kt.string((_b = endpoint.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
|
|
84
|
+
endpoint.deprecated !== undefined ? kt.argument.named('deprecated', kt.toNode(endpoint.deprecated)) : null,
|
|
85
|
+
]));
|
|
86
|
+
if (endpoint.responses.length > 0) {
|
|
87
|
+
annotations.push(kt.annotation(kt.refs.swagger.apiResponses(), [
|
|
88
|
+
kt.argument.named('value', kt.collectionLiteral(endpoint.responses.map((response) => {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
return kt.call(kt.refs.swagger.apiResponse(), [
|
|
91
|
+
kt.argument.named('responseCode', kt.string((_a = response.statusCode) === null || _a === void 0 ? void 0 : _a.toString())),
|
|
92
|
+
response.description
|
|
93
|
+
? kt.argument.named('description', kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
94
|
+
: null,
|
|
95
|
+
kt.argument.named('content', kt.collectionLiteral((response.contentOptions.length === 0
|
|
96
|
+
? [{ schema: undefined, type: undefined }]
|
|
97
|
+
: response.contentOptions).map((content) => {
|
|
98
|
+
var _a;
|
|
99
|
+
return kt.call(kt.refs.swagger.content(), [
|
|
100
|
+
content.type ? kt.argument.named('mediaType', kt.string(content.type)) : null,
|
|
101
|
+
content.schema
|
|
102
|
+
? kt.argument.named('schema', kt.call(kt.refs.swagger.schema(), [
|
|
103
|
+
kt.argument.named('implementation', s `${(_a = this.getSchemaType(ctx, { schema: content.schema })) !== null && _a !== void 0 ? _a : kt.refs.any()}::class`),
|
|
104
|
+
]))
|
|
105
|
+
: null,
|
|
106
|
+
]);
|
|
107
|
+
}))),
|
|
108
|
+
]);
|
|
109
|
+
}))),
|
|
110
|
+
]));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
91
113
|
const requestMapping = kt.annotation(kt.refs.spring.requestMapping(), [
|
|
92
114
|
kt.argument.named('method', kt.collectionLiteral([kt.call([kt.refs.spring.requestMethod(), endpoint.method.toUpperCase()])])),
|
|
93
115
|
kt.argument.named('value', kt.collectionLiteral([kt.string(this.getEndpointPath(ctx, { endpoint }))])),
|
|
@@ -95,7 +117,8 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
|
|
|
95
117
|
if (endpoint.requestBody && endpoint.requestBody.content.length > 0) {
|
|
96
118
|
requestMapping.arguments.push(kt.argument.named('consumes', kt.collectionLiteral((_c = endpoint.requestBody) === null || _c === void 0 ? void 0 : _c.content.map((x) => kt.string(x.type)))));
|
|
97
119
|
}
|
|
98
|
-
|
|
120
|
+
annotations.push(requestMapping);
|
|
121
|
+
return annotations;
|
|
99
122
|
}
|
|
100
123
|
getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter) {
|
|
101
124
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Factory, OpenApiServicesGenerationProviderBase } from '
|
|
1
|
+
import { Factory, OpenApiServicesGenerationProviderBase } from '@goast/core';
|
|
2
2
|
import { defaultKotlinServicesGeneratorConfig, } from './models.js';
|
|
3
3
|
import { DefaultKotlinSpringControllerGenerator } from './spring-controller-generator.js';
|
|
4
4
|
export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationProviderBase {
|
package/package.json
CHANGED
package/types/lib/ast/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstNode, AstNodeOptions, SourceBuilder } from '
|
|
1
|
+
import { AstNode, AstNodeOptions, SourceBuilder } from '@goast/core';
|
|
2
2
|
export declare abstract class KtNode<TBuilder extends SourceBuilder, TInjects extends string = never> extends AstNode<TBuilder, TInjects> {
|
|
3
3
|
constructor(options: AstNodeOptions<typeof AstNode<TBuilder, TInjects>>);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtArgument } from './argument';
|
|
3
3
|
import { KtType, KtValue } from './types';
|
|
4
4
|
import { KtNode } from '../node';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtValue } from './types';
|
|
3
3
|
import { KtNode } from '../node';
|
|
4
4
|
import { writeKtArguments } from '../utils/write-kt-arguments';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayItem, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { ArrayItem, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtArgument } from './argument';
|
|
3
3
|
import { KtType, KtValue } from './types';
|
|
4
4
|
import { KtNode } from '../node';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppendValue, AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AppendValue, AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtConstructor } from './constructor';
|
|
4
4
|
import { KtDoc } from './doc';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppendValue, AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AppendValue, AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtArgument } from './argument';
|
|
4
4
|
import { KtParameter } from './parameter';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, StringSuggestions, ParametersWithOverloads, Prettify, SingleOrMultiple, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, StringSuggestions, ParametersWithOverloads, Prettify, SingleOrMultiple, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtNode } from '../node';
|
|
3
3
|
import { KtAppendValue } from '../utils/write-kt-node';
|
|
4
4
|
type Injects = never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtDocTag } from './doc-tag';
|
|
3
3
|
import { KtGenericParameter } from './generic-parameter';
|
|
4
4
|
import { KtParameter } from './parameter';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppendValue, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AppendValue, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtArgument } from './argument';
|
|
4
4
|
import { KtDoc } from './doc';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppendValue, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AppendValue, AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtClass } from './class';
|
|
4
4
|
import { KtConstructor } from './constructor';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, AppendValue, Prettify, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, AppendValue, Prettify, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtDoc } from './doc';
|
|
4
4
|
import { KtGenericParameter } from './generic-parameter';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AstNodeOptions, BasicAppendValue, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtType } from './types';
|
|
3
3
|
import { KtNode } from '../node';
|
|
4
4
|
import { writeKtGenericParameters } from '../utils/write-kt-generic-parameters';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppendValue, AstNodeOptions, Prettify, SourceBuilder } from '
|
|
1
|
+
import { AppendValue, AstNodeOptions, Prettify, SourceBuilder } from '@goast/core';
|
|
2
2
|
import { KtNode } from '../node';
|
|
3
3
|
import { writeKtNodes } from '../utils/write-kt-node';
|
|
4
4
|
type Injects = never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AppendValue, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AppendValue, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtClass } from './class';
|
|
4
4
|
import { KtDoc } from './doc';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, Nullable, BasicAppendValue, AppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, Nullable, BasicAppendValue, AppendValue } from '@goast/core';
|
|
2
2
|
import { KtNode } from '../node';
|
|
3
3
|
import { writeKtNodes } from '../utils/write-kt-node';
|
|
4
4
|
type Injects = 'arguments' | 'body';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtArgument } from './argument';
|
|
3
3
|
import { KtFunction } from './function';
|
|
4
4
|
import { KtInitBlock } from './init-block';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '
|
|
1
|
+
import { SourceBuilder, AstNodeOptions, Prettify, Nullable, BasicAppendValue } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtType, KtValue } from './types';
|
|
4
4
|
import { KtAccessModifier } from '../common';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SourceBuilder, AppendValue, AstNodeOptions, Prettify, Nullable } from '
|
|
1
|
+
import { SourceBuilder, AppendValue, AstNodeOptions, Prettify, Nullable } from '@goast/core';
|
|
2
2
|
import { KtAnnotation } from './annotation';
|
|
3
3
|
import { KtArgument } from './argument';
|
|
4
4
|
import { KtDoc } from './doc';
|