@goast/kotlin 0.4.18-beta3 → 0.4.18-beta4

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.
@@ -212,7 +212,7 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
212
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
- 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}`)}) }`);
215
+ body.values.push(s `val ${paramName} = ${paramName}${type.nullable || !x.required && !x.schema.default ? '?' : ''}.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}`)}) }`);
216
216
  }
217
217
  }
218
218
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.4.18-beta3",
3
+ "version": "0.4.18-beta4",
4
4
  "description": "Provides gOAst generators for generating Kotlin code from OpenAPI specifications.",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -36,4 +36,4 @@
36
36
  "@types/fs-extra": "11"
37
37
  },
38
38
  "_generatedBy": "dnt@dev"
39
- }
39
+ }
@@ -217,7 +217,7 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_js_1.KotlinF
217
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
- 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}`)}) }`);
220
+ body.values.push((0, core_1.builderTemplate) `val ${paramName} = ${paramName}${type.nullable || !x.required && !x.schema.default ? '?' : ''}.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}`)}) }`);
221
221
  }
222
222
  }
223
223
  });