mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Merge branch 'master' of github.com:ferdikoomen/openapi-typescript-codegen
This commit is contained in:
commit
c39e82fff5
@ -32,6 +32,7 @@ const handlebarsPlugin = () => ({
|
||||
preventIndent: true,
|
||||
knownHelpersOnly: true,
|
||||
knownHelpers: {
|
||||
escapeSinglequotes: true,
|
||||
equals: true,
|
||||
notEquals: true,
|
||||
containsSpaces: true,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords =
|
||||
/^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
|
||||
@ -165,7 +165,7 @@ export function getModel(
|
||||
model.default = getModelDefault(definition, model);
|
||||
|
||||
if (definition.properties) {
|
||||
const modelProperties = getModelProperties(openApi, definition, getModel);
|
||||
const modelProperties = getModelProperties(openApi, definition, getModel, model);
|
||||
modelProperties.forEach(modelProperty => {
|
||||
model.imports.push(...modelProperty.imports);
|
||||
model.enums.push(...modelProperty.enums);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import type { Model } from '../../../client/interfaces/Model';
|
||||
import { findOneOfParentDiscriminator, mapPropertyValue } from '../../../utils/discriminator';
|
||||
import { getPattern } from '../../../utils/getPattern';
|
||||
import type { OpenApi } from '../interfaces/OpenApi';
|
||||
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
|
||||
@ -10,77 +11,82 @@ import { getType } from './getType';
|
||||
// Fix for circular dependency
|
||||
export type GetModelFn = typeof getModel;
|
||||
|
||||
export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema, getModel: GetModelFn): Model[] {
|
||||
export function getModelProperties(
|
||||
openApi: OpenApi,
|
||||
definition: OpenApiSchema,
|
||||
getModel: GetModelFn,
|
||||
parent?: Model
|
||||
): Model[] {
|
||||
const models: Model[] = [];
|
||||
const discriminator = findOneOfParentDiscriminator(openApi, parent);
|
||||
for (const propertyName in definition.properties) {
|
||||
if (definition.properties.hasOwnProperty(propertyName)) {
|
||||
const property = definition.properties[propertyName];
|
||||
const propertyRequired = !!definition.required?.includes(propertyName);
|
||||
if (property.$ref) {
|
||||
const propertyValues = {
|
||||
name: escapeName(propertyName),
|
||||
description: getComment(property.description),
|
||||
isDefinition: false,
|
||||
isReadOnly: property.readOnly === true,
|
||||
isRequired: propertyRequired,
|
||||
format: property.format,
|
||||
maximum: property.maximum,
|
||||
exclusiveMaximum: property.exclusiveMaximum,
|
||||
minimum: property.minimum,
|
||||
exclusiveMinimum: property.exclusiveMinimum,
|
||||
multipleOf: property.multipleOf,
|
||||
maxLength: property.maxLength,
|
||||
minLength: property.minLength,
|
||||
maxItems: property.maxItems,
|
||||
minItems: property.minItems,
|
||||
uniqueItems: property.uniqueItems,
|
||||
maxProperties: property.maxProperties,
|
||||
minProperties: property.minProperties,
|
||||
pattern: getPattern(property.pattern),
|
||||
};
|
||||
if (parent && discriminator?.propertyName == propertyName) {
|
||||
models.push({
|
||||
export: 'reference',
|
||||
type: 'string',
|
||||
base: `'${mapPropertyValue(discriminator, parent)}'`,
|
||||
template: null,
|
||||
isNullable: property.nullable === true,
|
||||
link: null,
|
||||
imports: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
...propertyValues,
|
||||
});
|
||||
} else if (property.$ref) {
|
||||
const model = getType(property.$ref);
|
||||
models.push({
|
||||
name: escapeName(propertyName),
|
||||
export: 'reference',
|
||||
type: model.type,
|
||||
base: model.base,
|
||||
template: model.template,
|
||||
link: null,
|
||||
description: getComment(property.description),
|
||||
isDefinition: false,
|
||||
isReadOnly: property.readOnly === true,
|
||||
isRequired: propertyRequired,
|
||||
isNullable: model.isNullable || property.nullable === true,
|
||||
format: property.format,
|
||||
maximum: property.maximum,
|
||||
exclusiveMaximum: property.exclusiveMaximum,
|
||||
minimum: property.minimum,
|
||||
exclusiveMinimum: property.exclusiveMinimum,
|
||||
multipleOf: property.multipleOf,
|
||||
maxLength: property.maxLength,
|
||||
minLength: property.minLength,
|
||||
maxItems: property.maxItems,
|
||||
minItems: property.minItems,
|
||||
uniqueItems: property.uniqueItems,
|
||||
maxProperties: property.maxProperties,
|
||||
minProperties: property.minProperties,
|
||||
pattern: getPattern(property.pattern),
|
||||
imports: model.imports,
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
...propertyValues,
|
||||
});
|
||||
} else {
|
||||
const model = getModel(openApi, property);
|
||||
models.push({
|
||||
name: escapeName(propertyName),
|
||||
export: model.export,
|
||||
type: model.type,
|
||||
base: model.base,
|
||||
template: model.template,
|
||||
link: model.link,
|
||||
description: getComment(property.description),
|
||||
isDefinition: false,
|
||||
isReadOnly: property.readOnly === true,
|
||||
isRequired: propertyRequired,
|
||||
isNullable: model.isNullable || property.nullable === true,
|
||||
format: property.format,
|
||||
maximum: property.maximum,
|
||||
exclusiveMaximum: property.exclusiveMaximum,
|
||||
minimum: property.minimum,
|
||||
exclusiveMinimum: property.exclusiveMinimum,
|
||||
multipleOf: property.multipleOf,
|
||||
maxLength: property.maxLength,
|
||||
minLength: property.minLength,
|
||||
maxItems: property.maxItems,
|
||||
minItems: property.minItems,
|
||||
uniqueItems: property.uniqueItems,
|
||||
maxProperties: property.maxProperties,
|
||||
minProperties: property.minProperties,
|
||||
pattern: getPattern(property.pattern),
|
||||
imports: model.imports,
|
||||
enum: model.enum,
|
||||
enums: model.enums,
|
||||
properties: model.properties,
|
||||
...propertyValues,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import camelCase from 'camelcase';
|
||||
|
||||
const reservedWords =
|
||||
/^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
const reservedWords = /^(arguments|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g;
|
||||
|
||||
/**
|
||||
* Replaces any invalid characters from a parameter name.
|
||||
|
||||
@ -33,7 +33,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
headers.append('Content-Type', options.body.type || 'application/octet-stream');
|
||||
} else if (isString(options.body)) {
|
||||
headers.append('Content-Type', 'text/plain');
|
||||
} else {
|
||||
} else if (!isFormData(options.body)) {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
if (options.body) {
|
||||
if (options.mediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
||||
return options.body;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
|
||||
@ -19,6 +19,9 @@ import { OpenAPI } from './OpenAPI';
|
||||
{{>functions/isBlob}}
|
||||
|
||||
|
||||
{{>functions/isFormData}}
|
||||
|
||||
|
||||
{{>functions/base64}}
|
||||
|
||||
|
||||
|
||||
3
src/templates/core/functions/isFormData.hbs
Normal file
3
src/templates/core/functions/isFormData.hbs
Normal file
@ -0,0 +1,3 @@
|
||||
function isFormData(value: any): value is FormData {
|
||||
return value instanceof FormData;
|
||||
}
|
||||
@ -33,7 +33,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
headers.append('Content-Type', 'application/octet-stream');
|
||||
} else if (isString(options.body)) {
|
||||
headers.append('Content-Type', 'text/plain');
|
||||
} else {
|
||||
} else if (!isFormData(options.body)) {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
if (options.body) {
|
||||
if (options.mediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
||||
return options.body as any;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
|
||||
@ -33,7 +33,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
headers.append('Content-Type', options.body.type || 'application/octet-stream');
|
||||
} else if (isString(options.body)) {
|
||||
headers.append('Content-Type', 'text/plain');
|
||||
} else {
|
||||
} else if (!isFormData(options.body)) {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ function getRequestBody(options: ApiRequestOptions): any {
|
||||
if (options.body) {
|
||||
if (options.mediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
||||
return options.body;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
{
|
||||
type: '{{export}}',
|
||||
{{#if description}}
|
||||
description: '{{{escapeSinglequotes description}}}',
|
||||
{{/if}}
|
||||
contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}],
|
||||
{{#if isReadOnly}}
|
||||
isReadOnly: {{{isReadOnly}}},
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
{
|
||||
{{#if type}}
|
||||
type: '{{{base}}}',
|
||||
type: '{{{type}}}',
|
||||
{{/if}}
|
||||
{{#if description}}
|
||||
description: '{{{escapeSinglequotes description}}}',
|
||||
{{/if}}
|
||||
{{#if isReadOnly}}
|
||||
isReadOnly: {{{isReadOnly}}},
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
{
|
||||
{{#if description}}
|
||||
description: '{{{escapeSinglequotes description}}}',
|
||||
{{/if}}
|
||||
properties: {
|
||||
{{#if properties}}
|
||||
{{#each properties}}
|
||||
|
||||
46
src/utils/discriminator.ts
Normal file
46
src/utils/discriminator.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { Model } from '../client/interfaces/Model';
|
||||
import { OpenApi } from '../openApi/v3/interfaces/OpenApi';
|
||||
import { OpenApiDiscriminator } from '../openApi/v3/interfaces/OpenApiDiscriminator';
|
||||
import { stripNamespace } from '../openApi/v3/parser/stripNamespace';
|
||||
import { Dictionary } from './types';
|
||||
|
||||
const inverseDictionary = (mapObj: Dictionary<string>) => {
|
||||
const m2: Dictionary<string> = {};
|
||||
for (const key in mapObj) {
|
||||
m2[mapObj[key]] = key;
|
||||
}
|
||||
return m2;
|
||||
};
|
||||
|
||||
export function findOneOfParentDiscriminator(openApi: OpenApi, parent?: Model): OpenApiDiscriminator | undefined {
|
||||
if (openApi.components) {
|
||||
for (const definitionName in openApi.components.schemas) {
|
||||
if (openApi.components.schemas.hasOwnProperty(definitionName)) {
|
||||
const schema = openApi.components.schemas[definitionName];
|
||||
if (parent && schema.oneOf?.length && schema.discriminator) {
|
||||
const isPartOf =
|
||||
schema.oneOf
|
||||
.map(definition => {
|
||||
return definition.$ref && stripNamespace(definition.$ref) == parent.name;
|
||||
})
|
||||
.filter(Boolean).length > 0;
|
||||
if (isPartOf) {
|
||||
return schema.discriminator;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function mapPropertyValue(discriminator: OpenApiDiscriminator, parent: Model): string {
|
||||
if (discriminator.mapping) {
|
||||
const mapping = inverseDictionary(discriminator.mapping);
|
||||
const key = Object.keys(mapping).find(item => stripNamespace(item) == parent.name);
|
||||
if (key && mapping[key]) {
|
||||
return mapping[key];
|
||||
}
|
||||
}
|
||||
return parent.name;
|
||||
}
|
||||
@ -10,6 +10,10 @@ export function registerHandlebarHelpers(root: {
|
||||
useOptions: boolean;
|
||||
useUnionTypes: boolean;
|
||||
}): void {
|
||||
Handlebars.registerHelper('escapeQuotes', function (value: string): string {
|
||||
return value.replace(/(')/g, '\\$1');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper(
|
||||
'equals',
|
||||
function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string {
|
||||
|
||||
@ -24,6 +24,7 @@ import functionGetQueryString from '../templates/core/functions/getQueryString.h
|
||||
import functionGetUrl from '../templates/core/functions/getUrl.hbs';
|
||||
import functionIsBlob from '../templates/core/functions/isBlob.hbs';
|
||||
import functionIsDefined from '../templates/core/functions/isDefined.hbs';
|
||||
import functionIsFormData from '../templates/core/functions/isFormData.hbs';
|
||||
import functionIsString from '../templates/core/functions/isString.hbs';
|
||||
import functionIsStringWithValue from '../templates/core/functions/isStringWithValue.hbs';
|
||||
import functionIsSuccess from '../templates/core/functions/isSuccess.hbs';
|
||||
@ -157,6 +158,7 @@ export function registerHandlebarTemplates(root: {
|
||||
Handlebars.registerPartial('functions/getUrl', Handlebars.template(functionGetUrl));
|
||||
Handlebars.registerPartial('functions/isBlob', Handlebars.template(functionIsBlob));
|
||||
Handlebars.registerPartial('functions/isDefined', Handlebars.template(functionIsDefined));
|
||||
Handlebars.registerPartial('functions/isFormData', Handlebars.template(functionIsFormData));
|
||||
Handlebars.registerPartial('functions/isString', Handlebars.template(functionIsString));
|
||||
Handlebars.registerPartial('functions/isStringWithValue', Handlebars.template(functionIsStringWithValue));
|
||||
Handlebars.registerPartial('functions/isSuccess', Handlebars.template(functionIsSuccess));
|
||||
|
||||
@ -233,6 +233,10 @@ function isBlob(value: any): value is Blob {
|
||||
return value instanceof Blob;
|
||||
}
|
||||
|
||||
function isFormData(value: any): value is FormData {
|
||||
return value instanceof FormData;
|
||||
}
|
||||
|
||||
function base64(str: string): string {
|
||||
try {
|
||||
return btoa(str);
|
||||
@ -347,7 +351,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
headers.append('Content-Type', options.body.type || 'application/octet-stream');
|
||||
} else if (isString(options.body)) {
|
||||
headers.append('Content-Type', 'text/plain');
|
||||
} else {
|
||||
} else if (!isFormData(options.body)) {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
@ -359,7 +363,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
if (options.body) {
|
||||
if (options.mediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
||||
return options.body;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
@ -1368,6 +1372,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$Date.ts 1`] = `
|
||||
/* eslint-disable */
|
||||
export const $Date = {
|
||||
type: 'string',
|
||||
description: 'This is a type-only model that defines Date as a string',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1450,6 +1455,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$EnumFromDescription.ts
|
||||
/* eslint-disable */
|
||||
export const $EnumFromDescription = {
|
||||
type: 'number',
|
||||
description: 'Success=1,Warning=2,Error=3',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1486,6 +1492,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtends.ts 1`
|
||||
/* eslint-disable */
|
||||
export const $ModelThatExtends = {
|
||||
type: 'all-of',
|
||||
description: 'This is a model that extends another model',
|
||||
contains: [{
|
||||
type: 'ModelWithString',
|
||||
}, {
|
||||
@ -1507,6 +1514,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelThatExtendsExtend
|
||||
/* eslint-disable */
|
||||
export const $ModelThatExtendsExtends = {
|
||||
type: 'all-of',
|
||||
description: 'This is a model that extends another model',
|
||||
contains: [{
|
||||
type: 'ModelWithString',
|
||||
}, {
|
||||
@ -1529,6 +1537,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithArray.ts 1`]
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithArray = {
|
||||
description: 'This is a model with one property containing an array',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'array',
|
||||
@ -1557,9 +1566,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithBoolean.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithBoolean = {
|
||||
description: 'This is a model with one boolean property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'boolean',
|
||||
description: 'This is a simple boolean property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -1570,6 +1581,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithCircularRefer
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithCircularReference = {
|
||||
description: 'This is a model with one property containing a circular reference',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithCircularReference',
|
||||
@ -1583,6 +1595,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDictionary.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDictionary = {
|
||||
description: 'This is a model with one property containing a dictionary',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'dictionary',
|
||||
@ -1599,6 +1612,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateImpo
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDuplicateImports = {
|
||||
description: 'This is a model with duplicated imports',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'ModelWithString',
|
||||
@ -1618,6 +1632,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithDuplicateProp
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDuplicateProperties = {
|
||||
description: 'This is a model with duplicated properties',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithString',
|
||||
@ -1631,6 +1646,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnum.ts 1`] =
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithEnum = {
|
||||
description: 'This is a model with one enum',
|
||||
properties: {
|
||||
test: {
|
||||
type: 'Enum',
|
||||
@ -1640,6 +1656,7 @@ export const $ModelWithEnum = {
|
||||
},
|
||||
bool: {
|
||||
type: 'boolean',
|
||||
description: 'Simple boolean enum',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -1650,6 +1667,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithEnumFromDescr
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithEnumFromDescription = {
|
||||
description: 'This is a model with one enum',
|
||||
properties: {
|
||||
test: {
|
||||
type: 'Enum',
|
||||
@ -1663,9 +1681,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithInteger.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithInteger = {
|
||||
description: 'This is a model with one number property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'number',
|
||||
description: 'This is a simple number property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -1676,6 +1696,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedEnums.t
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNestedEnums = {
|
||||
description: 'This is a model with nested enums',
|
||||
properties: {
|
||||
dictionaryWithEnum: {
|
||||
type: 'dictionary',
|
||||
@ -1710,6 +1731,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNestedPropert
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNestedProperties = {
|
||||
description: 'This is a model with one nested property',
|
||||
properties: {
|
||||
first: {
|
||||
properties: {
|
||||
@ -1737,13 +1759,16 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithNullableStrin
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNullableString = {
|
||||
description: 'This is a model with one string property',
|
||||
properties: {
|
||||
nullableProp: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isNullable: true,
|
||||
},
|
||||
nullableRequiredProp: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isRequired: true,
|
||||
isNullable: true,
|
||||
},
|
||||
@ -1756,6 +1781,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithOrderedProper
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithOrderedProperties = {
|
||||
description: 'This is a model with ordered properties',
|
||||
properties: {
|
||||
zebra: {
|
||||
type: 'string',
|
||||
@ -1775,6 +1801,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithPattern.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithPattern = {
|
||||
description: 'This is a model that contains a some patterns',
|
||||
properties: {
|
||||
key: {
|
||||
type: 'string',
|
||||
@ -1813,6 +1840,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithProperties.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithProperties = {
|
||||
description: 'This is a model with one nested property',
|
||||
properties: {
|
||||
required: {
|
||||
type: 'string',
|
||||
@ -1861,6 +1889,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithReference.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithReference = {
|
||||
description: 'This is a model with one property containing a reference',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithProperties',
|
||||
@ -1874,9 +1903,11 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$ModelWithString.ts 1`]
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithString = {
|
||||
description: 'This is a model with one string property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -1888,6 +1919,10 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$MultilineComment.ts 1`
|
||||
/* eslint-disable */
|
||||
export const $MultilineComment = {
|
||||
type: 'number',
|
||||
description: 'Testing multiline comments.
|
||||
* This must go to the next line.
|
||||
*
|
||||
* This will contain a break.',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1897,6 +1932,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleBoolean.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleBoolean = {
|
||||
type: 'boolean',
|
||||
description: 'This is a simple boolean',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1906,6 +1942,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = `
|
||||
/* eslint-disable */
|
||||
export const $SimpleFile = {
|
||||
type: 'binary',
|
||||
description: 'This is a simple file',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1915,6 +1952,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleInteger.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleInteger = {
|
||||
type: 'number',
|
||||
description: 'This is a simple number',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1924,6 +1962,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleReference.ts 1`]
|
||||
/* eslint-disable */
|
||||
export const $SimpleReference = {
|
||||
type: 'ModelWithString',
|
||||
description: 'This is a simple reference',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1933,6 +1972,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleString.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleString = {
|
||||
type: 'string',
|
||||
description: 'This is a simple string',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -1942,6 +1982,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleStringWithPatter
|
||||
/* eslint-disable */
|
||||
export const $SimpleStringWithPattern = {
|
||||
type: 'string',
|
||||
description: 'This is a simple string',
|
||||
maxLength: 64,
|
||||
pattern: '^[a-zA-Z0-9_]*$',
|
||||
} as const;"
|
||||
@ -2896,6 +2937,10 @@ function isBlob(value: any): value is Blob {
|
||||
return value instanceof Blob;
|
||||
}
|
||||
|
||||
function isFormData(value: any): value is FormData {
|
||||
return value instanceof FormData;
|
||||
}
|
||||
|
||||
function base64(str: string): string {
|
||||
try {
|
||||
return btoa(str);
|
||||
@ -3010,7 +3055,7 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
|
||||
headers.append('Content-Type', options.body.type || 'application/octet-stream');
|
||||
} else if (isString(options.body)) {
|
||||
headers.append('Content-Type', 'text/plain');
|
||||
} else {
|
||||
} else if (!isFormData(options.body)) {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
@ -3022,7 +3067,7 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
|
||||
if (options.body) {
|
||||
if (options.mediaType?.includes('/json')) {
|
||||
return JSON.stringify(options.body)
|
||||
} else if (isString(options.body) || isBlob(options.body)) {
|
||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
||||
return options.body;
|
||||
} else {
|
||||
return JSON.stringify(options.body);
|
||||
@ -3169,6 +3214,7 @@ export type { CompositionWithAnyOfAnonymous } from './models/CompositionWithAnyO
|
||||
export type { CompositionWithOneOf } from './models/CompositionWithOneOf';
|
||||
export type { CompositionWithOneOfAndNullable } from './models/CompositionWithOneOfAndNullable';
|
||||
export type { CompositionWithOneOfAnonymous } from './models/CompositionWithOneOfAnonymous';
|
||||
export type { CompositionWithOneOfDiscriminator } from './models/CompositionWithOneOfDiscriminator';
|
||||
export type { DictionaryWithArray } from './models/DictionaryWithArray';
|
||||
export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
|
||||
export type { DictionaryWithProperties } from './models/DictionaryWithProperties';
|
||||
@ -3178,6 +3224,8 @@ export type { EnumFromDescription } from './models/EnumFromDescription';
|
||||
export { EnumWithExtensions } from './models/EnumWithExtensions';
|
||||
export { EnumWithNumbers } from './models/EnumWithNumbers';
|
||||
export { EnumWithStrings } from './models/EnumWithStrings';
|
||||
export type { ModelCircle } from './models/ModelCircle';
|
||||
export type { ModelSquare } from './models/ModelSquare';
|
||||
export type { ModelThatExtends } from './models/ModelThatExtends';
|
||||
export type { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends';
|
||||
export type { ModelWithArray } from './models/ModelWithArray';
|
||||
@ -3220,6 +3268,7 @@ export { $CompositionWithAnyOfAnonymous } from './schemas/$CompositionWithAnyOfA
|
||||
export { $CompositionWithOneOf } from './schemas/$CompositionWithOneOf';
|
||||
export { $CompositionWithOneOfAndNullable } from './schemas/$CompositionWithOneOfAndNullable';
|
||||
export { $CompositionWithOneOfAnonymous } from './schemas/$CompositionWithOneOfAnonymous';
|
||||
export { $CompositionWithOneOfDiscriminator } from './schemas/$CompositionWithOneOfDiscriminator';
|
||||
export { $DictionaryWithArray } from './schemas/$DictionaryWithArray';
|
||||
export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary';
|
||||
export { $DictionaryWithProperties } from './schemas/$DictionaryWithProperties';
|
||||
@ -3229,6 +3278,8 @@ export { $EnumFromDescription } from './schemas/$EnumFromDescription';
|
||||
export { $EnumWithExtensions } from './schemas/$EnumWithExtensions';
|
||||
export { $EnumWithNumbers } from './schemas/$EnumWithNumbers';
|
||||
export { $EnumWithStrings } from './schemas/$EnumWithStrings';
|
||||
export { $ModelCircle } from './schemas/$ModelCircle';
|
||||
export { $ModelSquare } from './schemas/$ModelSquare';
|
||||
export { $ModelThatExtends } from './schemas/$ModelThatExtends';
|
||||
export { $ModelThatExtendsExtends } from './schemas/$ModelThatExtendsExtends';
|
||||
export { $ModelWithArray } from './schemas/$ModelWithArray';
|
||||
@ -3513,6 +3564,21 @@ export type CompositionWithOneOfAnonymous = {
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/CompositionWithOneOfDiscriminator.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import type { ModelCircle } from './ModelCircle';
|
||||
import type { ModelSquare } from './ModelSquare';
|
||||
|
||||
/**
|
||||
* This is a model with one property with a 'one of' relationship where the options are not $ref
|
||||
*/
|
||||
export type CompositionWithOneOfDiscriminator = (ModelCircle | ModelSquare);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/DictionaryWithArray.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -3652,6 +3718,36 @@ export enum EnumWithStrings {
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/ModelCircle.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* Circle
|
||||
*/
|
||||
export type ModelCircle = {
|
||||
kind: 'circle';
|
||||
radius?: number;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/ModelSquare.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* Square
|
||||
*/
|
||||
export type ModelSquare = {
|
||||
kind: 'square';
|
||||
sideLength?: number;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtends.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -4211,6 +4307,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionBaseModel.t
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionBaseModel = {
|
||||
description: 'This is a base model with two simple optional properties',
|
||||
properties: {
|
||||
firstName: {
|
||||
type: 'string',
|
||||
@ -4228,6 +4325,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionExtendedMod
|
||||
/* eslint-disable */
|
||||
export const $CompositionExtendedModel = {
|
||||
type: 'all-of',
|
||||
description: 'This is a model that extends the base model',
|
||||
contains: [{
|
||||
type: 'CompositionBaseModel',
|
||||
}, {
|
||||
@ -4254,6 +4352,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAllOfAn
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithAllOfAndNullable = {
|
||||
description: 'This is a model with one property with a \\\\'all of\\\\' relationship',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'all-of',
|
||||
@ -4281,6 +4380,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOf.t
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithAnyOf = {
|
||||
description: 'This is a model with one property with a \\\\'any of\\\\' relationship',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'any-of',
|
||||
@ -4303,6 +4403,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAn
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithAnyOfAndNullable = {
|
||||
description: 'This is a model with one property with a \\\\'any of\\\\' relationship',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'any-of',
|
||||
@ -4330,10 +4431,12 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithAnyOfAn
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithAnyOfAnonymous = {
|
||||
description: 'This is a model with one property with a \\\\'any of\\\\' relationship where the options are not $ref',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'any-of',
|
||||
contains: [{
|
||||
description: 'Anonymous object type',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'string',
|
||||
@ -4341,8 +4444,10 @@ export const $CompositionWithAnyOfAnonymous = {
|
||||
},
|
||||
}, {
|
||||
type: 'string',
|
||||
description: 'Anonymous string type',
|
||||
}, {
|
||||
type: 'number',
|
||||
description: 'Anonymous integer type',
|
||||
}],
|
||||
},
|
||||
},
|
||||
@ -4354,6 +4459,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOf.t
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithOneOf = {
|
||||
description: 'This is a model with one property with a \\\\'one of\\\\' relationship',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'one-of',
|
||||
@ -4376,6 +4482,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAn
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithOneOfAndNullable = {
|
||||
description: 'This is a model with one property with a \\\\'one of\\\\' relationship',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'one-of',
|
||||
@ -4403,10 +4510,12 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfAn
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithOneOfAnonymous = {
|
||||
description: 'This is a model with one property with a \\\\'one of\\\\' relationship where the options are not $ref',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'one-of',
|
||||
contains: [{
|
||||
description: 'Anonymous object type',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'string',
|
||||
@ -4414,14 +4523,30 @@ export const $CompositionWithOneOfAnonymous = {
|
||||
},
|
||||
}, {
|
||||
type: 'string',
|
||||
description: 'Anonymous string type',
|
||||
}, {
|
||||
type: 'number',
|
||||
description: 'Anonymous integer type',
|
||||
}],
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionWithOneOfDiscriminator.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $CompositionWithOneOfDiscriminator = {
|
||||
type: 'one-of',
|
||||
contains: [{
|
||||
type: 'ModelCircle',
|
||||
}, {
|
||||
type: 'ModelSquare',
|
||||
}],
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$DictionaryWithArray.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -4501,6 +4626,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$EnumFromDescription.ts
|
||||
/* eslint-disable */
|
||||
export const $EnumFromDescription = {
|
||||
type: 'number',
|
||||
description: 'Success=1,Warning=2,Error=3',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -4531,12 +4657,47 @@ export const $EnumWithStrings = {
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$ModelCircle.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelCircle = {
|
||||
properties: {
|
||||
kind: {
|
||||
type: 'string',
|
||||
isRequired: true,
|
||||
},
|
||||
radius: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$ModelSquare.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelSquare = {
|
||||
properties: {
|
||||
kind: {
|
||||
type: 'string',
|
||||
isRequired: true,
|
||||
},
|
||||
sideLength: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtends.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelThatExtends = {
|
||||
type: 'all-of',
|
||||
description: 'This is a model that extends another model',
|
||||
contains: [{
|
||||
type: 'ModelWithString',
|
||||
}, {
|
||||
@ -4558,6 +4719,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelThatExtendsExtend
|
||||
/* eslint-disable */
|
||||
export const $ModelThatExtendsExtends = {
|
||||
type: 'all-of',
|
||||
description: 'This is a model that extends another model',
|
||||
contains: [{
|
||||
type: 'ModelWithString',
|
||||
}, {
|
||||
@ -4580,6 +4742,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithArray.ts 1`]
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithArray = {
|
||||
description: 'This is a model with one property containing an array',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'array',
|
||||
@ -4608,9 +4771,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithBoolean.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithBoolean = {
|
||||
description: 'This is a model with one boolean property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'boolean',
|
||||
description: 'This is a simple boolean property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -4621,6 +4786,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithCircularRefer
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithCircularReference = {
|
||||
description: 'This is a model with one property containing a circular reference',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithCircularReference',
|
||||
@ -4634,6 +4800,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDictionary.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDictionary = {
|
||||
description: 'This is a model with one property containing a dictionary',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'dictionary',
|
||||
@ -4650,6 +4817,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateImpo
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDuplicateImports = {
|
||||
description: 'This is a model with duplicated imports',
|
||||
properties: {
|
||||
propA: {
|
||||
type: 'ModelWithString',
|
||||
@ -4669,6 +4837,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithDuplicateProp
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithDuplicateProperties = {
|
||||
description: 'This is a model with duplicated properties',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithString',
|
||||
@ -4682,6 +4851,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnum.ts 1`] =
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithEnum = {
|
||||
description: 'This is a model with one enum',
|
||||
properties: {
|
||||
test: {
|
||||
type: 'Enum',
|
||||
@ -4691,6 +4861,7 @@ export const $ModelWithEnum = {
|
||||
},
|
||||
bool: {
|
||||
type: 'boolean',
|
||||
description: 'Simple boolean enum',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -4701,6 +4872,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithEnumFromDescr
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithEnumFromDescription = {
|
||||
description: 'This is a model with one enum',
|
||||
properties: {
|
||||
test: {
|
||||
type: 'Enum',
|
||||
@ -4714,9 +4886,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithInteger.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithInteger = {
|
||||
description: 'This is a model with one number property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'number',
|
||||
description: 'This is a simple number property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -4727,6 +4901,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedEnums.t
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNestedEnums = {
|
||||
description: 'This is a model with nested enums',
|
||||
properties: {
|
||||
dictionaryWithEnum: {
|
||||
type: 'dictionary',
|
||||
@ -4761,6 +4936,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNestedPropert
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNestedProperties = {
|
||||
description: 'This is a model with one nested property',
|
||||
properties: {
|
||||
first: {
|
||||
properties: {
|
||||
@ -4791,22 +4967,27 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithNullableStrin
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithNullableString = {
|
||||
description: 'This is a model with one string property',
|
||||
properties: {
|
||||
nullableProp1: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isNullable: true,
|
||||
},
|
||||
nullableRequiredProp1: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isRequired: true,
|
||||
isNullable: true,
|
||||
},
|
||||
nullableProp2: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isNullable: true,
|
||||
},
|
||||
nullableRequiredProp2: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
isRequired: true,
|
||||
isNullable: true,
|
||||
},
|
||||
@ -4819,6 +5000,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithOrderedProper
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithOrderedProperties = {
|
||||
description: 'This is a model with ordered properties',
|
||||
properties: {
|
||||
zebra: {
|
||||
type: 'string',
|
||||
@ -4838,6 +5020,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithPattern.ts 1`
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithPattern = {
|
||||
description: 'This is a model that contains a some patterns',
|
||||
properties: {
|
||||
key: {
|
||||
type: 'string',
|
||||
@ -4876,6 +5059,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithProperties.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithProperties = {
|
||||
description: 'This is a model with one nested property',
|
||||
properties: {
|
||||
required: {
|
||||
type: 'string',
|
||||
@ -4929,6 +5113,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithReference.ts
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithReference = {
|
||||
description: 'This is a model with one property containing a reference',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'ModelWithProperties',
|
||||
@ -4942,9 +5127,11 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$ModelWithString.ts 1`]
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $ModelWithString = {
|
||||
description: 'This is a model with one string property',
|
||||
properties: {
|
||||
prop: {
|
||||
type: 'string',
|
||||
description: 'This is a simple string property',
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
@ -4956,6 +5143,10 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$MultilineComment.ts 1`
|
||||
/* eslint-disable */
|
||||
export const $MultilineComment = {
|
||||
type: 'number',
|
||||
description: 'Testing multiline comments.
|
||||
* This must go to the next line.
|
||||
*
|
||||
* This will contain a break.',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -4965,6 +5156,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleBoolean = {
|
||||
type: 'boolean',
|
||||
description: 'This is a simple boolean',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -4974,6 +5166,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = `
|
||||
/* eslint-disable */
|
||||
export const $SimpleFile = {
|
||||
type: 'binary',
|
||||
description: 'This is a simple file',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -4983,6 +5176,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleInteger.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleInteger = {
|
||||
type: 'number',
|
||||
description: 'This is a simple number',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -4992,6 +5186,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleReference.ts 1`]
|
||||
/* eslint-disable */
|
||||
export const $SimpleReference = {
|
||||
type: 'ModelWithString',
|
||||
description: 'This is a simple reference',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -5001,6 +5196,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleString.ts 1`] =
|
||||
/* eslint-disable */
|
||||
export const $SimpleString = {
|
||||
type: 'string',
|
||||
description: 'This is a simple string',
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
@ -5010,6 +5206,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleStringWithPatter
|
||||
/* eslint-disable */
|
||||
export const $SimpleStringWithPattern = {
|
||||
type: 'string',
|
||||
description: 'This is a simple string',
|
||||
isNullable: true,
|
||||
maxLength: 64,
|
||||
pattern: '^[a-zA-Z0-9_]*$',
|
||||
|
||||
@ -1863,6 +1863,51 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelCircle": {
|
||||
"description": "Circle",
|
||||
"type": "object",
|
||||
"required": ["kind"],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"radius": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelSquare": {
|
||||
"description": "Square",
|
||||
"type": "object",
|
||||
"required": ["kind"],
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string"
|
||||
},
|
||||
"sideLength": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CompositionWithOneOfDiscriminator": {
|
||||
"description": "This is a model with one property with a 'one of' relationship where the options are not $ref",
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ModelCircle"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/ModelSquare"
|
||||
}
|
||||
],
|
||||
"discriminator": {
|
||||
"propertyName": "kind",
|
||||
"mapping": {
|
||||
"circle": "#/components/schemas/ModelCircle",
|
||||
"square": "#/components/schemas/ModelSquare"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CompositionWithAnyOf": {
|
||||
"description": "This is a model with one property with a 'any of' relationship",
|
||||
"type": "object",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user