@goast/kotlin 0.0.4 → 0.0.5

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.
@@ -51,6 +51,11 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
51
51
  }
52
52
  generateFileContent(ctx, builder) {
53
53
  let schema = ctx.schema;
54
+ if (schema.kind === 'oneOf') {
55
+ schema = ctx.config.oneOfBehavior === 'treat-as-any-of'
56
+ ? Object.assign(Object.assign({}, schema), { kind: 'combined', anyOf: schema.oneOf, allOf: [], oneOf: undefined }) : Object.assign(Object.assign({}, schema), { kind: 'combined', allOf: schema.oneOf, anyOf: [], oneOf: undefined });
57
+ ctx.schema = schema;
58
+ }
54
59
  if (schema.kind === 'object' || schema.kind === 'combined') {
55
60
  const mergedSchema = (0, core_1.resolveAnyOfAndAllOf)(schema, true);
56
61
  if (mergedSchema) {
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultKotlinModelsGeneratorConfig = void 0;
4
4
  const config_1 = require("../../config");
5
- exports.defaultKotlinModelsGeneratorConfig = Object.assign(Object.assign({}, config_1.defaultKotlinGeneratorConfig), { packageName: 'com.openapi.generated', packageSuffix: '.model' });
5
+ exports.defaultKotlinModelsGeneratorConfig = Object.assign(Object.assign({}, config_1.defaultKotlinGeneratorConfig), { packageName: 'com.openapi.generated', packageSuffix: '.model', oneOfBehavior: 'treat-as-any-of' });
@@ -48,6 +48,11 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
48
48
  }
49
49
  generateFileContent(ctx, builder) {
50
50
  let schema = ctx.schema;
51
+ if (schema.kind === 'oneOf') {
52
+ schema = ctx.config.oneOfBehavior === 'treat-as-any-of'
53
+ ? Object.assign(Object.assign({}, schema), { kind: 'combined', anyOf: schema.oneOf, allOf: [], oneOf: undefined }) : Object.assign(Object.assign({}, schema), { kind: 'combined', allOf: schema.oneOf, anyOf: [], oneOf: undefined });
54
+ ctx.schema = schema;
55
+ }
51
56
  if (schema.kind === 'object' || schema.kind === 'combined') {
52
57
  const mergedSchema = resolveAnyOfAndAllOf(schema, true);
53
58
  if (mergedSchema) {
@@ -1,2 +1,2 @@
1
1
  import { defaultKotlinGeneratorConfig } from '../../config';
2
- export const defaultKotlinModelsGeneratorConfig = Object.assign(Object.assign({}, defaultKotlinGeneratorConfig), { packageName: 'com.openapi.generated', packageSuffix: '.model' });
2
+ export const defaultKotlinModelsGeneratorConfig = Object.assign(Object.assign({}, defaultKotlinGeneratorConfig), { packageName: 'com.openapi.generated', packageSuffix: '.model', oneOfBehavior: 'treat-as-any-of' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -4,6 +4,7 @@ import { KotlinGeneratorConfig } from '../../config';
4
4
  export type KotlinModelsGeneratorConfig = KotlinGeneratorConfig & {
5
5
  packageName: string;
6
6
  packageSuffix: string;
7
+ oneOfBehavior: 'treat-as-any-of' | 'treat-as-all-of';
7
8
  };
8
9
  export declare const defaultKotlinModelsGeneratorConfig: DefaultGenerationProviderConfig<KotlinModelsGeneratorConfig>;
9
10
  export type KotlinModelsGeneratorInput = {};