diff --git a/package.json b/package.json index bc386d32..7aed90a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-typescript-codegen", - "version": "0.1.3", + "version": "0.1.6", "description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", diff --git a/src/templates/javascript/core/request.js b/src/templates/javascript/core/request.js index cb7c0ad3..d9176ee1 100644 --- a/src/templates/javascript/core/request.js +++ b/src/templates/javascript/core/request.js @@ -4,11 +4,11 @@ /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; /** * Create the request. @@ -23,14 +23,14 @@ export async function request(options) { // Create request headers const headers = new Headers({ ...options.headers, - Accept: 'application/json' + Accept: 'application/json', }); // Create request settings const request = { headers, method: options.method, - credentials: 'same-origin' + credentials: 'same-origin', }; // If we have a bearer token then we set the authentication header. diff --git a/src/templates/javascript/core/requestUsingFetch.js b/src/templates/javascript/core/requestUsingFetch.js index 421d407d..632d36b4 100644 --- a/src/templates/javascript/core/requestUsingFetch.js +++ b/src/templates/javascript/core/requestUsingFetch.js @@ -22,7 +22,7 @@ export async function requestUsingFetch(url, request) { ok: response.ok, status: response.status, statusText: response.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. diff --git a/src/templates/javascript/core/requestUsingXHR.js b/src/templates/javascript/core/requestUsingXHR.js index 3871ad56..8515bae1 100644 --- a/src/templates/javascript/core/requestUsingXHR.js +++ b/src/templates/javascript/core/requestUsingXHR.js @@ -38,7 +38,7 @@ export async function requestUsingXHR(url, request) { ok: isSuccess(xhr.status), status: xhr.status, statusText: xhr.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. diff --git a/src/templates/javascript/models/Dictionary.js b/src/templates/javascript/models/Dictionary.js index df15b76a..9634979d 100644 --- a/src/templates/javascript/models/Dictionary.js +++ b/src/templates/javascript/models/Dictionary.js @@ -8,10 +8,7 @@ export let Dictionary; (function (Dictionary) { Dictionary.definition = { - type: 'Dictionary', - item: { - type: 'any' - } + type: 'Dictionary' }; })(Dictionary || (Dictionary = {})); diff --git a/src/templates/javascript/partials/definitionArray.hbs b/src/templates/javascript/partials/definitionArray.hbs index fc098c05..31a75ae0 100644 --- a/src/templates/javascript/partials/definitionArray.hbs +++ b/src/templates/javascript/partials/definitionArray.hbs @@ -1,12 +1,5 @@ { type: 'Array', -{{#if link~}} - item: {{>definition link}}, -{{else}} - item: { - type: '{{{base}}}', - }, -{{/if}} {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/javascript/partials/definitionDictionary.hbs b/src/templates/javascript/partials/definitionDictionary.hbs index 642428bb..0c159f34 100644 --- a/src/templates/javascript/partials/definitionDictionary.hbs +++ b/src/templates/javascript/partials/definitionDictionary.hbs @@ -1,12 +1,5 @@ { type: 'Dictionary', -{{#if link~}} - item: {{>definition link}}, -{{else}} - item: { - type: '{{{base}}}', - }, -{{/if}} {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/javascript/partials/definitionInterface.hbs b/src/templates/javascript/partials/definitionInterface.hbs index 53362e64..da00a3b6 100644 --- a/src/templates/javascript/partials/definitionInterface.hbs +++ b/src/templates/javascript/partials/definitionInterface.hbs @@ -1,7 +1,16 @@ { -{{#each properties}} - {{{name}}}: {{>definition}}, -{{/each}} + properties: { +{{#if extends}} + {{#each extends}} + ...{{{this}}}.definition.properties, + {{/each}} +{{/if}} +{{#if properties}} + {{#each properties}} + {{{name}}}: {{>definition}}, + {{/each}} +{{/if}} + }, {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/typescript/core/Definition.ts b/src/templates/typescript/core/Definition.ts index 5673fbc1..6f6614a3 100644 --- a/src/templates/typescript/core/Definition.ts +++ b/src/templates/typescript/core/Definition.ts @@ -3,14 +3,14 @@ /* eslint-disable */ /* prettier-ignore */ -import { Dictionary } from "../models/Dictionary"; +import { Dictionary } from '../models/Dictionary'; -type FieldDefinition = { +export type FieldDefinition = { readonly type?: string; readonly isReadOnly?: boolean; readonly isRequired?: boolean; readonly isNullable?: boolean; - readonly format?: 'int32' | 'int64' | 'float' | 'double' | 'string' | 'boolean' | 'byte' | 'binary' | 'date' | 'date-time' | 'password'; + readonly format?: string; readonly maximum?: number; readonly exclusiveMaximum?: boolean; readonly minimum?: number; @@ -35,8 +35,8 @@ type DictionaryDefinition = FieldDefinition & { } type ObjectDefinition = FieldDefinition & { - readonly [K in keyof T]: Definition; -} + readonly [K in keyof T]: Definition; + } export type Definition = T extends string ? FieldDefinition : diff --git a/src/templates/typescript/core/request.ts b/src/templates/typescript/core/request.ts index 62dd3f58..93927b07 100644 --- a/src/templates/typescript/core/request.ts +++ b/src/templates/typescript/core/request.ts @@ -3,13 +3,13 @@ /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {RequestOptions} from './RequestOptions'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; -import {Result} from './Result'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { RequestOptions } from './RequestOptions'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; +import { Result } from './Result'; /** * Create the request. @@ -24,14 +24,14 @@ export async function request(options: Readonly): Promise): Promise { - - /** - * @internal - */ - readonly __type: T, - +export type Dictionary = { [key: string]: T; } export namespace Dictionary { - export const definition: Definition> = { - type: 'Dictionary', - item: { - type: 'any' - } + export const definition = { + type: 'Dictionary' }; } diff --git a/src/templates/typescript/partials/definitionArray.hbs b/src/templates/typescript/partials/definitionArray.hbs index fc098c05..31a75ae0 100644 --- a/src/templates/typescript/partials/definitionArray.hbs +++ b/src/templates/typescript/partials/definitionArray.hbs @@ -1,12 +1,5 @@ { type: 'Array', -{{#if link~}} - item: {{>definition link}}, -{{else}} - item: { - type: '{{{base}}}', - }, -{{/if}} {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/typescript/partials/definitionDictionary.hbs b/src/templates/typescript/partials/definitionDictionary.hbs index 642428bb..0c159f34 100644 --- a/src/templates/typescript/partials/definitionDictionary.hbs +++ b/src/templates/typescript/partials/definitionDictionary.hbs @@ -1,12 +1,5 @@ { type: 'Dictionary', -{{#if link~}} - item: {{>definition link}}, -{{else}} - item: { - type: '{{{base}}}', - }, -{{/if}} {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/typescript/partials/definitionInterface.hbs b/src/templates/typescript/partials/definitionInterface.hbs index 53362e64..da00a3b6 100644 --- a/src/templates/typescript/partials/definitionInterface.hbs +++ b/src/templates/typescript/partials/definitionInterface.hbs @@ -1,7 +1,16 @@ { -{{#each properties}} - {{{name}}}: {{>definition}}, -{{/each}} + properties: { +{{#if extends}} + {{#each extends}} + ...{{{this}}}.definition.properties, + {{/each}} +{{/if}} +{{#if properties}} + {{#each properties}} + {{{name}}}: {{>definition}}, + {{/each}} +{{/if}} + }, {{#if isReadOnly~}} isReadOnly: {{{isReadOnly}}}, {{/if}} diff --git a/src/templates/typescript/partials/exportEnum.hbs b/src/templates/typescript/partials/exportEnum.hbs index c0531e30..a9f5837f 100644 --- a/src/templates/typescript/partials/exportEnum.hbs +++ b/src/templates/typescript/partials/exportEnum.hbs @@ -11,6 +11,6 @@ export enum {{{name}}} { export namespace {{{name}}} { - export const definition: Definition<{{{name}}}> = {{>definition}}; + export const definition = {{>definition}}; } diff --git a/src/templates/typescript/partials/exportGeneric.hbs b/src/templates/typescript/partials/exportGeneric.hbs index c43f121e..78ce1de2 100644 --- a/src/templates/typescript/partials/exportGeneric.hbs +++ b/src/templates/typescript/partials/exportGeneric.hbs @@ -7,6 +7,6 @@ export type {{{name}}} = {{>type}}; export namespace {{{name}}} { - export const definition: Definition<{{{name}}}> = {{>definition}}; + export const definition = {{>definition}}; } diff --git a/src/templates/typescript/partials/exportInterface.hbs b/src/templates/typescript/partials/exportInterface.hbs index d0264d70..db3bfddf 100644 --- a/src/templates/typescript/partials/exportInterface.hbs +++ b/src/templates/typescript/partials/exportInterface.hbs @@ -31,6 +31,6 @@ export namespace {{{name}}} { {{/each}} {{/if}} - export const definition: Definition<{{{name}}}> = {{>definition}}; + export const definition = {{>definition}}; } diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 9cbef9bb..ba8fe453 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -161,11 +161,11 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/core/request. /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; /** * Create the request. @@ -180,14 +180,14 @@ export async function request(options) { // Create request headers const headers = new Headers({ ...options.headers, - Accept: 'application/json' + Accept: 'application/json', }); // Create request settings const request = { headers, method: options.method, - credentials: 'same-origin' + credentials: 'same-origin', }; // If we have a bearer token then we set the authentication header. @@ -263,7 +263,7 @@ export async function requestUsingFetch(url, request) { ok: response.ok, status: response.status, statusText: response.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. @@ -332,7 +332,7 @@ export async function requestUsingXHR(url, request) { ok: isSuccess(xhr.status), status: xhr.status, statusText: xhr.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. @@ -528,12 +528,6 @@ export let ArrayWithArray; ArrayWithArray.definition = { type: 'Array', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; })(ArrayWithArray || (ArrayWithArray = {}));" @@ -554,9 +548,6 @@ export let ArrayWithBooleans; ArrayWithBooleans.definition = { type: 'Array', - item: { - type: 'boolean', - }, }; })(ArrayWithBooleans || (ArrayWithBooleans = {}));" @@ -577,9 +568,6 @@ export let ArrayWithNumbers; ArrayWithNumbers.definition = { type: 'Array', - item: { - type: 'number', - }, }; })(ArrayWithNumbers || (ArrayWithNumbers = {}));" @@ -600,14 +588,6 @@ export let ArrayWithProperties; ArrayWithProperties.definition = { type: 'Array', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; })(ArrayWithProperties || (ArrayWithProperties = {}));" @@ -628,9 +608,6 @@ export let ArrayWithReferences; ArrayWithReferences.definition = { type: 'Array', - item: { - type: 'ModelWithString', - }, }; })(ArrayWithReferences || (ArrayWithReferences = {}));" @@ -651,9 +628,6 @@ export let ArrayWithStrings; ArrayWithStrings.definition = { type: 'Array', - item: { - type: 'string', - }, }; })(ArrayWithStrings || (ArrayWithStrings = {}));" @@ -670,10 +644,7 @@ export let Dictionary; (function (Dictionary) { Dictionary.definition = { - type: 'Dictionary', - item: { - type: 'any' - } + type: 'Dictionary' }; })(Dictionary || (Dictionary = {})); @@ -695,12 +666,6 @@ export let DictionaryWithArray; DictionaryWithArray.definition = { type: 'Dictionary', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; })(DictionaryWithArray || (DictionaryWithArray = {}));" @@ -721,12 +686,6 @@ export let DictionaryWithDictionary; DictionaryWithDictionary.definition = { type: 'Dictionary', - item: { - type: 'Dictionary', - item: { - type: 'string', - }, - }, }; })(DictionaryWithDictionary || (DictionaryWithDictionary = {}));" @@ -747,14 +706,6 @@ export let DictionaryWithProperties; DictionaryWithProperties.definition = { type: 'Dictionary', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; })(DictionaryWithProperties || (DictionaryWithProperties = {}));" @@ -775,9 +726,6 @@ export let DictionaryWithReference; DictionaryWithReference.definition = { type: 'Dictionary', - item: { - type: 'ModelWithString', - }, }; })(DictionaryWithReference || (DictionaryWithReference = {}));" @@ -798,9 +746,6 @@ export let DictionaryWithString; DictionaryWithString.definition = { type: 'Dictionary', - item: { - type: 'string', - }, }; })(DictionaryWithString || (DictionaryWithString = {}));" @@ -892,8 +837,10 @@ export let ModelLink; (function (ModelLink) { ModelLink.definition = { - id: { - type: 'string', + properties: { + id: { + type: 'string', + }, }, }; @@ -914,11 +861,14 @@ export let ModelThatExtends; (function (ModelThatExtends) { ModelThatExtends.definition = { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', + properties: { + ...ModelWithString.definition.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, }, }; @@ -939,11 +889,15 @@ export let ModelThatExtendsExtends; (function (ModelThatExtendsExtends) { ModelThatExtendsExtends.definition = { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', + properties: { + ...ModelWithString.definition.properties, + ...ModelThatExtends.definition.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, }, }; @@ -964,22 +918,15 @@ export let ModelWithArray; (function (ModelWithArray) { ModelWithArray.definition = { - prop: { - type: 'Array', - item: { - type: 'ModelWithString', + properties: { + prop: { + type: 'Array', }, - }, - propWithFile: { - type: 'Array', - item: { - type: 'File', + propWithFile: { + type: 'Array', }, - }, - propWithNumber: { - type: 'Array', - item: { - type: 'number', + propWithNumber: { + type: 'Array', }, }, }; @@ -1001,8 +948,10 @@ export let ModelWithBoolean; (function (ModelWithBoolean) { ModelWithBoolean.definition = { - prop: { - type: 'boolean', + properties: { + prop: { + type: 'boolean', + }, }, }; @@ -1023,8 +972,10 @@ export let ModelWithCircularReference; (function (ModelWithCircularReference) { ModelWithCircularReference.definition = { - prop: { - type: 'ModelWithCircularReference', + properties: { + prop: { + type: 'ModelWithCircularReference', + }, }, }; @@ -1045,10 +996,9 @@ export let ModelWithDictionary; (function (ModelWithDictionary) { ModelWithDictionary.definition = { - prop: { - type: 'Dictionary', - item: { - type: 'string', + properties: { + prop: { + type: 'Dictionary', }, }, }; @@ -1070,14 +1020,16 @@ export let ModelWithDuplicateImports; (function (ModelWithDuplicateImports) { ModelWithDuplicateImports.definition = { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, }, }; @@ -1098,8 +1050,10 @@ export let ModelWithDuplicateProperties; (function (ModelWithDuplicateProperties) { ModelWithDuplicateProperties.definition = { - prop: { - type: 'ModelWithString', + properties: { + prop: { + type: 'ModelWithString', + }, }, }; @@ -1129,8 +1083,10 @@ export let ModelWithEnum; }; ModelWithEnum.definition = { - test: { - type: 'Enum', + properties: { + test: { + type: 'Enum', + }, }, }; @@ -1160,8 +1116,10 @@ export let ModelWithEnumFromDescription; }; ModelWithEnumFromDescription.definition = { - test: { - type: 'Enum', + properties: { + test: { + type: 'Enum', + }, }, }; @@ -1182,8 +1140,10 @@ export let ModelWithInteger; (function (ModelWithInteger) { ModelWithInteger.definition = { - prop: { - type: 'number', + properties: { + prop: { + type: 'number', + }, }, }; @@ -1204,8 +1164,10 @@ export let ModelWithLink; (function (ModelWithLink) { ModelWithLink.definition = { - prop: { - type: 'ModelLink', + properties: { + prop: { + type: 'ModelLink', + }, }, }; @@ -1226,28 +1188,18 @@ export let ModelWithNestedEnums; (function (ModelWithNestedEnums) { ModelWithNestedEnums.definition = { - arrayWithDescription: { - type: 'Array', - item: { - type: 'Enum', + properties: { + arrayWithDescription: { + type: 'Array', }, - }, - arrayWithEnum: { - type: 'Array', - item: { - type: 'Enum', + arrayWithEnum: { + type: 'Array', }, - }, - dictionaryWithEnum: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnum: { + type: 'Dictionary', }, - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnumFromDescription: { + type: 'Dictionary', }, }, }; @@ -1269,18 +1221,24 @@ export let ModelWithNestedProperties; (function (ModelWithNestedProperties) { ModelWithNestedProperties.definition = { - first: { - second: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, }, isReadOnly: true, isRequired: true, }, - isReadOnly: true, - isRequired: true, }, }; @@ -1301,26 +1259,28 @@ export let ModelWithProperties; (function (ModelWithProperties) { ModelWithProperties.definition = { - boolean: { - type: 'boolean', - }, - number: { - type: 'number', - }, - reference: { - type: 'ModelWithString', - }, - required: { - type: 'string', - isRequired: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - string: { - type: 'string', + properties: { + boolean: { + type: 'boolean', + }, + number: { + type: 'number', + }, + reference: { + type: 'ModelWithString', + }, + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, }, }; @@ -1341,8 +1301,10 @@ export let ModelWithReference; (function (ModelWithReference) { ModelWithReference.definition = { - prop: { - type: 'ModelWithString', + properties: { + prop: { + type: 'ModelWithProperties', + }, }, }; @@ -1363,8 +1325,10 @@ export let ModelWithString; (function (ModelWithString) { ModelWithString.definition = { - prop: { - type: 'string', + properties: { + prop: { + type: 'string', + }, }, }; @@ -1951,14 +1915,14 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/core/Definiti /* eslint-disable */ /* prettier-ignore */ -import { Dictionary } from \\"../models/Dictionary\\"; +import { Dictionary } from '../models/Dictionary'; -type FieldDefinition = { +export type FieldDefinition = { readonly type?: string; readonly isReadOnly?: boolean; readonly isRequired?: boolean; readonly isNullable?: boolean; - readonly format?: 'int32' | 'int64' | 'float' | 'double' | 'string' | 'boolean' | 'byte' | 'binary' | 'date' | 'date-time' | 'password'; + readonly format?: string; readonly maximum?: number; readonly exclusiveMaximum?: boolean; readonly minimum?: number; @@ -1983,8 +1947,8 @@ type DictionaryDefinition = FieldDefinition & { } type ObjectDefinition = FieldDefinition & { - readonly [K in keyof T]: Definition; -} + readonly [K in keyof T]: Definition; + } export type Definition = T extends string ? FieldDefinition : @@ -2130,13 +2094,13 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/core/request. /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {RequestOptions} from './RequestOptions'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; -import {Result} from './Result'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { RequestOptions } from './RequestOptions'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; +import { Result } from './Result'; /** * Create the request. @@ -2151,14 +2115,14 @@ export async function request(options: Readonly): Promise): Promise>; export namespace ArrayWithArray { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; }" @@ -2521,7 +2477,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with booleans @@ -2530,11 +2485,8 @@ export type ArrayWithBooleans = Array; export namespace ArrayWithBooleans { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'boolean', - }, }; }" @@ -2546,7 +2498,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with numbers @@ -2555,11 +2506,8 @@ export type ArrayWithNumbers = Array; export namespace ArrayWithNumbers { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'number', - }, }; }" @@ -2571,7 +2519,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with properties @@ -2583,16 +2530,8 @@ export type ArrayWithProperties = Array<{ export namespace ArrayWithProperties { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; }" @@ -2604,7 +2543,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -2614,11 +2552,8 @@ export type ArrayWithReferences = Array; export namespace ArrayWithReferences { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'ModelWithString', - }, }; }" @@ -2630,7 +2565,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with strings @@ -2639,11 +2573,8 @@ export type ArrayWithStrings = Array; export namespace ArrayWithStrings { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'string', - }, }; }" @@ -2655,25 +2586,14 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; - -export interface Dictionary { - - /** - * @internal - */ - readonly __type: T, - +export type Dictionary = { [key: string]: T; } export namespace Dictionary { - export const definition: Definition> = { - type: 'Dictionary', - item: { - type: 'any' - } + export const definition = { + type: 'Dictionary' }; } @@ -2686,7 +2606,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; @@ -2697,14 +2616,8 @@ export type DictionaryWithArray = Dictionary>; export namespace DictionaryWithArray { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; }" @@ -2716,7 +2629,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -2726,14 +2638,8 @@ export type DictionaryWithDictionary = Dictionary>; export namespace DictionaryWithDictionary { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'Dictionary', - item: { - type: 'string', - }, - }, }; }" @@ -2745,7 +2651,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -2758,16 +2663,8 @@ export type DictionaryWithProperties = Dictionary<{ export namespace DictionaryWithProperties { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; }" @@ -2779,7 +2676,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; @@ -2790,11 +2686,8 @@ export type DictionaryWithReference = Dictionary; export namespace DictionaryWithReference { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'ModelWithString', - }, }; }" @@ -2806,7 +2699,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -2816,11 +2708,8 @@ export type DictionaryWithString = Dictionary; export namespace DictionaryWithString { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'string', - }, }; }" @@ -2832,7 +2721,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumFr /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * Success=1,Warning=2,Error=3 @@ -2845,7 +2733,7 @@ export enum EnumFromDescription { export namespace EnumFromDescription { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -2858,7 +2746,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple enum with numbers @@ -2871,7 +2758,7 @@ export enum EnumWithNumbers { export namespace EnumWithNumbers { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -2884,7 +2771,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple enum with strings @@ -2897,7 +2783,7 @@ export enum EnumWithStrings { export namespace EnumWithStrings { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -2910,7 +2796,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelL /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model that can have a template?? @@ -2921,9 +2806,11 @@ export interface ModelLink { export namespace ModelLink { - export const definition: Definition = { - id: { - type: 'string', + export const definition = { + properties: { + id: { + type: 'string', + }, }, }; @@ -2936,7 +2823,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelT /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -2949,12 +2835,15 @@ export interface ModelThatExtends extends ModelWithString { export namespace ModelThatExtends { - export const definition: Definition = { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', + export const definition = { + properties: { + ...ModelWithString.definition.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, }, }; @@ -2967,7 +2856,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelT /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelWithString } from '../models/ModelWithString'; @@ -2981,12 +2869,16 @@ export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExten export namespace ModelThatExtendsExtends { - export const definition: Definition = { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', + export const definition = { + properties: { + ...ModelWithString.definition.properties, + ...ModelThatExtends.definition.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, }, }; @@ -2999,7 +2891,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -3013,23 +2904,16 @@ export interface ModelWithArray { export namespace ModelWithArray { - export const definition: Definition = { - prop: { - type: 'Array', - item: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'Array', }, - }, - propWithFile: { - type: 'Array', - item: { - type: 'File', + propWithFile: { + type: 'Array', }, - }, - propWithNumber: { - type: 'Array', - item: { - type: 'number', + propWithNumber: { + type: 'Array', }, }, }; @@ -3043,7 +2927,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one boolean property @@ -3057,9 +2940,11 @@ export interface ModelWithBoolean { export namespace ModelWithBoolean { - export const definition: Definition = { - prop: { - type: 'boolean', + export const definition = { + properties: { + prop: { + type: 'boolean', + }, }, }; @@ -3072,7 +2957,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one property containing a circular reference @@ -3083,9 +2967,11 @@ export interface ModelWithCircularReference { export namespace ModelWithCircularReference { - export const definition: Definition = { - prop: { - type: 'ModelWithCircularReference', + export const definition = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, }, }; @@ -3098,7 +2984,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -3110,11 +2995,10 @@ export interface ModelWithDictionary { export namespace ModelWithDictionary { - export const definition: Definition = { - prop: { - type: 'Dictionary', - item: { - type: 'string', + export const definition = { + properties: { + prop: { + type: 'Dictionary', }, }, }; @@ -3128,7 +3012,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -3142,15 +3025,17 @@ export interface ModelWithDuplicateImports { export namespace ModelWithDuplicateImports { - export const definition: Definition = { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', + export const definition = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, }, }; @@ -3163,7 +3048,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -3175,9 +3059,11 @@ export interface ModelWithDuplicateProperties { export namespace ModelWithDuplicateProperties { - export const definition: Definition = { - prop: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'ModelWithString', + }, }, }; @@ -3190,7 +3076,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one enum @@ -3213,9 +3098,11 @@ export namespace ModelWithEnum { ERROR = 'Error', } - export const definition: Definition = { - test: { - type: 'Enum', + export const definition = { + properties: { + test: { + type: 'Enum', + }, }, }; @@ -3228,7 +3115,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one enum @@ -3251,9 +3137,11 @@ export namespace ModelWithEnumFromDescription { ERROR = 3, } - export const definition: Definition = { - test: { - type: 'Enum', + export const definition = { + properties: { + test: { + type: 'Enum', + }, }, }; @@ -3266,7 +3154,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one number property @@ -3280,9 +3167,11 @@ export interface ModelWithInteger { export namespace ModelWithInteger { - export const definition: Definition = { - prop: { - type: 'number', + export const definition = { + properties: { + prop: { + type: 'number', + }, }, }; @@ -3295,7 +3184,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelLink } from '../models/ModelLink'; import { ModelWithString } from '../models/ModelWithString'; @@ -3308,9 +3196,11 @@ export interface ModelWithLink { export namespace ModelWithLink { - export const definition: Definition = { - prop: { - type: 'ModelLink', + export const definition = { + properties: { + prop: { + type: 'ModelLink', + }, }, }; @@ -3323,7 +3213,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -3338,29 +3227,19 @@ export interface ModelWithNestedEnums { export namespace ModelWithNestedEnums { - export const definition: Definition = { - arrayWithDescription: { - type: 'Array', - item: { - type: 'Enum', + export const definition = { + properties: { + arrayWithDescription: { + type: 'Array', }, - }, - arrayWithEnum: { - type: 'Array', - item: { - type: 'Enum', + arrayWithEnum: { + type: 'Array', }, - }, - dictionaryWithEnum: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnum: { + type: 'Dictionary', }, - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnumFromDescription: { + type: 'Dictionary', }, }, }; @@ -3374,7 +3253,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one nested property @@ -3389,19 +3267,25 @@ export interface ModelWithNestedProperties { export namespace ModelWithNestedProperties { - export const definition: Definition = { - first: { - second: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, + export const definition = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + }, + isReadOnly: true, + isRequired: true, + }, }, isReadOnly: true, isRequired: true, }, - isReadOnly: true, - isRequired: true, }, }; @@ -3414,7 +3298,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -3431,27 +3314,29 @@ export interface ModelWithProperties { export namespace ModelWithProperties { - export const definition: Definition = { - boolean: { - type: 'boolean', - }, - number: { - type: 'number', - }, - reference: { - type: 'ModelWithString', - }, - required: { - type: 'string', - isRequired: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - string: { - type: 'string', + export const definition = { + properties: { + boolean: { + type: 'boolean', + }, + number: { + type: 'number', + }, + reference: { + type: 'ModelWithString', + }, + required: { + type: 'string', + isRequired: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, }, }; @@ -3464,21 +3349,22 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; -import { ModelWithString } from '../models/ModelWithString'; +import { ModelWithProperties } from '../models/ModelWithProperties'; /** * This is a model with one property containing a reference */ export interface ModelWithReference { - prop?: ModelWithString; + prop?: ModelWithProperties; } export namespace ModelWithReference { - export const definition: Definition = { - prop: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'ModelWithProperties', + }, }, }; @@ -3491,7 +3377,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one string property @@ -3505,9 +3390,11 @@ export interface ModelWithString { export namespace ModelWithString { - export const definition: Definition = { - prop: { - type: 'string', + export const definition = { + properties: { + prop: { + type: 'string', + }, }, }; @@ -3520,7 +3407,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple boolean @@ -3529,7 +3415,7 @@ export type SimpleBoolean = boolean; export namespace SimpleBoolean { - export const definition: Definition = { + export const definition = { type: 'boolean', }; @@ -3542,7 +3428,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple file @@ -3551,7 +3436,7 @@ export type SimpleFile = File; export namespace SimpleFile { - export const definition: Definition = { + export const definition = { type: 'File', }; @@ -3564,7 +3449,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple number @@ -3573,7 +3457,7 @@ export type SimpleInteger = number; export namespace SimpleInteger { - export const definition: Definition = { + export const definition = { type: 'number', }; @@ -3586,7 +3470,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -3596,7 +3479,7 @@ export type SimpleReference = ModelWithString; export namespace SimpleReference { - export const definition: Definition = { + export const definition = { type: 'ModelWithString', }; @@ -3609,7 +3492,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple string @@ -3618,7 +3500,7 @@ export type SimpleString = string; export namespace SimpleString { - export const definition: Definition = { + export const definition = { type: 'string', }; @@ -4205,11 +4087,11 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/core/request. /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; /** * Create the request. @@ -4224,14 +4106,14 @@ export async function request(options) { // Create request headers const headers = new Headers({ ...options.headers, - Accept: 'application/json' + Accept: 'application/json', }); // Create request settings const request = { headers, method: options.method, - credentials: 'same-origin' + credentials: 'same-origin', }; // If we have a bearer token then we set the authentication header. @@ -4307,7 +4189,7 @@ export async function requestUsingFetch(url, request) { ok: response.ok, status: response.status, statusText: response.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. @@ -4376,7 +4258,7 @@ export async function requestUsingXHR(url, request) { ok: isSuccess(xhr.status), status: xhr.status, statusText: xhr.statusText, - body: null + body: null, }; // Try to parse the content for any response status code. @@ -4573,12 +4455,6 @@ export let ArrayWithArray; ArrayWithArray.definition = { type: 'Array', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; })(ArrayWithArray || (ArrayWithArray = {}));" @@ -4599,9 +4475,6 @@ export let ArrayWithBooleans; ArrayWithBooleans.definition = { type: 'Array', - item: { - type: 'boolean', - }, }; })(ArrayWithBooleans || (ArrayWithBooleans = {}));" @@ -4622,9 +4495,6 @@ export let ArrayWithNumbers; ArrayWithNumbers.definition = { type: 'Array', - item: { - type: 'number', - }, }; })(ArrayWithNumbers || (ArrayWithNumbers = {}));" @@ -4645,14 +4515,6 @@ export let ArrayWithProperties; ArrayWithProperties.definition = { type: 'Array', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; })(ArrayWithProperties || (ArrayWithProperties = {}));" @@ -4673,9 +4535,6 @@ export let ArrayWithReferences; ArrayWithReferences.definition = { type: 'Array', - item: { - type: 'ModelWithString', - }, }; })(ArrayWithReferences || (ArrayWithReferences = {}));" @@ -4696,9 +4555,6 @@ export let ArrayWithStrings; ArrayWithStrings.definition = { type: 'Array', - item: { - type: 'string', - }, }; })(ArrayWithStrings || (ArrayWithStrings = {}));" @@ -4715,10 +4571,7 @@ export let Dictionary; (function (Dictionary) { Dictionary.definition = { - type: 'Dictionary', - item: { - type: 'any' - } + type: 'Dictionary' }; })(Dictionary || (Dictionary = {})); @@ -4740,12 +4593,6 @@ export let DictionaryWithArray; DictionaryWithArray.definition = { type: 'Dictionary', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; })(DictionaryWithArray || (DictionaryWithArray = {}));" @@ -4766,12 +4613,6 @@ export let DictionaryWithDictionary; DictionaryWithDictionary.definition = { type: 'Dictionary', - item: { - type: 'Dictionary', - item: { - type: 'string', - }, - }, }; })(DictionaryWithDictionary || (DictionaryWithDictionary = {}));" @@ -4792,14 +4633,6 @@ export let DictionaryWithProperties; DictionaryWithProperties.definition = { type: 'Dictionary', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; })(DictionaryWithProperties || (DictionaryWithProperties = {}));" @@ -4820,9 +4653,6 @@ export let DictionaryWithReference; DictionaryWithReference.definition = { type: 'Dictionary', - item: { - type: 'ModelWithString', - }, }; })(DictionaryWithReference || (DictionaryWithReference = {}));" @@ -4843,9 +4673,6 @@ export let DictionaryWithString; DictionaryWithString.definition = { type: 'Dictionary', - item: { - type: 'string', - }, }; })(DictionaryWithString || (DictionaryWithString = {}));" @@ -4937,8 +4764,10 @@ export let ModelLink; (function (ModelLink) { ModelLink.definition = { - id: { - type: 'string', + properties: { + id: { + type: 'string', + }, }, }; @@ -4959,11 +4788,14 @@ export let ModelThatExtends; (function (ModelThatExtends) { ModelThatExtends.definition = { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', + properties: { + ...ModelWithString.definition.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, }, }; @@ -4984,11 +4816,15 @@ export let ModelThatExtendsExtends; (function (ModelThatExtendsExtends) { ModelThatExtendsExtends.definition = { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', + properties: { + ...ModelWithString.definition.properties, + ...ModelThatExtends.definition.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, }, }; @@ -5009,22 +4845,15 @@ export let ModelWithArray; (function (ModelWithArray) { ModelWithArray.definition = { - prop: { - type: 'Array', - item: { - type: 'ModelWithString', + properties: { + prop: { + type: 'Array', }, - }, - propWithFile: { - type: 'Array', - item: { - type: 'File', + propWithFile: { + type: 'Array', }, - }, - propWithNumber: { - type: 'Array', - item: { - type: 'number', + propWithNumber: { + type: 'Array', }, }, }; @@ -5046,8 +4875,10 @@ export let ModelWithBoolean; (function (ModelWithBoolean) { ModelWithBoolean.definition = { - prop: { - type: 'boolean', + properties: { + prop: { + type: 'boolean', + }, }, }; @@ -5068,8 +4899,10 @@ export let ModelWithCircularReference; (function (ModelWithCircularReference) { ModelWithCircularReference.definition = { - prop: { - type: 'ModelWithCircularReference', + properties: { + prop: { + type: 'ModelWithCircularReference', + }, }, }; @@ -5090,10 +4923,9 @@ export let ModelWithDictionary; (function (ModelWithDictionary) { ModelWithDictionary.definition = { - prop: { - type: 'Dictionary', - item: { - type: 'string', + properties: { + prop: { + type: 'Dictionary', }, }, }; @@ -5115,14 +4947,16 @@ export let ModelWithDuplicateImports; (function (ModelWithDuplicateImports) { ModelWithDuplicateImports.definition = { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, }, }; @@ -5143,8 +4977,10 @@ export let ModelWithDuplicateProperties; (function (ModelWithDuplicateProperties) { ModelWithDuplicateProperties.definition = { - prop: { - type: 'ModelWithString', + properties: { + prop: { + type: 'ModelWithString', + }, }, }; @@ -5174,8 +5010,10 @@ export let ModelWithEnum; }; ModelWithEnum.definition = { - Test: { - type: 'Enum', + properties: { + Test: { + type: 'Enum', + }, }, }; @@ -5205,8 +5043,10 @@ export let ModelWithEnumFromDescription; }; ModelWithEnumFromDescription.definition = { - Test: { - type: 'Enum', + properties: { + Test: { + type: 'Enum', + }, }, }; @@ -5227,8 +5067,10 @@ export let ModelWithInteger; (function (ModelWithInteger) { ModelWithInteger.definition = { - prop: { - type: 'number', + properties: { + prop: { + type: 'number', + }, }, }; @@ -5249,8 +5091,10 @@ export let ModelWithLink; (function (ModelWithLink) { ModelWithLink.definition = { - prop: { - type: 'ModelLink', + properties: { + prop: { + type: 'ModelLink', + }, }, }; @@ -5271,28 +5115,18 @@ export let ModelWithNestedEnums; (function (ModelWithNestedEnums) { ModelWithNestedEnums.definition = { - arrayWithDescription: { - type: 'Array', - item: { - type: 'Enum', + properties: { + arrayWithDescription: { + type: 'Array', }, - }, - arrayWithEnum: { - type: 'Array', - item: { - type: 'Enum', + arrayWithEnum: { + type: 'Array', }, - }, - dictionaryWithEnum: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnum: { + type: 'Dictionary', }, - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnumFromDescription: { + type: 'Dictionary', }, }, }; @@ -5314,21 +5148,27 @@ export let ModelWithNestedProperties; (function (ModelWithNestedProperties) { ModelWithNestedProperties.definition = { - first: { - second: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, }, isReadOnly: true, isRequired: true, isNullable: true, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }; @@ -5349,31 +5189,33 @@ export let ModelWithProperties; (function (ModelWithProperties) { ModelWithProperties.definition = { - boolean: { - type: 'boolean', - }, - number: { - type: 'number', - }, - reference: { - type: 'ModelWithString', - }, - required: { - type: 'string', - isRequired: true, - }, - requiredAndNullable: { - type: 'string', - isRequired: true, - isNullable: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - string: { - type: 'string', + properties: { + boolean: { + type: 'boolean', + }, + number: { + type: 'number', + }, + reference: { + type: 'ModelWithString', + }, + required: { + type: 'string', + isRequired: true, + }, + requiredAndNullable: { + type: 'string', + isRequired: true, + isNullable: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, }, }; @@ -5394,8 +5236,10 @@ export let ModelWithReference; (function (ModelWithReference) { ModelWithReference.definition = { - prop: { - type: 'ModelWithString', + properties: { + prop: { + type: 'ModelWithProperties', + }, }, }; @@ -5416,8 +5260,10 @@ export let ModelWithString; (function (ModelWithString) { ModelWithString.definition = { - prop: { - type: 'string', + properties: { + prop: { + type: 'string', + }, }, }; @@ -6041,14 +5887,14 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/core/Definiti /* eslint-disable */ /* prettier-ignore */ -import { Dictionary } from \\"../models/Dictionary\\"; +import { Dictionary } from '../models/Dictionary'; -type FieldDefinition = { +export type FieldDefinition = { readonly type?: string; readonly isReadOnly?: boolean; readonly isRequired?: boolean; readonly isNullable?: boolean; - readonly format?: 'int32' | 'int64' | 'float' | 'double' | 'string' | 'boolean' | 'byte' | 'binary' | 'date' | 'date-time' | 'password'; + readonly format?: string; readonly maximum?: number; readonly exclusiveMaximum?: boolean; readonly minimum?: number; @@ -6073,8 +5919,8 @@ type DictionaryDefinition = FieldDefinition & { } type ObjectDefinition = FieldDefinition & { - readonly [K in keyof T]: Definition; -} + readonly [K in keyof T]: Definition; + } export type Definition = T extends string ? FieldDefinition : @@ -6220,13 +6066,13 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/core/request. /* eslint-disable */ /* prettier-ignore */ -import {getFormData} from './getFormData'; -import {getQueryString} from './getQueryString'; -import {OpenAPI} from './OpenAPI'; -import {RequestOptions} from './RequestOptions'; -import {requestUsingFetch} from './requestUsingFetch'; -import {requestUsingXHR} from './requestUsingXHR'; -import {Result} from './Result'; +import { getFormData } from './getFormData'; +import { getQueryString } from './getQueryString'; +import { OpenAPI } from './OpenAPI'; +import { RequestOptions } from './RequestOptions'; +import { requestUsingFetch } from './requestUsingFetch'; +import { requestUsingXHR } from './requestUsingXHR'; +import { Result } from './Result'; /** * Create the request. @@ -6241,14 +6087,14 @@ export async function request(options: Readonly): Promise): Promise>; export namespace ArrayWithArray { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; }" @@ -6612,7 +6450,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with booleans @@ -6621,11 +6458,8 @@ export type ArrayWithBooleans = Array; export namespace ArrayWithBooleans { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'boolean', - }, }; }" @@ -6637,7 +6471,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with numbers @@ -6646,11 +6479,8 @@ export type ArrayWithNumbers = Array; export namespace ArrayWithNumbers { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'number', - }, }; }" @@ -6662,7 +6492,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with properties @@ -6674,16 +6503,8 @@ export type ArrayWithProperties = Array<{ export namespace ArrayWithProperties { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; }" @@ -6695,7 +6516,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -6705,11 +6525,8 @@ export type ArrayWithReferences = Array; export namespace ArrayWithReferences { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'ModelWithString', - }, }; }" @@ -6721,7 +6538,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple array with strings @@ -6730,11 +6546,8 @@ export type ArrayWithStrings = Array; export namespace ArrayWithStrings { - export const definition: Definition = { + export const definition = { type: 'Array', - item: { - type: 'string', - }, }; }" @@ -6746,25 +6559,14 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; - -export interface Dictionary { - - /** - * @internal - */ - readonly __type: T, - +export type Dictionary = { [key: string]: T; } export namespace Dictionary { - export const definition: Definition> = { - type: 'Dictionary', - item: { - type: 'any' - } + export const definition = { + type: 'Dictionary' }; } @@ -6777,7 +6579,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; @@ -6788,14 +6589,8 @@ export type DictionaryWithArray = Dictionary>; export namespace DictionaryWithArray { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'Array', - item: { - type: 'ModelWithString', - }, - }, }; }" @@ -6807,7 +6602,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -6817,14 +6611,8 @@ export type DictionaryWithDictionary = Dictionary>; export namespace DictionaryWithDictionary { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'Dictionary', - item: { - type: 'string', - }, - }, }; }" @@ -6836,7 +6624,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -6849,16 +6636,8 @@ export type DictionaryWithProperties = Dictionary<{ export namespace DictionaryWithProperties { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, }; }" @@ -6870,7 +6649,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; @@ -6881,11 +6659,8 @@ export type DictionaryWithReference = Dictionary; export namespace DictionaryWithReference { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'ModelWithString', - }, }; }" @@ -6897,7 +6672,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -6907,11 +6681,8 @@ export type DictionaryWithString = Dictionary; export namespace DictionaryWithString { - export const definition: Definition = { + export const definition = { type: 'Dictionary', - item: { - type: 'string', - }, }; }" @@ -6923,7 +6694,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumFr /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * Success=1,Warning=2,Error=3 @@ -6936,7 +6706,7 @@ export enum EnumFromDescription { export namespace EnumFromDescription { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -6949,7 +6719,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple enum with numbers @@ -6962,7 +6731,7 @@ export enum EnumWithNumbers { export namespace EnumWithNumbers { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -6975,7 +6744,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple enum with strings @@ -6988,7 +6756,7 @@ export enum EnumWithStrings { export namespace EnumWithStrings { - export const definition: Definition = { + export const definition = { type: 'Enum', }; @@ -7001,7 +6769,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelL /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model that can have a template?? @@ -7012,9 +6779,11 @@ export interface ModelLink { export namespace ModelLink { - export const definition: Definition = { - id: { - type: 'string', + export const definition = { + properties: { + id: { + type: 'string', + }, }, }; @@ -7027,7 +6796,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelT /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7040,12 +6808,15 @@ export interface ModelThatExtends extends ModelWithString { export namespace ModelThatExtends { - export const definition: Definition = { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - type: 'ModelWithString', + export const definition = { + properties: { + ...ModelWithString.definition.properties, + propExtendsA: { + type: 'string', + }, + propExtendsB: { + type: 'ModelWithString', + }, }, }; @@ -7058,7 +6829,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelT /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelWithString } from '../models/ModelWithString'; @@ -7072,12 +6842,16 @@ export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExten export namespace ModelThatExtendsExtends { - export const definition: Definition = { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - type: 'ModelWithString', + export const definition = { + properties: { + ...ModelWithString.definition.properties, + ...ModelThatExtends.definition.properties, + propExtendsC: { + type: 'string', + }, + propExtendsD: { + type: 'ModelWithString', + }, }, }; @@ -7090,7 +6864,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7104,23 +6877,16 @@ export interface ModelWithArray { export namespace ModelWithArray { - export const definition: Definition = { - prop: { - type: 'Array', - item: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'Array', }, - }, - propWithFile: { - type: 'Array', - item: { - type: 'File', + propWithFile: { + type: 'Array', }, - }, - propWithNumber: { - type: 'Array', - item: { - type: 'number', + propWithNumber: { + type: 'Array', }, }, }; @@ -7134,7 +6900,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one boolean property @@ -7148,9 +6913,11 @@ export interface ModelWithBoolean { export namespace ModelWithBoolean { - export const definition: Definition = { - prop: { - type: 'boolean', + export const definition = { + properties: { + prop: { + type: 'boolean', + }, }, }; @@ -7163,7 +6930,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one property containing a circular reference @@ -7174,9 +6940,11 @@ export interface ModelWithCircularReference { export namespace ModelWithCircularReference { - export const definition: Definition = { - prop: { - type: 'ModelWithCircularReference', + export const definition = { + properties: { + prop: { + type: 'ModelWithCircularReference', + }, }, }; @@ -7189,7 +6957,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -7201,11 +6968,10 @@ export interface ModelWithDictionary { export namespace ModelWithDictionary { - export const definition: Definition = { - prop: { - type: 'Dictionary', - item: { - type: 'string', + export const definition = { + properties: { + prop: { + type: 'Dictionary', }, }, }; @@ -7219,7 +6985,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7233,15 +6998,17 @@ export interface ModelWithDuplicateImports { export namespace ModelWithDuplicateImports { - export const definition: Definition = { - propA: { - type: 'ModelWithString', - }, - propB: { - type: 'ModelWithString', - }, - propC: { - type: 'ModelWithString', + export const definition = { + properties: { + propA: { + type: 'ModelWithString', + }, + propB: { + type: 'ModelWithString', + }, + propC: { + type: 'ModelWithString', + }, }, }; @@ -7254,7 +7021,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7266,9 +7032,11 @@ export interface ModelWithDuplicateProperties { export namespace ModelWithDuplicateProperties { - export const definition: Definition = { - prop: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'ModelWithString', + }, }, }; @@ -7281,7 +7049,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one enum @@ -7304,9 +7071,11 @@ export namespace ModelWithEnum { ERROR = 'Error', } - export const definition: Definition = { - Test: { - type: 'Enum', + export const definition = { + properties: { + Test: { + type: 'Enum', + }, }, }; @@ -7319,7 +7088,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one enum @@ -7342,9 +7110,11 @@ export namespace ModelWithEnumFromDescription { ERROR = 3, } - export const definition: Definition = { - Test: { - type: 'Enum', + export const definition = { + properties: { + Test: { + type: 'Enum', + }, }, }; @@ -7357,7 +7127,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one number property @@ -7371,9 +7140,11 @@ export interface ModelWithInteger { export namespace ModelWithInteger { - export const definition: Definition = { - prop: { - type: 'number', + export const definition = { + properties: { + prop: { + type: 'number', + }, }, }; @@ -7386,7 +7157,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelLink } from '../models/ModelLink'; import { ModelWithString } from '../models/ModelWithString'; @@ -7399,9 +7169,11 @@ export interface ModelWithLink { export namespace ModelWithLink { - export const definition: Definition = { - prop: { - type: 'ModelLink', + export const definition = { + properties: { + prop: { + type: 'ModelLink', + }, }, }; @@ -7414,7 +7186,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { Dictionary } from '../models/Dictionary'; /** @@ -7429,29 +7200,19 @@ export interface ModelWithNestedEnums { export namespace ModelWithNestedEnums { - export const definition: Definition = { - arrayWithDescription: { - type: 'Array', - item: { - type: 'Enum', + export const definition = { + properties: { + arrayWithDescription: { + type: 'Array', }, - }, - arrayWithEnum: { - type: 'Array', - item: { - type: 'Enum', + arrayWithEnum: { + type: 'Array', }, - }, - dictionaryWithEnum: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnum: { + type: 'Dictionary', }, - }, - dictionaryWithEnumFromDescription: { - type: 'Dictionary', - item: { - type: 'Enum', + dictionaryWithEnumFromDescription: { + type: 'Dictionary', }, }, }; @@ -7465,7 +7226,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one nested property @@ -7480,22 +7240,28 @@ export interface ModelWithNestedProperties { export namespace ModelWithNestedProperties { - export const definition: Definition = { - first: { - second: { - third: { - type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + export const definition = { + properties: { + first: { + properties: { + second: { + properties: { + third: { + type: 'string', + isReadOnly: true, + isRequired: true, + isNullable: true, + }, + }, + isReadOnly: true, + isRequired: true, + isNullable: true, + }, }, isReadOnly: true, isRequired: true, isNullable: true, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }; @@ -7508,7 +7274,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7526,32 +7291,34 @@ export interface ModelWithProperties { export namespace ModelWithProperties { - export const definition: Definition = { - boolean: { - type: 'boolean', - }, - number: { - type: 'number', - }, - reference: { - type: 'ModelWithString', - }, - required: { - type: 'string', - isRequired: true, - }, - requiredAndNullable: { - type: 'string', - isRequired: true, - isNullable: true, - }, - requiredAndReadOnly: { - type: 'string', - isReadOnly: true, - isRequired: true, - }, - string: { - type: 'string', + export const definition = { + properties: { + boolean: { + type: 'boolean', + }, + number: { + type: 'number', + }, + reference: { + type: 'ModelWithString', + }, + required: { + type: 'string', + isRequired: true, + }, + requiredAndNullable: { + type: 'string', + isRequired: true, + isNullable: true, + }, + requiredAndReadOnly: { + type: 'string', + isReadOnly: true, + isRequired: true, + }, + string: { + type: 'string', + }, }, }; @@ -7564,21 +7331,22 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; -import { ModelWithString } from '../models/ModelWithString'; +import { ModelWithProperties } from '../models/ModelWithProperties'; /** * This is a model with one property containing a reference */ export interface ModelWithReference { - prop?: ModelWithString; + prop?: ModelWithProperties; } export namespace ModelWithReference { - export const definition: Definition = { - prop: { - type: 'ModelWithString', + export const definition = { + properties: { + prop: { + type: 'ModelWithProperties', + }, }, }; @@ -7591,7 +7359,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a model with one string property @@ -7605,9 +7372,11 @@ export interface ModelWithString { export namespace ModelWithString { - export const definition: Definition = { - prop: { - type: 'string', + export const definition = { + properties: { + prop: { + type: 'string', + }, }, }; @@ -7620,7 +7389,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple boolean @@ -7629,7 +7397,7 @@ export type SimpleBoolean = boolean; export namespace SimpleBoolean { - export const definition: Definition = { + export const definition = { type: 'boolean', }; @@ -7642,7 +7410,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple file @@ -7651,7 +7418,7 @@ export type SimpleFile = File; export namespace SimpleFile { - export const definition: Definition = { + export const definition = { type: 'File', }; @@ -7664,7 +7431,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple number @@ -7673,7 +7439,7 @@ export type SimpleInteger = number; export namespace SimpleInteger { - export const definition: Definition = { + export const definition = { type: 'number', }; @@ -7686,7 +7452,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; import { ModelWithString } from '../models/ModelWithString'; /** @@ -7696,7 +7461,7 @@ export type SimpleReference = ModelWithString; export namespace SimpleReference { - export const definition: Definition = { + export const definition = { type: 'ModelWithString', }; @@ -7709,7 +7474,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import { Definition } from '../core/Definition'; /** * This is a simple string @@ -7718,7 +7482,7 @@ export type SimpleString = string; export namespace SimpleString { - export const definition: Definition = { + export const definition = { type: 'string', }; diff --git a/test/mock/spec-v2.json b/test/mock/spec-v2.json index 1506e7b6..5cae0125 100644 --- a/test/mock/spec-v2.json +++ b/test/mock/spec-v2.json @@ -671,7 +671,7 @@ "type": "object", "properties": { "prop": { - "$ref": "#/definitions/ModelWithString" + "$ref": "#/definitions/ModelWithProperties" } } }, diff --git a/test/mock/spec-v3.json b/test/mock/spec-v3.json index bb683f9f..3bf6300f 100644 --- a/test/mock/spec-v3.json +++ b/test/mock/spec-v3.json @@ -834,7 +834,7 @@ "type": "object", "properties": { "prop": { - "$ref": "#/components/schemas/ModelWithString" + "$ref": "#/components/schemas/ModelWithProperties" } } },