@goast/kotlin 0.1.0 → 0.1.2

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.
@@ -369,6 +369,10 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
369
369
  schema.kind !== 'oneOf') {
370
370
  return false;
371
371
  }
372
+ // Too complex types cannot be represented in Kotlin, so they fallback to Any
373
+ if (schema.kind === 'combined' || schema.kind === 'multi-type' || schema.kind === 'oneOf') {
374
+ return false;
375
+ }
372
376
  // Only object types with properties should have its own type declaration
373
377
  if (schema.kind === 'object' &&
374
378
  schema.properties.size === 0 &&
@@ -162,12 +162,12 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_1.KotlinFile
162
162
  }
163
163
  }
164
164
  generateApiInterfaceMethodParameterSignature(ctx, builder, endpoint, parameter) {
165
- var _a;
165
+ var _a, _b;
166
166
  builder
167
167
  .append((0, core_1.toCasing)(parameter.name, 'camel'))
168
168
  .append(': ')
169
169
  .append((builder) => this.generateTypeUsage(ctx, builder, parameter.schema))
170
- .append(!parameter.required && !((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.nullable) ? '?' : '');
170
+ .append(!parameter.required && ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default) === undefined && !((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? '?' : '');
171
171
  }
172
172
  generateApiInterfaceMethodContent(ctx, builder, endpoint) {
173
173
  const parameters = this.getAllParameters(ctx, endpoint);
@@ -310,12 +310,12 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_1.KotlinFile
310
310
  // None for now.
311
311
  }
312
312
  generateApiDelegateInterfaceMethodParameterSignature(ctx, builder, endpoint, parameter) {
313
- var _a;
313
+ var _a, _b;
314
314
  builder
315
315
  .append((0, core_1.toCasing)(parameter.name, 'camel'))
316
316
  .append(': ')
317
317
  .append((builder) => this.generateTypeUsage(ctx, builder, parameter.schema))
318
- .append(!parameter.required && !((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.nullable) ? '?' : '');
318
+ .append(!parameter.required && ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default) === undefined && !((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? '?' : '');
319
319
  }
320
320
  generateApiDelegateInterfaceMethodContent(ctx, builder, endpoint) {
321
321
  builder
@@ -366,6 +366,10 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
366
366
  schema.kind !== 'oneOf') {
367
367
  return false;
368
368
  }
369
+ // Too complex types cannot be represented in Kotlin, so they fallback to Any
370
+ if (schema.kind === 'combined' || schema.kind === 'multi-type' || schema.kind === 'oneOf') {
371
+ return false;
372
+ }
369
373
  // Only object types with properties should have its own type declaration
370
374
  if (schema.kind === 'object' &&
371
375
  schema.properties.size === 0 &&
@@ -159,12 +159,12 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
159
159
  }
160
160
  }
161
161
  generateApiInterfaceMethodParameterSignature(ctx, builder, endpoint, parameter) {
162
- var _a;
162
+ var _a, _b;
163
163
  builder
164
164
  .append(toCasing(parameter.name, 'camel'))
165
165
  .append(': ')
166
166
  .append((builder) => this.generateTypeUsage(ctx, builder, parameter.schema))
167
- .append(!parameter.required && !((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.nullable) ? '?' : '');
167
+ .append(!parameter.required && ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default) === undefined && !((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? '?' : '');
168
168
  }
169
169
  generateApiInterfaceMethodContent(ctx, builder, endpoint) {
170
170
  const parameters = this.getAllParameters(ctx, endpoint);
@@ -307,12 +307,12 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
307
307
  // None for now.
308
308
  }
309
309
  generateApiDelegateInterfaceMethodParameterSignature(ctx, builder, endpoint, parameter) {
310
- var _a;
310
+ var _a, _b;
311
311
  builder
312
312
  .append(toCasing(parameter.name, 'camel'))
313
313
  .append(': ')
314
314
  .append((builder) => this.generateTypeUsage(ctx, builder, parameter.schema))
315
- .append(!parameter.required && !((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.nullable) ? '?' : '');
315
+ .append(!parameter.required && ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default) === undefined && !((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? '?' : '');
316
316
  }
317
317
  generateApiDelegateInterfaceMethodContent(ctx, builder, endpoint) {
318
318
  builder
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",