@goast/kotlin 0.4.16-beta5 → 0.4.17-beta1

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.
@@ -2,7 +2,6 @@ import { type KtGenericReferenceFactory, type KtReferenceFactory } from '../node
2
2
  export declare const file: KtReferenceFactory;
3
3
  export declare const ioException: KtReferenceFactory;
4
4
  export declare const illegalStateException: KtReferenceFactory;
5
- export declare const illegalArgumentException: KtReferenceFactory;
6
5
  export declare const system: KtReferenceFactory;
7
6
  export declare const unsupportedOperationException: KtReferenceFactory;
8
7
  export declare const offsetDateTime: KtReferenceFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/java.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,IAAI,EAAE,kBAA2D,CAAC;AAC/E,eAAO,MAAM,WAAW,EAAE,kBAAkE,CAAC;AAG7F,eAAO,MAAM,qBAAqB,EAAE,kBAA8E,CAAC;AACnH,eAAO,MAAM,wBAAwB,EAAE,kBAGtC,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,kBAA+D,CAAC;AACrF,eAAO,MAAM,6BAA6B,EAAE,kBAG3C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,kBAAuE,CAAC;AAGrG,eAAO,MAAM,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAA0D,CAAC"}
1
+ {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/java.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,IAAI,EAAE,kBAA2D,CAAC;AAC/E,eAAO,MAAM,WAAW,EAAE,kBAAkE,CAAC;AAG7F,eAAO,MAAM,qBAAqB,EAAE,kBAA8E,CAAC;AACnH,eAAO,MAAM,MAAM,EAAE,kBAA+D,CAAC;AACrF,eAAO,MAAM,6BAA6B,EAAE,kBAG3C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,kBAAuE,CAAC;AAGrG,eAAO,MAAM,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAA0D,CAAC"}
@@ -4,7 +4,6 @@ export const file = ktReference.factory('File', 'java.io');
4
4
  export const ioException = ktReference.factory('IOException', 'java.io');
5
5
  // java.lang
6
6
  export const illegalStateException = ktReference.factory('IllegalStateException', 'java.lang');
7
- export const illegalArgumentException = ktReference.factory('IllegalArgumentException', 'java.lang');
8
7
  export const system = ktReference.factory('System', 'java.lang');
9
8
  export const unsupportedOperationException = ktReference.factory('UnsupportedOperationException', 'java.lang');
10
9
  // java.time
@@ -146,7 +146,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
146
146
  getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter) {
147
147
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
148
148
  const isEnumSchema = ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = parameter.schema.enum) === null || _b === void 0 ? void 0 : _b.length) &&
149
- this.getSchemaType(ctx, { schema: parameter.schema });
149
+ this.getSchemaType(ctx, { schema: parameter.schema }) && !parameter.multipart;
150
150
  const actualType = this.getSchemaType(ctx, { schema: parameter.schema });
151
151
  const schemaType = isEnumSchema ? kt.refs.string({ nullable: actualType === null || actualType === void 0 ? void 0 : actualType.nullable }) : actualType;
152
152
  const result = kt.parameter(toCasing(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter, type: isEnumSchema ? schemaType : undefined }), {
@@ -209,7 +209,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
209
209
  parameters.forEach((x) => {
210
210
  var _a, _b;
211
211
  const paramName = toCasing(x.name, ctx.config.parameterNameCasing);
212
- if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = x.schema.enum) === null || _b === void 0 ? void 0 : _b.length)) {
212
+ if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = x.schema.enum) === null || _b === void 0 ? void 0 : _b.length) && !x.multipart) {
213
213
  const type = this.getSchemaType(ctx, { schema: x.schema });
214
214
  if (type) {
215
215
  body.values.push(s `val ${paramName} = ${paramName}${type.nullable || !x.required ? '?' : ''}.let { ${type}.fromValue(it) ?: return ${kt.refs.spring.responseEntity.infer()}.status(${kt.refs.spring.httpStatus()}.BAD_REQUEST).body(${kt.string(`Invalid value for parameter ${x.name}`)}) }`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.4.16-beta5",
3
+ "version": "0.4.17-beta1",
4
4
  "description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -2,7 +2,6 @@ import { type KtGenericReferenceFactory, type KtReferenceFactory } from '../node
2
2
  export declare const file: KtReferenceFactory;
3
3
  export declare const ioException: KtReferenceFactory;
4
4
  export declare const illegalStateException: KtReferenceFactory;
5
- export declare const illegalArgumentException: KtReferenceFactory;
6
5
  export declare const system: KtReferenceFactory;
7
6
  export declare const unsupportedOperationException: KtReferenceFactory;
8
7
  export declare const offsetDateTime: KtReferenceFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/java.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,IAAI,EAAE,kBAA2D,CAAC;AAC/E,eAAO,MAAM,WAAW,EAAE,kBAAkE,CAAC;AAG7F,eAAO,MAAM,qBAAqB,EAAE,kBAA8E,CAAC;AACnH,eAAO,MAAM,wBAAwB,EAAE,kBAGtC,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,kBAA+D,CAAC;AACrF,eAAO,MAAM,6BAA6B,EAAE,kBAG3C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,kBAAuE,CAAC;AAGrG,eAAO,MAAM,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAA0D,CAAC"}
1
+ {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../src/src/ast/references/java.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAe,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG7G,eAAO,MAAM,IAAI,EAAE,kBAA2D,CAAC;AAC/E,eAAO,MAAM,WAAW,EAAE,kBAAkE,CAAC;AAG7F,eAAO,MAAM,qBAAqB,EAAE,kBAA8E,CAAC;AACnH,eAAO,MAAM,MAAM,EAAE,kBAA+D,CAAC;AACrF,eAAO,MAAM,6BAA6B,EAAE,kBAG3C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,kBAAuE,CAAC;AAGrG,eAAO,MAAM,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAA0D,CAAC"}
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optional = exports.offsetDateTime = exports.unsupportedOperationException = exports.system = exports.illegalArgumentException = exports.illegalStateException = exports.ioException = exports.file = void 0;
3
+ exports.optional = exports.offsetDateTime = exports.unsupportedOperationException = exports.system = exports.illegalStateException = exports.ioException = exports.file = void 0;
4
4
  const reference_js_1 = require("../nodes/reference.js");
5
5
  // java.io
6
6
  exports.file = reference_js_1.ktReference.factory('File', 'java.io');
7
7
  exports.ioException = reference_js_1.ktReference.factory('IOException', 'java.io');
8
8
  // java.lang
9
9
  exports.illegalStateException = reference_js_1.ktReference.factory('IllegalStateException', 'java.lang');
10
- exports.illegalArgumentException = reference_js_1.ktReference.factory('IllegalArgumentException', 'java.lang');
11
10
  exports.system = reference_js_1.ktReference.factory('System', 'java.lang');
12
11
  exports.unsupportedOperationException = reference_js_1.ktReference.factory('UnsupportedOperationException', 'java.lang');
13
12
  // java.time
@@ -151,7 +151,7 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
151
151
  getApiInterfaceEndpointMethodParameter(ctx, endpoint, parameter) {
152
152
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
153
153
  const isEnumSchema = ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = parameter.schema.enum) === null || _b === void 0 ? void 0 : _b.length) &&
154
- this.getSchemaType(ctx, { schema: parameter.schema });
154
+ this.getSchemaType(ctx, { schema: parameter.schema }) && !parameter.multipart;
155
155
  const actualType = this.getSchemaType(ctx, { schema: parameter.schema });
156
156
  const schemaType = isEnumSchema ? index_js_1.kt.refs.string({ nullable: actualType === null || actualType === void 0 ? void 0 : actualType.nullable }) : actualType;
157
157
  const result = index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter, type: isEnumSchema ? schemaType : undefined }), {
@@ -214,7 +214,7 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
214
214
  parameters.forEach((x) => {
215
215
  var _a, _b;
216
216
  const paramName = (0, core_1.toCasing)(x.name, ctx.config.parameterNameCasing);
217
- if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = x.schema.enum) === null || _b === void 0 ? void 0 : _b.length)) {
217
+ if (((_a = x.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && ((_b = x.schema.enum) === null || _b === void 0 ? void 0 : _b.length) && !x.multipart) {
218
218
  const type = this.getSchemaType(ctx, { schema: x.schema });
219
219
  if (type) {
220
220
  body.values.push((0, core_1.builderTemplate) `val ${paramName} = ${paramName}${type.nullable || !x.required ? '?' : ''}.let { ${type}.fromValue(it) ?: return ${index_js_1.kt.refs.spring.responseEntity.infer()}.status(${index_js_1.kt.refs.spring.httpStatus()}.BAD_REQUEST).body(${index_js_1.kt.string(`Invalid value for parameter ${x.name}`)}) }`);