@goast/kotlin 0.4.16 → 0.4.17

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.
@@ -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",
3
+ "version": "0.4.17",
4
4
  "description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -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}`)}) }`);
@@ -232,7 +232,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
232
232
  parameter: ApiParameterWithMultipartInfo,
233
233
  ): kt.Parameter<Builder> {
234
234
  const isEnumSchema = parameter.schema?.kind === 'string' && parameter.schema.enum?.length &&
235
- this.getSchemaType(ctx, { schema: parameter.schema });
235
+ this.getSchemaType(ctx, { schema: parameter.schema }) && !parameter.multipart;
236
236
  const actualType = this.getSchemaType(ctx, { schema: parameter.schema });
237
237
  const schemaType = isEnumSchema ? kt.refs.string({ nullable: actualType?.nullable }) : actualType;
238
238
  const result = kt.parameter(
@@ -320,13 +320,13 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator<
320
320
  private getApiInterfaceEndpointMethodBody(
321
321
  ctx: Context,
322
322
  endpoint: ApiEndpoint,
323
- parameters: ApiParameter[],
323
+ parameters: ApiParameterWithMultipartInfo[],
324
324
  ): AppendValueGroup<Builder> {
325
325
  const body = appendValueGroup<Builder>([], '\n');
326
326
 
327
327
  parameters.forEach((x) => {
328
328
  const paramName = toCasing(x.name, ctx.config.parameterNameCasing);
329
- if (x.schema?.kind === 'string' && x.schema.enum?.length) {
329
+ if (x.schema?.kind === 'string' && x.schema.enum?.length && !x.multipart) {
330
330
  const type = this.getSchemaType(ctx, { schema: x.schema });
331
331
  if (type) {
332
332
  body.values.push(