From ce0bcf51f66bc98753c0fcd2541fc1c2d5762688 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 8 Apr 2024 02:17:12 +0100 Subject: [PATCH 1/3] chore(parser): pass openAPI schema to write methods --- packages/openapi-ts/src/compiler/types.ts | 3 + packages/openapi-ts/src/compiler/utils.ts | 7 + packages/openapi-ts/src/index.ts | 2 +- .../src/utils/write/__tests__/class.spec.ts | 51 +- .../src/utils/write/__tests__/client.spec.ts | 5 +- .../src/utils/write/__tests__/core.spec.ts | 15 +- .../src/utils/write/__tests__/models.spec.ts | 6 +- .../src/utils/write/__tests__/models.ts | 11 + .../src/utils/write/__tests__/schemas.spec.ts | 6 +- .../utils/write/__tests__/services.spec.ts | 49 +- packages/openapi-ts/src/utils/write/class.ts | 9 +- packages/openapi-ts/src/utils/write/client.ts | 23 +- packages/openapi-ts/src/utils/write/core.ts | 9 +- packages/openapi-ts/src/utils/write/models.ts | 7 +- .../openapi-ts/src/utils/write/schemas.ts | 11 +- .../openapi-ts/src/utils/write/services.ts | 9 +- .../test/generated/v2/schemas.ts.snap | 1440 ++++++++ .../test/generated/v3/schemas.ts.snap | 3047 +++++++++++++++++ .../test/generated/v3_angular/schemas.ts.snap | 3047 +++++++++++++++++ .../test/generated/v3_date/schemas.ts.snap | 3047 +++++++++++++++++ .../v3_enums_typescript/schemas.ts.snap | 3047 +++++++++++++++++ .../generated/v3_experimental/schemas.ts.snap | 3047 +++++++++++++++++ 22 files changed, 16817 insertions(+), 81 deletions(-) create mode 100644 packages/openapi-ts/src/utils/write/__tests__/models.ts diff --git a/packages/openapi-ts/src/compiler/types.ts b/packages/openapi-ts/src/compiler/types.ts index 6545ccf41..a706bb6d1 100644 --- a/packages/openapi-ts/src/compiler/types.ts +++ b/packages/openapi-ts/src/compiler/types.ts @@ -57,6 +57,9 @@ export const createObjectType = (obj: T, multiLine: boolean = Object.entries(obj) .map(([key, value]) => { const initializer = toExpression(value); + if (key.match(/\W/g) && !key.startsWith("'") && !key.endsWith("'")) { + key = `'${key}'`; + } return initializer ? ts.factory.createPropertyAssignment(key, initializer) : undefined; }) .filter(isType), diff --git a/packages/openapi-ts/src/compiler/utils.ts b/packages/openapi-ts/src/compiler/utils.ts index 86e0b6219..aaff57f38 100644 --- a/packages/openapi-ts/src/compiler/utils.ts +++ b/packages/openapi-ts/src/compiler/utils.ts @@ -61,6 +61,13 @@ export const ots = { if (unescape) { value = unescapeName(value); } + if ( + (value.includes('\n') || (value.includes("'") && value.includes('"'))) && + !value.startsWith('`') && + !value.endsWith('`') + ) { + value = `\`${value}\``; + } const text = encodeURIComponent(value); if (value.startsWith('`')) { return ts.factory.createIdentifier(text); diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index 533e1e5d5..f3a43c50b 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -198,7 +198,7 @@ export async function createClient(userConfig: UserConfig): Promise { if (config.write) { logClientMessage(config.client); logMissingDependenciesWarning(config.client, dependencies); - await writeClient(client, templates, config); + await writeClient(openApi, client, templates, config); processOutput(config, dependencies); } diff --git a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts index 8363e22c3..9b1736f82 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts @@ -4,12 +4,13 @@ import { describe, expect, it, vi } from 'vitest'; import { writeClientClass } from '../class'; import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClientClass', () => { it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -17,27 +18,33 @@ describe('writeClientClass', () => { version: 'v1', }; - await writeClientClass(client, mockTemplates, './dist', { - client: 'fetch', - debug: false, - enums: 'javascript', - experimental: false, - exportCore: true, - exportModels: true, - exportSchemas: true, - exportServices: true, - format: false, - input: '', - lint: false, - name: 'AppClient', - operationId: true, - output: '', - postfixServices: '', - serviceResponse: 'body', - useDateType: false, - useOptions: true, - write: true, - }); + await writeClientClass( + openApi, + client, + './dist', + { + client: 'fetch', + debug: false, + enums: 'javascript', + experimental: false, + exportCore: true, + exportModels: true, + exportSchemas: true, + exportServices: true, + format: false, + input: '', + lint: false, + name: 'AppClient', + operationId: true, + output: '', + postfixServices: '', + serviceResponse: 'body', + useDateType: false, + useOptions: true, + write: true, + }, + mockTemplates + ); expect(writeFileSync).toHaveBeenCalled(); }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts index 6dfd266bc..889f1ad9a 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/client.spec.ts @@ -4,12 +4,13 @@ import { describe, expect, it, vi } from 'vitest'; import { writeClient } from '../client'; import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClient', () => { it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -17,7 +18,7 @@ describe('writeClient', () => { version: 'v1', }; - await writeClient(client, mockTemplates, { + await writeClient(openApi, client, mockTemplates, { client: 'fetch', debug: false, enums: 'javascript', diff --git a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts index bd5373d6d..4de9526aa 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts @@ -5,17 +5,18 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { writeClientCore } from '../core'; import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClientCore', () => { - let templates: Parameters[1]; + let templates: Parameters[4]; beforeEach(() => { templates = mockTemplates; }); it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -45,7 +46,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(client, templates, '/', config); + await writeClientCore(openApi, client, '/', config, templates); expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/OpenAPI.ts'), 'settings'); expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/ApiError.ts'), 'apiError'); @@ -57,7 +58,7 @@ describe('writeClientCore', () => { }); it('uses client server value for base', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -87,7 +88,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(client, templates, '/', config); + await writeClientCore(openApi, client, '/', config, templates); expect(templates.core.settings).toHaveBeenCalledWith({ $config: config, @@ -98,7 +99,7 @@ describe('writeClientCore', () => { }); it('uses custom value for base', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -129,7 +130,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(client, templates, '/', config); + await writeClientCore(openApi, client, '/', config, templates); expect(templates.core.settings).toHaveBeenCalledWith({ $config: config, diff --git a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts index 7132b7053..b360b5e53 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts @@ -4,13 +4,13 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientModels } from '../models'; -import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClientModels', () => { it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [ { @@ -37,7 +37,7 @@ describe('writeClientModels', () => { version: 'v1', }; - await writeClientModels(client, mockTemplates, '/', { + await writeClientModels(openApi, client, '/', { client: 'fetch', debug: false, enums: 'javascript', diff --git a/packages/openapi-ts/src/utils/write/__tests__/models.ts b/packages/openapi-ts/src/utils/write/__tests__/models.ts new file mode 100644 index 000000000..be2e5c826 --- /dev/null +++ b/packages/openapi-ts/src/utils/write/__tests__/models.ts @@ -0,0 +1,11 @@ +import type { OpenApi } from '../../../openApi'; + +export const openApi: OpenApi = { + info: { + title: '', + version: '', + }, + openapi: '', + paths: {}, + swagger: '', +}; diff --git a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts index 27567d117..d8296b07d 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts @@ -4,13 +4,13 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import { writeClientSchemas } from '../schemas'; -import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClientSchemas', () => { it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [ { @@ -37,7 +37,7 @@ describe('writeClientSchemas', () => { version: 'v1', }; - await writeClientSchemas(client, mockTemplates, '/', { + await writeClientSchemas(openApi, client, '/', { client: 'fetch', debug: false, enums: 'javascript', diff --git a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts index e7661e948..630f93819 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts @@ -4,12 +4,13 @@ import { describe, expect, it, vi } from 'vitest'; import { writeClientServices } from '../services'; import { mockTemplates } from './mocks'; +import { openApi } from './models'; vi.mock('node:fs'); describe('writeClientServices', () => { it('should write to filesystem', async () => { - const client: Parameters[0] = { + const client: Parameters[1] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -24,26 +25,32 @@ describe('writeClientServices', () => { version: 'v1', }; - await writeClientServices(client, mockTemplates, '/', { - client: 'fetch', - debug: false, - enums: false, - experimental: false, - exportCore: true, - exportModels: true, - exportSchemas: true, - exportServices: true, - format: false, - input: '', - lint: false, - operationId: true, - output: '', - postfixServices: 'Service', - serviceResponse: 'body', - useDateType: false, - useOptions: false, - write: true, - }); + await writeClientServices( + openApi, + client, + '/', + { + client: 'fetch', + debug: false, + enums: false, + experimental: false, + exportCore: true, + exportModels: true, + exportSchemas: true, + exportServices: true, + format: false, + input: '', + lint: false, + operationId: true, + output: '', + postfixServices: 'Service', + serviceResponse: 'body', + useDateType: false, + useOptions: false, + write: true, + }, + mockTemplates + ); expect(writeFileSync).toHaveBeenCalled(); }); diff --git a/packages/openapi-ts/src/utils/write/class.ts b/packages/openapi-ts/src/utils/write/class.ts index 8240b76de..4a4943751 100644 --- a/packages/openapi-ts/src/utils/write/class.ts +++ b/packages/openapi-ts/src/utils/write/class.ts @@ -1,6 +1,7 @@ import { writeFileSync } from 'node:fs'; import path from 'node:path'; +import type { OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { getHttpRequestName } from '../getHttpRequestName'; @@ -11,16 +12,18 @@ import { sortByName } from '../sort'; * Generate the OpenAPI client index file using the Handlebar template and write it to disk. * The index file just contains all the exports you need to use the client as a standalone * library. But yuo can also import individual models and services directly. + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services - * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param config {@link Config} passed to the `createClient()` method + * @param templates The loaded handlebar templates */ export const writeClientClass = async ( + openApi: OpenApi, client: Client, - templates: Templates, outputPath: string, - config: Config + config: Config, + templates: Templates ): Promise => { const templateResult = templates.client({ $config: config, diff --git a/packages/openapi-ts/src/utils/write/client.ts b/packages/openapi-ts/src/utils/write/client.ts index 247d08c6e..f33c19a93 100644 --- a/packages/openapi-ts/src/utils/write/client.ts +++ b/packages/openapi-ts/src/utils/write/client.ts @@ -1,6 +1,7 @@ import { mkdirSync, rmSync } from 'node:fs'; import path from 'node:path'; +import type { OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import type { Templates } from '../handlebars'; @@ -13,11 +14,17 @@ import { writeClientServices } from './services'; /** * Write our OpenAPI client, using the given templates at the given output + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services * @param templates Templates wrapper with all loaded Handlebars templates * @param config {@link Config} passed to the `createClient()` method */ -export const writeClient = async (client: Client, templates: Templates, config: Config): Promise => { +export const writeClient = async ( + openApi: OpenApi, + client: Client, + templates: Templates, + config: Config +): Promise => { await rmSync(config.output, { force: true, recursive: true, @@ -73,10 +80,16 @@ export const writeClient = async (client: Client, templates: Templates, config: await mkdirSync(sectionPath, { recursive: true, }); - await section.fn(client, templates, sectionPath, { - ...config, - name: config.name!, - }); + await section.fn( + openApi, + client, + sectionPath, + { + ...config, + name: config.name!, + }, + templates + ); } } diff --git a/packages/openapi-ts/src/utils/write/core.ts b/packages/openapi-ts/src/utils/write/core.ts index ea563280f..ece4566c4 100644 --- a/packages/openapi-ts/src/utils/write/core.ts +++ b/packages/openapi-ts/src/utils/write/core.ts @@ -1,6 +1,7 @@ import { copyFileSync, existsSync, writeFileSync } from 'node:fs'; import path from 'node:path'; +import type { OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { getHttpRequestName } from '../getHttpRequestName'; @@ -8,16 +9,18 @@ import type { Templates } from '../handlebars'; /** * Generate OpenAPI core files, this includes the basic boilerplate code to handle requests. + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services - * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param config {@link Config} passed to the `createClient()` method + * @param templates The loaded handlebar templates */ export const writeClientCore = async ( + openApi: OpenApi, client: Client, - templates: Templates, outputPath: string, - config: Config + config: Config, + templates: Templates ): Promise => { const context = { httpRequest: getHttpRequestName(config.client), diff --git a/packages/openapi-ts/src/utils/write/models.ts b/packages/openapi-ts/src/utils/write/models.ts index 20ec76a48..52be84f45 100644 --- a/packages/openapi-ts/src/utils/write/models.ts +++ b/packages/openapi-ts/src/utils/write/models.ts @@ -5,12 +5,11 @@ import ts from 'typescript'; import compiler, { TypeScriptFile } from '../../compiler'; import { toExpression } from '../../compiler/types'; import { isType } from '../../compiler/utils'; -import type { Model } from '../../openApi'; +import type { Model, OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { enumKey, enumName, enumUnionType, enumValue } from '../enum'; import { escapeComment } from '../escape'; -import type { Templates } from '../handlebars'; import { addLeadingJSDocComment, toType } from './type'; type Nodes = Array; @@ -165,14 +164,14 @@ const processModel = (config: Config, client: Client, model: Model) => { /** * Generate Models using the Handlebar template and write to disk. + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services - * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param config {@link Config} passed to the `createClient()` method */ export const writeClientModels = async ( + openApi: OpenApi, client: Client, - templates: Templates, outputPath: string, config: Config ): Promise => { diff --git a/packages/openapi-ts/src/utils/write/schemas.ts b/packages/openapi-ts/src/utils/write/schemas.ts index 74f201f64..682d22a6e 100644 --- a/packages/openapi-ts/src/utils/write/schemas.ts +++ b/packages/openapi-ts/src/utils/write/schemas.ts @@ -1,11 +1,10 @@ import path from 'node:path'; import compiler, { TypeScriptFile } from '../../compiler'; -import type { Model } from '../../openApi'; +import type { Model, OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { escapeDescription } from '../escape'; -import type { Templates } from '../handlebars'; const escapeNewline = (value: string) => value.replace(/\n/g, '\\n'); @@ -275,14 +274,14 @@ const exportSchema = (config: Config, model: Model) => { /** * Generate Schemas using the Handlebar template and write to disk. + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services - * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param config {@link Config} passed to the `createClient()` method */ export const writeClientSchemas = async ( + openApi: OpenApi, client: Client, - templates: Templates, outputPath: string, config: Config ): Promise => { @@ -295,5 +294,9 @@ export const writeClientSchemas = async ( const result = exportSchema(config, model); file.add(result); } + + const expression = compiler.types.object(openApi); + file.add(compiler.export.asConst(`$OpenApi`, expression)); + file.write(path.resolve(outputPath, 'schemas.ts'), '\n\n'); }; diff --git a/packages/openapi-ts/src/utils/write/services.ts b/packages/openapi-ts/src/utils/write/services.ts index 1b1a032eb..c18faa515 100644 --- a/packages/openapi-ts/src/utils/write/services.ts +++ b/packages/openapi-ts/src/utils/write/services.ts @@ -2,6 +2,7 @@ import { writeFileSync } from 'node:fs'; import path from 'node:path'; import { TypeScriptFile } from '../../compiler'; +import type { OpenApi } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { operationDataType, type Templates } from '../handlebars'; @@ -9,16 +10,18 @@ import { unique } from '../unique'; /** * Generate Services using the Handlebar template and write to disk. + * @param openApi {@link OpenApi} Dereferenced OpenAPI specification * @param client Client containing models, schemas, and services - * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to * @param config {@link Config} passed to the `createClient()` method + * @param templates The loaded handlebar templates */ export const writeClientServices = async ( + openApi: OpenApi, client: Client, - templates: Templates, outputPath: string, - config: Config + config: Config, + templates: Templates ): Promise => { if (!client.services.length) { return; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap index 77ac1586b..d580dd7f8 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap @@ -558,3 +558,1443 @@ export const $ModelWithPattern = { }, }, } as const; + +export const $OpenApi = { + swagger: '2.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + host: 'localhost:3000', + basePath: '/base', + schemes: ['http'], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that is sent as request body', + name: 'parameterBody', + in: 'body', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + type: 'string', + required: true, + }, + { + name: 'api-version', + in: 'path', + type: 'string', + required: true, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + type: 'string', + required: false, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + type: 'string', + required: false, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + type: 'string', + required: false, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + type: 'string', + required: false, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + type: 'string', + required: true, + }, + { + description: 'This is the parameter that is sent as request body', + name: 'PARAMETER-BODY', + in: 'body', + type: 'string', + required: true, + }, + { + name: 'api-version', + in: 'path', + type: 'string', + required: true, + }, + ], + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + required: true, + default: 'Hello World!', + type: 'string', + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + required: true, + default: 123, + type: 'number', + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + required: true, + default: true, + type: 'boolean', + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + required: true, + default: 0, + schema: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + required: true, + default: { + prop: 'Hello World!', + }, + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + default: 'Hello World!', + type: 'string', + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + default: 123, + type: 'number', + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + default: true, + type: 'boolean', + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + default: 0, + schema: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + default: { + prop: 'Hello World!', + }, + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + default: 'Hello World!', + type: 'string', + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + default: '', + type: 'string', + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + type: 'string', + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + default: 'Hello World!', + type: 'string', + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + default: '', + type: 'string', + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + type: 'string', + }, + { + 'x-nullable': true, + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + type: 'string', + }, + { + 'x-nullable': true, + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + type: 'string', + default: null, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate', 'Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate', 'Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate', 'Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate', 'Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + description: 'Message for default response', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 202: { + description: 'Message for 202 response', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 500: { + description: 'Message for 500 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 501: { + description: 'Message for 501 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 502: { + description: 'Message for 502 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + default: { + description: 'Message for default response', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + schema: { + $ref: '#/definitions/ModelThatExtends', + }, + }, + 202: { + description: 'Message for 202 response', + schema: { + $ref: '#/definitions/ModelThatExtendsExtends', + }, + }, + 500: { + description: 'Message for 500 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 501: { + description: 'Message for 501 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + 502: { + description: 'Message for 502 error', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + default: { + description: 'Message for default response', + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + default: 123, + type: 'number', + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + default: 'default', + type: 'string', + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + default: true, + type: 'boolean', + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + default: null, + type: 'object', + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + type: 'array', + items: { + type: 'string', + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + type: 'object', + items: { + type: 'string', + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + schema: { + type: 'number', + }, + }, + 201: { + description: 'Response is a simple string', + schema: { + type: 'string', + }, + }, + 202: { + description: 'Response is a simple boolean', + schema: { + type: 'boolean', + }, + }, + 203: { + description: 'Response is a simple object', + default: null, + schema: { + type: 'object', + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/definitions/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + schema: { + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + type: 'string', + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + type: 'string', + required: true, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + schema: { + $ref: '#/definitions/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + definitions: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/definitions/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/definitions/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + Date: { + description: 'This is a type-only model that defines Date as a string', + type: 'string', + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp'], + properties: { + nullableProp: { + description: 'This is a simple string property', + type: 'string', + 'x-nullable': true, + }, + nullableRequiredProp: { + description: 'This is a simple string property', + type: 'string', + 'x-nullable': true, + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/definitions/ModelWithProperties', + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/definitions/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/definitions/ModelWithCircularReference', + }, + }, + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/definitions/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + properties: { + third: { + type: 'string', + readOnly: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/definitions/ModelWithString', + }, + propB: { + $ref: '#/definitions/ModelWithString', + }, + propC: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/definitions/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/definitions/ModelWithString', + }, + { + $ref: '#/definitions/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/definitions/ModelWithString', + }, + }, + }, + ], + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap index e402b1ef7..f7f419e44 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap @@ -1461,3 +1461,3050 @@ export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, } as const; + +export const $OpenApi = { + openapi: '3.0.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + servers: [ + { + url: 'http://localhost:3000/base', + }, + ], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + post: { + operationId: 'PostServiceWithEmptyTag', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + { + $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', + }, + ], + }, + }, + }, + }, + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/foo/{foo}/bar/{bar}': { + delete: { + tags: ['Parameters'], + operationId: 'deleteFoo', + parameters: [ + { + description: 'foo in method', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in method', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + parameters: [ + { + description: 'foo in global parameters', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in global parameters', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/deprecated': { + post: { + tags: ['Deprecated'], + deprecated: true, + operationId: 'DeprecatedCall', + parameters: [ + { + deprecated: true, + description: 'This parameter is deprecated', + name: 'parameter', + in: 'header', + required: true, + nullable: true, + schema: { + $ref: '#/components/schemas/DeprecatedModel', + }, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + required: false, + schema: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + name: 'foo_ref_enum', + in: 'query', + }, + { + required: true, + schema: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + name: 'foo_all_of_enum', + in: 'query', + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'parameterCookie', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'PARAMETER-COOKIE', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/': { + get: { + tags: ['Parameters'], + operationId: 'GetCallWithOptionalParam', + parameters: [ + { + description: 'This is an optional parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is a required parameter', + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + }, + }, + }, + }, + post: { + tags: ['Parameters'], + operationId: 'PostCallWithOptionalParam', + parameters: [ + { + description: 'This is a required parameter', + name: 'parameter', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/Pageable', + }, + }, + ], + requestBody: { + description: 'This is an optional parameter', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/requestBody/': { + post: { + tags: ['RequestBody'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleRequestBody', + }, + }, + }, + '/api/v{api-version}/formData/': { + post: { + tags: ['FormData'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleFormData', + }, + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + nullable: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + nullable: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + nullable: true, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + nullable: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + required: false, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + required: false, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + required: false, + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + required: false, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + }, + }, + { + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + default: null, + }, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtends', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtendsExtends', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'default', + nullable: true, + }, + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + schema: { + type: 'boolean', + default: true, + nullable: true, + }, + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + default: null, + nullable: true, + }, + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + schema: { + type: 'object', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + nullable: true, + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 201: { + description: 'Response is a simple string', + content: { + 'application/json': { + schema: { + type: 'string', + }, + }, + }, + }, + 202: { + description: 'Response is a simple boolean', + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + 203: { + description: 'Response is a simple object', + content: { + 'application/json': { + schema: { + type: 'object', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/upload': { + post: { + tags: ['Upload'], + operationId: 'UploadFile', + parameters: [ + { + description: 'Supply a file reference for upload', + name: 'file', + in: 'formData', + required: true, + schema: { + type: 'file', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + nullable: true, + }, + }, + ], + responses: { + 200: { + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/file/{id}': { + get: { + tags: ['FileResponse'], + operationId: 'FileResponse', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Success', + content: { + 'audio/*': { + schema: { + type: 'file', + }, + }, + 'video/*': { + schema: { + type: 'file', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/multipart': { + post: { + tags: ['multipart'], + operationId: 'MultipartRequest', + requestBody: { + content: { + 'multipart/form-data': { + schema: { + type: 'object', + properties: { + content: { + type: 'string', + format: 'binary', + }, + data: { + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + ], + nullable: true, + }, + }, + }, + encoding: { + content: { + style: 'form', + }, + data: { + style: 'form', + }, + }, + }, + }, + }, + }, + get: { + tags: ['multipart'], + operationId: 'MultipartResponse', + responses: { + 200: { + description: 'OK', + content: { + 'multipart/mixed': { + schema: { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + metadata: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex/{id}': { + put: { + tags: ['Complex'], + operationId: 'ComplexParams', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + format: 'int32', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + content: { + 'application/json-patch+json': { + schema: { + required: ['key', 'name', 'parameters', 'type'], + type: 'object', + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + nullable: true, + readOnly: true, + }, + name: { + maxLength: 255, + type: 'string', + nullable: true, + }, + enabled: { + type: 'boolean', + default: true, + }, + type: { + enum: ['Monkey', 'Horse', 'Bird'], + type: 'string', + readOnly: true, + }, + listOfModels: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + nullable: true, + }, + listOfStrings: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + parameters: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + user: { + type: 'object', + properties: { + id: { + type: 'integer', + format: 'int32', + readOnly: true, + }, + name: { + type: 'string', + nullable: true, + readOnly: true, + }, + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + responses: { + 200: { + description: 'Success', + content: { + 'application/json; type=collection': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + schema: { + type: 'string', + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + requestBodies: { + SimpleRequestBody: { + 'x-body-name': 'foo', + description: 'A reusable request body', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + SimpleFormData: { + description: 'A reusable request body', + required: false, + content: { + 'multipart/form-data': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + parameters: { + SimpleParameter: { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + }, + schemas: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: [ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串', + ], + }, + EnumWithReplacedCharacters: { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ArrayWithAnyOfProperties: { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + }, + AnyOfAnyAndNull: { + type: 'object', + properties: { + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], + }, + }, + }, + AnyOfArrays: { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableRequiredProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumWithHyphen: { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { + type: 'string', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, + }, + ModelWithArrayReadOnlyAndWriteOnly: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + DeprecatedModel: { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', + }, + }, + }, + CompositionWithOneOf: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAnonymous: { + description: + "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + 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', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAnonymous: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + CompositionWithNestedAnyAndTypeNull: { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + ], + }, + }, + }, + Enum1: { + enum: ['Bird', 'Dog'], + type: 'string', + }, + ConstValue: { + type: 'string', + const: 'ConstValue', + }, + CompositionWithNestedAnyOfAndNull: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + title: 'Scopes', + }, + }, + }, + CompositionWithOneOfAndNullable: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleDictionary: { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleArrayDictionary: { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'boolean', + }, + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndComplexArrayDictionary: { + description: + 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], + }, + }, + }, + ], + }, + }, + }, + CompositionWithAllOfAndNullable: { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAndNullable: { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionBaseModel: { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, + }, + CompositionExtendedModel: { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { + type: 'string', + required: true, + readOnly: true, + nullable: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + File: { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, + }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, + }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', + }, + }, + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + Pageable: { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, + FreeFormObjectWithoutAdditionalProperties: { + description: 'This is a free-form object without additionalProperties.', + type: 'object', + }, + FreeFormObjectWithAdditionalPropertiesEqTrue: { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, + }, + FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, + }, + ModelWithConst: { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, + }, + ModelWithAdditionalPropertiesEqTrue: { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, + }, + NestedAnyOfArraysNullable: { + properties: { + nullableArray: { + anyOf: [ + { + items: { + anyOf: [ + { + type: 'string', + }, + { + type: 'boolean', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + }, + }, + type: 'object', + }, + CompositionWithOneOfAndProperties: { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', + }, + }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, + }, + NullableObject: { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, + }, + ModelWithNullableObject: { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, + }, + ModelWithOneOfEnum: { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, + }, + foo: { + type: 'string', + enum: ['Corge'], + }, + }, + }, + ], + }, + ModelWithNestedArrayEnumsDataFoo: { + enum: ['foo', 'bar'], + type: 'string', + }, + ModelWithNestedArrayEnumsDataBar: { + enum: ['baz', 'qux'], + type: 'string', + }, + ModelWithNestedArrayEnumsData: { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', + }, + }, + }, + }, + ModelWithNestedArrayEnums: { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, + }, + ModelWithNestedCompositionEnums: { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, + }, + ModelWithReadOnlyAndWriteOnly: { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, + }, + }, + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap index e402b1ef7..f7f419e44 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap @@ -1461,3 +1461,3050 @@ export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, } as const; + +export const $OpenApi = { + openapi: '3.0.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + servers: [ + { + url: 'http://localhost:3000/base', + }, + ], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + post: { + operationId: 'PostServiceWithEmptyTag', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + { + $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', + }, + ], + }, + }, + }, + }, + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/foo/{foo}/bar/{bar}': { + delete: { + tags: ['Parameters'], + operationId: 'deleteFoo', + parameters: [ + { + description: 'foo in method', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in method', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + parameters: [ + { + description: 'foo in global parameters', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in global parameters', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/deprecated': { + post: { + tags: ['Deprecated'], + deprecated: true, + operationId: 'DeprecatedCall', + parameters: [ + { + deprecated: true, + description: 'This parameter is deprecated', + name: 'parameter', + in: 'header', + required: true, + nullable: true, + schema: { + $ref: '#/components/schemas/DeprecatedModel', + }, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + required: false, + schema: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + name: 'foo_ref_enum', + in: 'query', + }, + { + required: true, + schema: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + name: 'foo_all_of_enum', + in: 'query', + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'parameterCookie', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'PARAMETER-COOKIE', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/': { + get: { + tags: ['Parameters'], + operationId: 'GetCallWithOptionalParam', + parameters: [ + { + description: 'This is an optional parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is a required parameter', + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + }, + }, + }, + }, + post: { + tags: ['Parameters'], + operationId: 'PostCallWithOptionalParam', + parameters: [ + { + description: 'This is a required parameter', + name: 'parameter', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/Pageable', + }, + }, + ], + requestBody: { + description: 'This is an optional parameter', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/requestBody/': { + post: { + tags: ['RequestBody'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleRequestBody', + }, + }, + }, + '/api/v{api-version}/formData/': { + post: { + tags: ['FormData'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleFormData', + }, + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + nullable: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + nullable: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + nullable: true, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + nullable: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + required: false, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + required: false, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + required: false, + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + required: false, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + }, + }, + { + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + default: null, + }, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtends', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtendsExtends', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'default', + nullable: true, + }, + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + schema: { + type: 'boolean', + default: true, + nullable: true, + }, + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + default: null, + nullable: true, + }, + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + schema: { + type: 'object', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + nullable: true, + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 201: { + description: 'Response is a simple string', + content: { + 'application/json': { + schema: { + type: 'string', + }, + }, + }, + }, + 202: { + description: 'Response is a simple boolean', + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + 203: { + description: 'Response is a simple object', + content: { + 'application/json': { + schema: { + type: 'object', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/upload': { + post: { + tags: ['Upload'], + operationId: 'UploadFile', + parameters: [ + { + description: 'Supply a file reference for upload', + name: 'file', + in: 'formData', + required: true, + schema: { + type: 'file', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + nullable: true, + }, + }, + ], + responses: { + 200: { + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/file/{id}': { + get: { + tags: ['FileResponse'], + operationId: 'FileResponse', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Success', + content: { + 'audio/*': { + schema: { + type: 'file', + }, + }, + 'video/*': { + schema: { + type: 'file', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/multipart': { + post: { + tags: ['multipart'], + operationId: 'MultipartRequest', + requestBody: { + content: { + 'multipart/form-data': { + schema: { + type: 'object', + properties: { + content: { + type: 'string', + format: 'binary', + }, + data: { + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + ], + nullable: true, + }, + }, + }, + encoding: { + content: { + style: 'form', + }, + data: { + style: 'form', + }, + }, + }, + }, + }, + }, + get: { + tags: ['multipart'], + operationId: 'MultipartResponse', + responses: { + 200: { + description: 'OK', + content: { + 'multipart/mixed': { + schema: { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + metadata: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex/{id}': { + put: { + tags: ['Complex'], + operationId: 'ComplexParams', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + format: 'int32', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + content: { + 'application/json-patch+json': { + schema: { + required: ['key', 'name', 'parameters', 'type'], + type: 'object', + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + nullable: true, + readOnly: true, + }, + name: { + maxLength: 255, + type: 'string', + nullable: true, + }, + enabled: { + type: 'boolean', + default: true, + }, + type: { + enum: ['Monkey', 'Horse', 'Bird'], + type: 'string', + readOnly: true, + }, + listOfModels: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + nullable: true, + }, + listOfStrings: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + parameters: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + user: { + type: 'object', + properties: { + id: { + type: 'integer', + format: 'int32', + readOnly: true, + }, + name: { + type: 'string', + nullable: true, + readOnly: true, + }, + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + responses: { + 200: { + description: 'Success', + content: { + 'application/json; type=collection': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + schema: { + type: 'string', + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + requestBodies: { + SimpleRequestBody: { + 'x-body-name': 'foo', + description: 'A reusable request body', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + SimpleFormData: { + description: 'A reusable request body', + required: false, + content: { + 'multipart/form-data': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + parameters: { + SimpleParameter: { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + }, + schemas: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: [ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串', + ], + }, + EnumWithReplacedCharacters: { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ArrayWithAnyOfProperties: { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + }, + AnyOfAnyAndNull: { + type: 'object', + properties: { + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], + }, + }, + }, + AnyOfArrays: { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableRequiredProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumWithHyphen: { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { + type: 'string', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, + }, + ModelWithArrayReadOnlyAndWriteOnly: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + DeprecatedModel: { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', + }, + }, + }, + CompositionWithOneOf: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAnonymous: { + description: + "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + 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', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAnonymous: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + CompositionWithNestedAnyAndTypeNull: { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + ], + }, + }, + }, + Enum1: { + enum: ['Bird', 'Dog'], + type: 'string', + }, + ConstValue: { + type: 'string', + const: 'ConstValue', + }, + CompositionWithNestedAnyOfAndNull: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + title: 'Scopes', + }, + }, + }, + CompositionWithOneOfAndNullable: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleDictionary: { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleArrayDictionary: { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'boolean', + }, + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndComplexArrayDictionary: { + description: + 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], + }, + }, + }, + ], + }, + }, + }, + CompositionWithAllOfAndNullable: { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAndNullable: { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionBaseModel: { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, + }, + CompositionExtendedModel: { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { + type: 'string', + required: true, + readOnly: true, + nullable: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + File: { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, + }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, + }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', + }, + }, + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + Pageable: { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, + FreeFormObjectWithoutAdditionalProperties: { + description: 'This is a free-form object without additionalProperties.', + type: 'object', + }, + FreeFormObjectWithAdditionalPropertiesEqTrue: { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, + }, + FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, + }, + ModelWithConst: { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, + }, + ModelWithAdditionalPropertiesEqTrue: { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, + }, + NestedAnyOfArraysNullable: { + properties: { + nullableArray: { + anyOf: [ + { + items: { + anyOf: [ + { + type: 'string', + }, + { + type: 'boolean', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + }, + }, + type: 'object', + }, + CompositionWithOneOfAndProperties: { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', + }, + }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, + }, + NullableObject: { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, + }, + ModelWithNullableObject: { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, + }, + ModelWithOneOfEnum: { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, + }, + foo: { + type: 'string', + enum: ['Corge'], + }, + }, + }, + ], + }, + ModelWithNestedArrayEnumsDataFoo: { + enum: ['foo', 'bar'], + type: 'string', + }, + ModelWithNestedArrayEnumsDataBar: { + enum: ['baz', 'qux'], + type: 'string', + }, + ModelWithNestedArrayEnumsData: { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', + }, + }, + }, + }, + ModelWithNestedArrayEnums: { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, + }, + ModelWithNestedCompositionEnums: { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, + }, + ModelWithReadOnlyAndWriteOnly: { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, + }, + }, + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap index be54e210f..aa980d0b0 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap @@ -43,3 +43,3050 @@ export const $ModelWithPattern = { }, }, } as const; + +export const $OpenApi = { + openapi: '3.0.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + servers: [ + { + url: 'http://localhost:3000/base', + }, + ], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + post: { + operationId: 'PostServiceWithEmptyTag', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + { + $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', + }, + ], + }, + }, + }, + }, + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/foo/{foo}/bar/{bar}': { + delete: { + tags: ['Parameters'], + operationId: 'deleteFoo', + parameters: [ + { + description: 'foo in method', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in method', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + parameters: [ + { + description: 'foo in global parameters', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in global parameters', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/deprecated': { + post: { + tags: ['Deprecated'], + deprecated: true, + operationId: 'DeprecatedCall', + parameters: [ + { + deprecated: true, + description: 'This parameter is deprecated', + name: 'parameter', + in: 'header', + required: true, + nullable: true, + schema: { + $ref: '#/components/schemas/DeprecatedModel', + }, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + required: false, + schema: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + name: 'foo_ref_enum', + in: 'query', + }, + { + required: true, + schema: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + name: 'foo_all_of_enum', + in: 'query', + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'parameterCookie', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'PARAMETER-COOKIE', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/': { + get: { + tags: ['Parameters'], + operationId: 'GetCallWithOptionalParam', + parameters: [ + { + description: 'This is an optional parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is a required parameter', + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + }, + }, + }, + }, + post: { + tags: ['Parameters'], + operationId: 'PostCallWithOptionalParam', + parameters: [ + { + description: 'This is a required parameter', + name: 'parameter', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/Pageable', + }, + }, + ], + requestBody: { + description: 'This is an optional parameter', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/requestBody/': { + post: { + tags: ['RequestBody'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleRequestBody', + }, + }, + }, + '/api/v{api-version}/formData/': { + post: { + tags: ['FormData'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleFormData', + }, + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + nullable: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + nullable: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + nullable: true, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + nullable: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + required: false, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + required: false, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + required: false, + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + required: false, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + }, + }, + { + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + default: null, + }, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtends', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtendsExtends', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'default', + nullable: true, + }, + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + schema: { + type: 'boolean', + default: true, + nullable: true, + }, + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + default: null, + nullable: true, + }, + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + schema: { + type: 'object', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + nullable: true, + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 201: { + description: 'Response is a simple string', + content: { + 'application/json': { + schema: { + type: 'string', + }, + }, + }, + }, + 202: { + description: 'Response is a simple boolean', + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + 203: { + description: 'Response is a simple object', + content: { + 'application/json': { + schema: { + type: 'object', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/upload': { + post: { + tags: ['Upload'], + operationId: 'UploadFile', + parameters: [ + { + description: 'Supply a file reference for upload', + name: 'file', + in: 'formData', + required: true, + schema: { + type: 'file', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + nullable: true, + }, + }, + ], + responses: { + 200: { + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/file/{id}': { + get: { + tags: ['FileResponse'], + operationId: 'FileResponse', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Success', + content: { + 'audio/*': { + schema: { + type: 'file', + }, + }, + 'video/*': { + schema: { + type: 'file', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/multipart': { + post: { + tags: ['multipart'], + operationId: 'MultipartRequest', + requestBody: { + content: { + 'multipart/form-data': { + schema: { + type: 'object', + properties: { + content: { + type: 'string', + format: 'binary', + }, + data: { + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + ], + nullable: true, + }, + }, + }, + encoding: { + content: { + style: 'form', + }, + data: { + style: 'form', + }, + }, + }, + }, + }, + }, + get: { + tags: ['multipart'], + operationId: 'MultipartResponse', + responses: { + 200: { + description: 'OK', + content: { + 'multipart/mixed': { + schema: { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + metadata: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex/{id}': { + put: { + tags: ['Complex'], + operationId: 'ComplexParams', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + format: 'int32', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + content: { + 'application/json-patch+json': { + schema: { + required: ['key', 'name', 'parameters', 'type'], + type: 'object', + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + nullable: true, + readOnly: true, + }, + name: { + maxLength: 255, + type: 'string', + nullable: true, + }, + enabled: { + type: 'boolean', + default: true, + }, + type: { + enum: ['Monkey', 'Horse', 'Bird'], + type: 'string', + readOnly: true, + }, + listOfModels: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + nullable: true, + }, + listOfStrings: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + parameters: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + user: { + type: 'object', + properties: { + id: { + type: 'integer', + format: 'int32', + readOnly: true, + }, + name: { + type: 'string', + nullable: true, + readOnly: true, + }, + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + responses: { + 200: { + description: 'Success', + content: { + 'application/json; type=collection': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + schema: { + type: 'string', + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + requestBodies: { + SimpleRequestBody: { + 'x-body-name': 'foo', + description: 'A reusable request body', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + SimpleFormData: { + description: 'A reusable request body', + required: false, + content: { + 'multipart/form-data': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + parameters: { + SimpleParameter: { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + }, + schemas: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: [ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串', + ], + }, + EnumWithReplacedCharacters: { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ArrayWithAnyOfProperties: { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + }, + AnyOfAnyAndNull: { + type: 'object', + properties: { + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], + }, + }, + }, + AnyOfArrays: { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableRequiredProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumWithHyphen: { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { + type: 'string', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, + }, + ModelWithArrayReadOnlyAndWriteOnly: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + DeprecatedModel: { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', + }, + }, + }, + CompositionWithOneOf: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAnonymous: { + description: + "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + 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', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAnonymous: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + CompositionWithNestedAnyAndTypeNull: { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + ], + }, + }, + }, + Enum1: { + enum: ['Bird', 'Dog'], + type: 'string', + }, + ConstValue: { + type: 'string', + const: 'ConstValue', + }, + CompositionWithNestedAnyOfAndNull: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + title: 'Scopes', + }, + }, + }, + CompositionWithOneOfAndNullable: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleDictionary: { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleArrayDictionary: { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'boolean', + }, + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndComplexArrayDictionary: { + description: + 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], + }, + }, + }, + ], + }, + }, + }, + CompositionWithAllOfAndNullable: { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAndNullable: { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionBaseModel: { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, + }, + CompositionExtendedModel: { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { + type: 'string', + required: true, + readOnly: true, + nullable: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + File: { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, + }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, + }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', + }, + }, + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + Pageable: { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, + FreeFormObjectWithoutAdditionalProperties: { + description: 'This is a free-form object without additionalProperties.', + type: 'object', + }, + FreeFormObjectWithAdditionalPropertiesEqTrue: { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, + }, + FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, + }, + ModelWithConst: { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, + }, + ModelWithAdditionalPropertiesEqTrue: { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, + }, + NestedAnyOfArraysNullable: { + properties: { + nullableArray: { + anyOf: [ + { + items: { + anyOf: [ + { + type: 'string', + }, + { + type: 'boolean', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + }, + }, + type: 'object', + }, + CompositionWithOneOfAndProperties: { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', + }, + }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, + }, + NullableObject: { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, + }, + ModelWithNullableObject: { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, + }, + ModelWithOneOfEnum: { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, + }, + foo: { + type: 'string', + enum: ['Corge'], + }, + }, + }, + ], + }, + ModelWithNestedArrayEnumsDataFoo: { + enum: ['foo', 'bar'], + type: 'string', + }, + ModelWithNestedArrayEnumsDataBar: { + enum: ['baz', 'qux'], + type: 'string', + }, + ModelWithNestedArrayEnumsData: { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', + }, + }, + }, + }, + ModelWithNestedArrayEnums: { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, + }, + ModelWithNestedCompositionEnums: { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, + }, + ModelWithReadOnlyAndWriteOnly: { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, + }, + }, + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap index e402b1ef7..f7f419e44 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap @@ -1461,3 +1461,3050 @@ export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, } as const; + +export const $OpenApi = { + openapi: '3.0.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + servers: [ + { + url: 'http://localhost:3000/base', + }, + ], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + post: { + operationId: 'PostServiceWithEmptyTag', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + { + $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', + }, + ], + }, + }, + }, + }, + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/foo/{foo}/bar/{bar}': { + delete: { + tags: ['Parameters'], + operationId: 'deleteFoo', + parameters: [ + { + description: 'foo in method', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in method', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + parameters: [ + { + description: 'foo in global parameters', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in global parameters', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/deprecated': { + post: { + tags: ['Deprecated'], + deprecated: true, + operationId: 'DeprecatedCall', + parameters: [ + { + deprecated: true, + description: 'This parameter is deprecated', + name: 'parameter', + in: 'header', + required: true, + nullable: true, + schema: { + $ref: '#/components/schemas/DeprecatedModel', + }, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + required: false, + schema: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + name: 'foo_ref_enum', + in: 'query', + }, + { + required: true, + schema: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + name: 'foo_all_of_enum', + in: 'query', + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'parameterCookie', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'PARAMETER-COOKIE', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/': { + get: { + tags: ['Parameters'], + operationId: 'GetCallWithOptionalParam', + parameters: [ + { + description: 'This is an optional parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is a required parameter', + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + }, + }, + }, + }, + post: { + tags: ['Parameters'], + operationId: 'PostCallWithOptionalParam', + parameters: [ + { + description: 'This is a required parameter', + name: 'parameter', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/Pageable', + }, + }, + ], + requestBody: { + description: 'This is an optional parameter', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/requestBody/': { + post: { + tags: ['RequestBody'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleRequestBody', + }, + }, + }, + '/api/v{api-version}/formData/': { + post: { + tags: ['FormData'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleFormData', + }, + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + nullable: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + nullable: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + nullable: true, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + nullable: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + required: false, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + required: false, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + required: false, + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + required: false, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + }, + }, + { + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + default: null, + }, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtends', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtendsExtends', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'default', + nullable: true, + }, + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + schema: { + type: 'boolean', + default: true, + nullable: true, + }, + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + default: null, + nullable: true, + }, + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + schema: { + type: 'object', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + nullable: true, + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 201: { + description: 'Response is a simple string', + content: { + 'application/json': { + schema: { + type: 'string', + }, + }, + }, + }, + 202: { + description: 'Response is a simple boolean', + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + 203: { + description: 'Response is a simple object', + content: { + 'application/json': { + schema: { + type: 'object', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/upload': { + post: { + tags: ['Upload'], + operationId: 'UploadFile', + parameters: [ + { + description: 'Supply a file reference for upload', + name: 'file', + in: 'formData', + required: true, + schema: { + type: 'file', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + nullable: true, + }, + }, + ], + responses: { + 200: { + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/file/{id}': { + get: { + tags: ['FileResponse'], + operationId: 'FileResponse', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Success', + content: { + 'audio/*': { + schema: { + type: 'file', + }, + }, + 'video/*': { + schema: { + type: 'file', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/multipart': { + post: { + tags: ['multipart'], + operationId: 'MultipartRequest', + requestBody: { + content: { + 'multipart/form-data': { + schema: { + type: 'object', + properties: { + content: { + type: 'string', + format: 'binary', + }, + data: { + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + ], + nullable: true, + }, + }, + }, + encoding: { + content: { + style: 'form', + }, + data: { + style: 'form', + }, + }, + }, + }, + }, + }, + get: { + tags: ['multipart'], + operationId: 'MultipartResponse', + responses: { + 200: { + description: 'OK', + content: { + 'multipart/mixed': { + schema: { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + metadata: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex/{id}': { + put: { + tags: ['Complex'], + operationId: 'ComplexParams', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + format: 'int32', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + content: { + 'application/json-patch+json': { + schema: { + required: ['key', 'name', 'parameters', 'type'], + type: 'object', + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + nullable: true, + readOnly: true, + }, + name: { + maxLength: 255, + type: 'string', + nullable: true, + }, + enabled: { + type: 'boolean', + default: true, + }, + type: { + enum: ['Monkey', 'Horse', 'Bird'], + type: 'string', + readOnly: true, + }, + listOfModels: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + nullable: true, + }, + listOfStrings: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + parameters: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + user: { + type: 'object', + properties: { + id: { + type: 'integer', + format: 'int32', + readOnly: true, + }, + name: { + type: 'string', + nullable: true, + readOnly: true, + }, + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + responses: { + 200: { + description: 'Success', + content: { + 'application/json; type=collection': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + schema: { + type: 'string', + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + requestBodies: { + SimpleRequestBody: { + 'x-body-name': 'foo', + description: 'A reusable request body', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + SimpleFormData: { + description: 'A reusable request body', + required: false, + content: { + 'multipart/form-data': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + parameters: { + SimpleParameter: { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + }, + schemas: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: [ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串', + ], + }, + EnumWithReplacedCharacters: { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ArrayWithAnyOfProperties: { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + }, + AnyOfAnyAndNull: { + type: 'object', + properties: { + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], + }, + }, + }, + AnyOfArrays: { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableRequiredProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumWithHyphen: { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { + type: 'string', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, + }, + ModelWithArrayReadOnlyAndWriteOnly: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + DeprecatedModel: { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', + }, + }, + }, + CompositionWithOneOf: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAnonymous: { + description: + "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + 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', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAnonymous: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + CompositionWithNestedAnyAndTypeNull: { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + ], + }, + }, + }, + Enum1: { + enum: ['Bird', 'Dog'], + type: 'string', + }, + ConstValue: { + type: 'string', + const: 'ConstValue', + }, + CompositionWithNestedAnyOfAndNull: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + title: 'Scopes', + }, + }, + }, + CompositionWithOneOfAndNullable: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleDictionary: { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleArrayDictionary: { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'boolean', + }, + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndComplexArrayDictionary: { + description: + 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], + }, + }, + }, + ], + }, + }, + }, + CompositionWithAllOfAndNullable: { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAndNullable: { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionBaseModel: { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, + }, + CompositionExtendedModel: { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { + type: 'string', + required: true, + readOnly: true, + nullable: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + File: { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, + }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, + }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', + }, + }, + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + Pageable: { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, + FreeFormObjectWithoutAdditionalProperties: { + description: 'This is a free-form object without additionalProperties.', + type: 'object', + }, + FreeFormObjectWithAdditionalPropertiesEqTrue: { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, + }, + FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, + }, + ModelWithConst: { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, + }, + ModelWithAdditionalPropertiesEqTrue: { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, + }, + NestedAnyOfArraysNullable: { + properties: { + nullableArray: { + anyOf: [ + { + items: { + anyOf: [ + { + type: 'string', + }, + { + type: 'boolean', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + }, + }, + type: 'object', + }, + CompositionWithOneOfAndProperties: { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', + }, + }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, + }, + NullableObject: { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, + }, + ModelWithNullableObject: { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, + }, + ModelWithOneOfEnum: { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, + }, + foo: { + type: 'string', + enum: ['Corge'], + }, + }, + }, + ], + }, + ModelWithNestedArrayEnumsDataFoo: { + enum: ['foo', 'bar'], + type: 'string', + }, + ModelWithNestedArrayEnumsDataBar: { + enum: ['baz', 'qux'], + type: 'string', + }, + ModelWithNestedArrayEnumsData: { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', + }, + }, + }, + }, + ModelWithNestedArrayEnums: { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, + }, + ModelWithNestedCompositionEnums: { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, + }, + ModelWithReadOnlyAndWriteOnly: { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, + }, + }, + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap index e402b1ef7..f7f419e44 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap @@ -1461,3 +1461,3050 @@ export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, } as const; + +export const $OpenApi = { + openapi: '3.0.0', + info: { + title: 'swagger', + version: 'v1.0', + }, + servers: [ + { + url: 'http://localhost:3000/base', + }, + ], + paths: { + '/api/v{api-version}/no-tag': { + tags: [], + get: { + operationId: 'ServiceWithEmptyTag', + }, + post: { + operationId: 'PostServiceWithEmptyTag', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + { + $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', + }, + ], + }, + }, + }, + }, + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/simple': { + get: { + tags: ['Simple'], + operationId: 'GetCallWithoutParametersAndResponse', + }, + put: { + tags: ['Simple'], + operationId: 'PutCallWithoutParametersAndResponse', + }, + post: { + tags: ['Simple'], + operationId: 'PostCallWithoutParametersAndResponse', + }, + delete: { + tags: ['Simple'], + operationId: 'DeleteCallWithoutParametersAndResponse', + }, + options: { + tags: ['Simple'], + operationId: 'OptionsCallWithoutParametersAndResponse', + }, + head: { + tags: ['Simple'], + operationId: 'HeadCallWithoutParametersAndResponse', + }, + patch: { + tags: ['Simple'], + operationId: 'PatchCallWithoutParametersAndResponse', + }, + }, + '/api/v{api-version}/foo/{foo}/bar/{bar}': { + delete: { + tags: ['Parameters'], + operationId: 'deleteFoo', + parameters: [ + { + description: 'foo in method', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in method', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + parameters: [ + { + description: 'foo in global parameters', + in: 'path', + name: 'foo', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'bar in global parameters', + in: 'path', + name: 'bar', + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + '/api/v{api-version}/descriptions/': { + post: { + tags: ['Descriptions'], + operationId: 'CallWithDescriptions', + parameters: [ + { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + name: 'parameterWithBreaks', + in: 'query', + type: 'string', + }, + { + description: + 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + name: 'parameterWithBackticks', + in: 'query', + type: 'string', + }, + { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + name: 'parameterWithSlashes', + in: 'query', + type: 'string', + }, + { + description: 'Testing expression placeholders in string: ${expression} should work', + name: 'parameterWithExpressionPlaceholders', + in: 'query', + type: 'string', + }, + { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + name: 'parameterWithQuotes', + in: 'query', + type: 'string', + }, + { + description: + 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + name: 'parameterWithReservedCharacters', + in: 'query', + type: 'string', + }, + ], + }, + }, + '/api/v{api-version}/parameters/deprecated': { + post: { + tags: ['Deprecated'], + deprecated: true, + operationId: 'DeprecatedCall', + parameters: [ + { + deprecated: true, + description: 'This parameter is deprecated', + name: 'parameter', + in: 'header', + required: true, + nullable: true, + schema: { + $ref: '#/components/schemas/DeprecatedModel', + }, + }, + ], + }, + }, + '/api/v{api-version}/parameters/{parameterPath}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithParameters', + parameters: [ + { + description: 'This is the parameter that goes into the header', + name: 'parameterHeader', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + required: false, + schema: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + name: 'foo_ref_enum', + in: 'query', + }, + { + required: true, + schema: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + name: 'foo_all_of_enum', + in: 'query', + }, + { + description: 'This is the parameter that goes into the query params', + name: 'parameterQuery', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the form data', + name: 'parameterForm', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'parameterCookie', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameterPath', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { + post: { + tags: ['Parameters'], + operationId: 'CallWithWeirdParameterNames', + parameters: [ + { + description: 'This is the parameter that goes into the path', + name: 'parameter.path.1', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'parameter-path-2', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the path', + name: 'PARAMETER-PATH-3', + in: 'path', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter with a reserved keyword', + name: 'default', + in: 'query', + required: false, + nullable: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request header', + name: 'parameter.header', + in: 'header', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request query params', + name: 'parameter-query', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the request form data', + name: 'parameter_form', + in: 'formData', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is the parameter that goes into the cookie', + name: 'PARAMETER-COOKIE', + in: 'cookie', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + nullable: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is the parameter that goes into the body', + required: true, + nullable: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/parameters/': { + get: { + tags: ['Parameters'], + operationId: 'GetCallWithOptionalParam', + parameters: [ + { + description: 'This is an optional parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + description: 'This is a required parameter', + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + }, + }, + }, + }, + post: { + tags: ['Parameters'], + operationId: 'PostCallWithOptionalParam', + parameters: [ + { + description: 'This is a required parameter', + name: 'parameter', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/Pageable', + }, + }, + ], + requestBody: { + description: 'This is an optional parameter', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/requestBody/': { + post: { + tags: ['RequestBody'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleRequestBody', + }, + }, + }, + '/api/v{api-version}/formData/': { + post: { + tags: ['FormData'], + parameters: [ + { + $ref: '#/components/parameters/SimpleParameter', + }, + ], + requestBody: { + $ref: '#/components/requestBodies/SimpleFormData', + }, + }, + }, + '/api/v{api-version}/defaults': { + get: { + tags: ['Defaults'], + operationId: 'CallWithDefaultParameters', + parameters: [ + { + description: 'This is a simple string with default value', + name: 'parameterString', + in: 'query', + nullable: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number with default value', + name: 'parameterNumber', + in: 'query', + nullable: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean with default value', + name: 'parameterBoolean', + in: 'query', + nullable: true, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum with default value', + name: 'parameterEnum', + in: 'query', + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model with default value', + name: 'parameterModel', + in: 'query', + nullable: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + post: { + tags: ['Defaults'], + operationId: 'CallWithDefaultOptionalParameters', + parameters: [ + { + description: 'This is a simple string that is optional with default value', + name: 'parameterString', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a simple number that is optional with default value', + name: 'parameterNumber', + in: 'query', + required: false, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a simple boolean that is optional with default value', + name: 'parameterBoolean', + in: 'query', + required: false, + schema: { + type: 'boolean', + default: true, + }, + }, + { + description: 'This is a simple enum that is optional with default value', + name: 'parameterEnum', + in: 'query', + required: false, + schema: { + enum: ['Success', 'Warning', 'Error'], + default: 0, + }, + }, + { + description: 'This is a simple model that is optional with default value', + name: 'parameterModel', + in: 'query', + required: false, + schema: { + $ref: '#/components/schemas/ModelWithString', + default: { + prop: 'Hello World!', + }, + }, + }, + ], + }, + put: { + tags: ['Defaults'], + operationId: 'CallToTestOrderOfParams', + parameters: [ + { + description: 'This is a optional string with default', + name: 'parameterOptionalStringWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a optional string with empty default', + name: 'parameterOptionalStringWithEmptyDefault', + in: 'query', + required: false, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a optional string with no default', + name: 'parameterOptionalStringWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string with default', + name: 'parameterStringWithDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'Hello World!', + }, + }, + { + description: 'This is a string with empty default', + name: 'parameterStringWithEmptyDefault', + in: 'query', + required: true, + schema: { + type: 'string', + default: '', + }, + }, + { + description: 'This is a string with no default', + name: 'parameterStringWithNoDefault', + in: 'query', + required: true, + schema: { + type: 'string', + }, + }, + { + description: 'This is a string that can be null with no default', + name: 'parameterStringNullableWithNoDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + }, + }, + { + description: 'This is a string that can be null with default', + name: 'parameterStringNullableWithDefault', + in: 'query', + required: false, + schema: { + type: 'string', + nullable: true, + default: null, + }, + }, + ], + }, + }, + '/api/v{api-version}/duplicate': { + get: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + post: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + put: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + delete: { + tags: ['Duplicate'], + operationId: 'DuplicateName', + }, + }, + '/api/v{api-version}/no-content': { + get: { + tags: ['NoContent'], + operationId: 'CallWithNoContentResponse', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/response-and-no-content': { + get: { + tags: ['Response', 'NoContent'], + operationId: 'CallWithResponseAndNoContentResponse', + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/a': { + get: { + tags: ['MultipleTags1', 'MultipleTags2'], + operationId: 'DummyA', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/multiple-tags/b': { + get: { + tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], + operationId: 'DummyB', + responses: { + 204: { + description: 'Success', + }, + }, + }, + }, + '/api/v{api-version}/response': { + get: { + tags: ['Response'], + operationId: 'CallWithResponse', + responses: { + default: { + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + post: { + tags: ['Response'], + operationId: 'CallWithDuplicateResponses', + responses: { + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + put: { + tags: ['Response'], + operationId: 'CallWithResponses', + responses: { + 200: { + description: 'Message for 200 response', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + value: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + 201: { + description: 'Message for 201 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtends', + }, + }, + }, + }, + 202: { + description: 'Message for 202 response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelThatExtendsExtends', + }, + }, + }, + }, + 500: { + description: 'Message for 500 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 501: { + description: 'Message for 501 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + 502: { + description: 'Message for 502 error', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + default: { + description: 'Message for default response', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/collectionFormat': { + get: { + tags: ['CollectionFormat'], + operationId: 'CollectionFormat', + parameters: [ + { + description: 'This is an array parameter that is sent as csv format (comma-separated values)', + name: 'parameterArrayCSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'csv', + }, + { + description: 'This is an array parameter that is sent as ssv format (space-separated values)', + name: 'parameterArraySSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'ssv', + }, + { + description: 'This is an array parameter that is sent as tsv format (tab-separated values)', + name: 'parameterArrayTSV', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'tsv', + }, + { + description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', + name: 'parameterArrayPipes', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'pipes', + }, + { + description: + 'This is an array parameter that is sent as multi format (multiple parameter instances)', + name: 'parameterArrayMulti', + in: 'query', + required: true, + nullable: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + collectionFormat: 'multi', + }, + ], + }, + }, + '/api/v{api-version}/types': { + get: { + tags: ['Types'], + operationId: 'Types', + parameters: [ + { + description: 'This is a number parameter', + name: 'parameterNumber', + in: 'query', + required: true, + schema: { + type: 'number', + default: 123, + }, + }, + { + description: 'This is a string parameter', + name: 'parameterString', + in: 'query', + required: true, + schema: { + type: 'string', + default: 'default', + nullable: true, + }, + }, + { + description: 'This is a boolean parameter', + name: 'parameterBoolean', + in: 'query', + required: true, + schema: { + type: 'boolean', + default: true, + nullable: true, + }, + }, + { + description: 'This is an object parameter', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + default: null, + nullable: true, + }, + }, + { + description: 'This is an array parameter', + name: 'parameterArray', + in: 'query', + required: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is a dictionary parameter', + name: 'parameterDictionary', + in: 'query', + required: true, + schema: { + type: 'object', + items: { + type: 'string', + }, + nullable: true, + }, + }, + { + description: 'This is an enum parameter', + name: 'parameterEnum', + in: 'query', + required: true, + schema: { + enum: ['Success', 'Warning', 'Error'], + nullable: true, + }, + }, + { + description: 'This is a number parameter', + name: 'id', + in: 'path', + schema: { + type: 'integer', + format: 'int32', + }, + }, + ], + responses: { + 200: { + description: 'Response is a simple number', + content: { + 'application/json': { + schema: { + type: 'number', + }, + }, + }, + }, + 201: { + description: 'Response is a simple string', + content: { + 'application/json': { + schema: { + type: 'string', + }, + }, + }, + }, + 202: { + description: 'Response is a simple boolean', + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + 203: { + description: 'Response is a simple object', + content: { + 'application/json': { + schema: { + type: 'object', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/upload': { + post: { + tags: ['Upload'], + operationId: 'UploadFile', + parameters: [ + { + description: 'Supply a file reference for upload', + name: 'file', + in: 'formData', + required: true, + schema: { + type: 'file', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + nullable: true, + }, + }, + ], + responses: { + 200: { + content: { + 'application/json': { + schema: { + type: 'boolean', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/file/{id}': { + get: { + tags: ['FileResponse'], + operationId: 'FileResponse', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Success', + content: { + 'audio/*': { + schema: { + type: 'file', + }, + }, + 'video/*': { + schema: { + type: 'file', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex': { + get: { + tags: ['Complex'], + operationId: 'ComplexTypes', + parameters: [ + { + description: 'Parameter containing object', + name: 'parameterObject', + in: 'query', + required: true, + schema: { + type: 'object', + properties: { + first: { + type: 'object', + properties: { + second: { + type: 'object', + properties: { + third: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + { + description: 'Parameter containing reference', + name: 'parameterReference', + in: 'query', + required: true, + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/multipart': { + post: { + tags: ['multipart'], + operationId: 'MultipartRequest', + requestBody: { + content: { + 'multipart/form-data': { + schema: { + type: 'object', + properties: { + content: { + type: 'string', + format: 'binary', + }, + data: { + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + ], + nullable: true, + }, + }, + }, + encoding: { + content: { + style: 'form', + }, + data: { + style: 'form', + }, + }, + }, + }, + }, + }, + get: { + tags: ['multipart'], + operationId: 'MultipartResponse', + responses: { + 200: { + description: 'OK', + content: { + 'multipart/mixed': { + schema: { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + metadata: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/complex/{id}': { + put: { + tags: ['Complex'], + operationId: 'ComplexParams', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + format: 'int32', + }, + }, + { + name: 'api-version', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + requestBody: { + content: { + 'application/json-patch+json': { + schema: { + required: ['key', 'name', 'parameters', 'type'], + type: 'object', + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + nullable: true, + readOnly: true, + }, + name: { + maxLength: 255, + type: 'string', + nullable: true, + }, + enabled: { + type: 'boolean', + default: true, + }, + type: { + enum: ['Monkey', 'Horse', 'Bird'], + type: 'string', + readOnly: true, + }, + listOfModels: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + nullable: true, + }, + listOfStrings: { + type: 'array', + items: { + type: 'string', + }, + nullable: true, + }, + parameters: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + user: { + type: 'object', + properties: { + id: { + type: 'integer', + format: 'int32', + readOnly: true, + }, + name: { + type: 'string', + nullable: true, + readOnly: true, + }, + }, + readOnly: true, + }, + }, + }, + }, + }, + }, + responses: { + 200: { + description: 'Success', + content: { + 'application/json; type=collection': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + }, + }, + '/api/v{api-version}/header': { + post: { + tags: ['Header'], + operationId: 'CallWithResultFromHeader', + responses: { + 200: { + description: 'Successful response', + headers: { + 'operation-location': { + schema: { + type: 'string', + }, + }, + }, + }, + 400: { + description: '400 server error', + }, + 500: { + description: '500 server error', + }, + }, + }, + }, + '/api/v{api-version}/error': { + post: { + tags: ['Error'], + operationId: 'testErrorCode', + parameters: [ + { + description: 'Status code to return', + name: 'status', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Custom message: Successful response', + }, + 500: { + description: 'Custom message: Internal Server Error', + }, + 501: { + description: 'Custom message: Not Implemented', + }, + 502: { + description: 'Custom message: Bad Gateway', + }, + 503: { + description: 'Custom message: Service Unavailable', + }, + }, + }, + }, + '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { + post: { + tags: ['Non-Ascii-æøåÆØÅöôêÊ'], + operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', + parameters: [ + { + description: 'Dummy input param', + name: 'nonAsciiParamæøåÆØÅöôêÊ', + in: 'query', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + 200: { + description: 'Successful response', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + }, + }, + }, + }, + }, + }, + }, + components: { + requestBodies: { + SimpleRequestBody: { + 'x-body-name': 'foo', + description: 'A reusable request body', + required: false, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + SimpleFormData: { + description: 'A reusable request body', + required: false, + content: { + 'multipart/form-data': { + schema: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + }, + }, + parameters: { + SimpleParameter: { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, + }, + }, + schemas: { + CommentWithBreaks: { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', + }, + CommentWithBackticks: { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', + }, + CommentWithSlashes: { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', + }, + CommentWithExpressionPlaceholders: { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', + }, + CommentWithQuotes: { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', + }, + CommentWithReservedCharacters: { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', + }, + SimpleInteger: { + description: 'This is a simple number', + type: 'integer', + }, + SimpleBoolean: { + description: 'This is a simple boolean', + type: 'boolean', + }, + SimpleString: { + description: 'This is a simple string', + type: 'string', + }, + NonAsciiStringæøåÆØÅöôêÊ字符串: { + description: + 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', + }, + SimpleFile: { + description: 'This is a simple file', + type: 'file', + }, + SimpleReference: { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', + }, + SimpleStringWithPattern: { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + EnumWithStrings: { + description: 'This is a simple enum with strings', + enum: [ + 'Success', + 'Warning', + 'Error', + "'Single Quote'", + '"Double Quotes"', + 'Non-ascii: øæåôöØÆÅÔÖ字符串', + ], + }, + EnumWithReplacedCharacters: { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', + }, + EnumWithNumbers: { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, + }, + EnumFromDescription: { + description: 'Success=1,Warning=2,Error=3', + type: 'number', + }, + EnumWithExtensions: { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], + }, + ArrayWithNumbers: { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, + }, + ArrayWithBooleans: { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, + }, + ArrayWithStrings: { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], + }, + ArrayWithReferences: { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + ArrayWithArray: { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ArrayWithProperties: { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ArrayWithAnyOfProperties: { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + }, + AnyOfAnyAndNull: { + type: 'object', + properties: { + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], + }, + }, + }, + AnyOfArrays: { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, + }, + DictionaryWithString: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + DictionaryWithReference: { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + DictionaryWithArray: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + DictionaryWithDictionary: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + DictionaryWithProperties: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, + }, + ModelWithInteger: { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, + }, + ModelWithBoolean: { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', + type: 'boolean', + }, + }, + }, + ModelWithString: { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + }, + ModelWithNullableString: { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableRequiredProp1: { + description: 'This is a simple string property', + type: 'string', + nullable: true, + }, + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithEnum: { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, + }, + ModelWithEnumWithHyphen: { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { + type: 'string', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', + }, + }, + }, + ModelWithEnumFromDescription: { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + }, + ModelWithNestedEnums: { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], + }, + }, + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, + }, + ModelWithReference: { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, + }, + ModelWithArrayReadOnlyAndWriteOnly: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithArray: { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + propWithFile: { + type: 'array', + items: { + type: 'file', + }, + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', + }, + }, + }, + }, + ModelWithDictionary: { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + DeprecatedModel: { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', + }, + }, + }, + ModelWithCircularReference: { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', + }, + }, + }, + CompositionWithOneOf: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAnonymous: { + description: + "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + 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', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAnonymous: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { + type: 'string', + }, + }, + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, + }, + CompositionWithNestedAnyAndTypeNull: { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + type: 'null', + }, + ], + }, + type: 'array', + }, + ], + }, + }, + }, + Enum1: { + enum: ['Bird', 'Dog'], + type: 'string', + }, + ConstValue: { + type: 'string', + const: 'ConstValue', + }, + CompositionWithNestedAnyOfAndNull: { + description: + "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + title: 'Scopes', + }, + }, + }, + CompositionWithOneOfAndNullable: { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleDictionary: { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndSimpleArrayDictionary: { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'boolean', + }, + }, + }, + ], + }, + }, + }, + CompositionWithOneOfAndComplexArrayDictionary: { + description: + 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], + }, + }, + }, + ], + }, + }, + }, + CompositionWithAllOfAndNullable: { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionWithAnyOfAndNullable: { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, + }, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, + }, + CompositionBaseModel: { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, + }, + CompositionExtendedModel: { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], + }, + ModelWithProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, + }, + ModelWithNestedProperties: { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { + type: 'string', + required: true, + readOnly: true, + nullable: true, + }, + }, + }, + }, + }, + }, + }, + ModelWithDuplicateProperties: { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelWithOrderedProperties: { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', + }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, + }, + ModelWithDuplicateImports: { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ModelThatExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelThatExtendsExtends: { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', + }, + }, + }, + ], + }, + ModelWithPattern: { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', + }, + name: { + maxLength: 255, + type: 'string', + }, + enabled: { + type: 'boolean', + readOnly: true, + }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, + }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', + }, + text: { + type: 'string', + pattern: '^w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", + }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', + }, + }, + }, + File: { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, + }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, + }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, + }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', + }, + }, + }, + default: { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, + }, + Pageable: { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, + FreeFormObjectWithoutAdditionalProperties: { + description: 'This is a free-form object without additionalProperties.', + type: 'object', + }, + FreeFormObjectWithAdditionalPropertiesEqTrue: { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, + }, + FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, + }, + ModelWithConst: { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, + }, + ModelWithAdditionalPropertiesEqTrue: { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, + }, + NestedAnyOfArraysNullable: { + properties: { + nullableArray: { + anyOf: [ + { + items: { + anyOf: [ + { + type: 'string', + }, + { + type: 'boolean', + }, + ], + }, + type: 'array', + }, + { + type: 'null', + }, + ], + }, + }, + type: 'object', + }, + CompositionWithOneOfAndProperties: { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', + }, + }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', + }, + }, + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, + }, + NullableObject: { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, + }, + ModelWithNullableObject: { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, + }, + ModelWithOneOfEnum: { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, + }, + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], + }, + }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, + }, + foo: { + type: 'string', + enum: ['Corge'], + }, + }, + }, + ], + }, + ModelWithNestedArrayEnumsDataFoo: { + enum: ['foo', 'bar'], + type: 'string', + }, + ModelWithNestedArrayEnumsDataBar: { + enum: ['baz', 'qux'], + type: 'string', + }, + ModelWithNestedArrayEnumsData: { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', + }, + }, + }, + }, + ModelWithNestedArrayEnums: { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, + }, + ModelWithNestedCompositionEnums: { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, + }, + ModelWithReadOnlyAndWriteOnly: { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, + }, + }, + }, +} as const; From 8bc92d47e621ca22d4e95e0af7727fd56596cf50 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 8 Apr 2024 03:39:19 +0100 Subject: [PATCH 2/3] feat(parser): output OpenAPI schemas --- packages/openapi-ts/src/compiler/index.ts | 3 + packages/openapi-ts/src/openApi/index.ts | 5 +- .../src/utils/write/__tests__/class.spec.ts | 4 +- .../src/utils/write/__tests__/core.spec.ts | 12 +- .../src/utils/write/__tests__/models.spec.ts | 4 +- .../src/utils/write/__tests__/schemas.spec.ts | 55 +- .../utils/write/__tests__/services.spec.ts | 4 +- packages/openapi-ts/src/utils/write/class.ts | 4 +- packages/openapi-ts/src/utils/write/client.ts | 2 +- packages/openapi-ts/src/utils/write/core.ts | 4 +- packages/openapi-ts/src/utils/write/models.ts | 4 +- .../openapi-ts/src/utils/write/schemas.ts | 323 +- .../openapi-ts/src/utils/write/services.ts | 4 +- .../test/generated/v2/schemas.ts.snap | 1759 +------ .../test/generated/v3/schemas.ts.snap | 3937 ++------------- .../test/generated/v3_angular/schemas.ts.snap | 3937 ++------------- .../test/generated/v3_date/schemas.ts.snap | 4363 ++++++----------- .../v3_enums_typescript/schemas.ts.snap | 3937 ++------------- .../generated/v3_experimental/schemas.ts.snap | 3937 ++------------- 19 files changed, 3553 insertions(+), 18745 deletions(-) diff --git a/packages/openapi-ts/src/compiler/index.ts b/packages/openapi-ts/src/compiler/index.ts index 73c2133ab..09e5ec58f 100644 --- a/packages/openapi-ts/src/compiler/index.ts +++ b/packages/openapi-ts/src/compiler/index.ts @@ -24,6 +24,9 @@ export class TypeScriptFile { } public write(file: PathOrFileDescriptor, seperator: string = '\n') { + if (!this._items.length) { + return; + } writeFileSync(file, this.toString(seperator)); } } diff --git a/packages/openapi-ts/src/openApi/index.ts b/packages/openapi-ts/src/openApi/index.ts index 7e4ac9813..3bd6b5b71 100644 --- a/packages/openapi-ts/src/openApi/index.ts +++ b/packages/openapi-ts/src/openApi/index.ts @@ -16,8 +16,11 @@ export { OpenApi } from './common/interfaces/OpenApi'; export function parse(openApi: OpenApi, config: Config): Client { if ('openapi' in openApi) { return parseV3(openApi, config); - } else if ('swagger' in openApi) { + } + + if ('swagger' in openApi) { return parseV2(openApi, config); } + throw new Error(`Unsupported Open API specification: ${JSON.stringify(openApi, null, 2)}`); } diff --git a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts index 9b1736f82..8ebbef814 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/class.spec.ts @@ -10,7 +10,7 @@ vi.mock('node:fs'); describe('writeClientClass', () => { it('should write to filesystem', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -20,8 +20,8 @@ describe('writeClientClass', () => { await writeClientClass( openApi, - client, './dist', + client, { client: 'fetch', debug: false, diff --git a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts index 4de9526aa..8b5828b6c 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/core.spec.ts @@ -16,7 +16,7 @@ describe('writeClientCore', () => { }); it('should write to filesystem', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -46,7 +46,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(openApi, client, '/', config, templates); + await writeClientCore(openApi, '/', client, config, templates); expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/OpenAPI.ts'), 'settings'); expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/ApiError.ts'), 'apiError'); @@ -58,7 +58,7 @@ describe('writeClientCore', () => { }); it('uses client server value for base', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -88,7 +88,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(openApi, client, '/', config, templates); + await writeClientCore(openApi, '/', client, config, templates); expect(templates.core.settings).toHaveBeenCalledWith({ $config: config, @@ -99,7 +99,7 @@ describe('writeClientCore', () => { }); it('uses custom value for base', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -130,7 +130,7 @@ describe('writeClientCore', () => { write: true, }; - await writeClientCore(openApi, client, '/', config, templates); + await writeClientCore(openApi, '/', client, config, templates); expect(templates.core.settings).toHaveBeenCalledWith({ $config: config, diff --git a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts index b360b5e53..50ac16d0f 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/models.spec.ts @@ -10,7 +10,7 @@ vi.mock('node:fs'); describe('writeClientModels', () => { it('should write to filesystem', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [ { @@ -37,7 +37,7 @@ describe('writeClientModels', () => { version: 'v1', }; - await writeClientModels(openApi, client, '/', { + await writeClientModels(openApi, '/', client, { client: 'fetch', debug: false, enums: 'javascript', diff --git a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts index d8296b07d..8810dea6c 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts @@ -10,54 +10,17 @@ vi.mock('node:fs'); describe('writeClientSchemas', () => { it('should write to filesystem', async () => { - const client: Parameters[1] = { - enumNames: [], - models: [ - { - $refs: [], - base: 'User', - description: null, - enum: [], - enums: [], - export: 'interface', - imports: [], - isDefinition: true, - isNullable: false, - isReadOnly: false, - isRequired: false, - link: null, - name: 'User', - properties: [], - template: null, - type: 'User', + if ('openapi' in openApi) { + openApi.components = { + schemas: { + foo: { + type: 'object', + }, }, - ], - server: 'http://localhost:8080', - services: [], - version: 'v1', - }; + }; + } - await writeClientSchemas(openApi, client, '/', { - client: 'fetch', - debug: false, - enums: 'javascript', - experimental: false, - exportCore: true, - exportModels: true, - exportSchemas: true, - exportServices: true, - format: false, - input: '', - lint: false, - name: 'AppClient', - operationId: true, - output: '', - postfixServices: '', - serviceResponse: 'body', - useDateType: false, - useOptions: true, - write: true, - }); + await writeClientSchemas(openApi, '/'); expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/schemas.ts'), expect.anything()); }); diff --git a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts index 630f93819..a3db3d2f8 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/services.spec.ts @@ -10,7 +10,7 @@ vi.mock('node:fs'); describe('writeClientServices', () => { it('should write to filesystem', async () => { - const client: Parameters[1] = { + const client: Parameters[2] = { enumNames: [], models: [], server: 'http://localhost:8080', @@ -27,8 +27,8 @@ describe('writeClientServices', () => { await writeClientServices( openApi, - client, '/', + client, { client: 'fetch', debug: false, diff --git a/packages/openapi-ts/src/utils/write/class.ts b/packages/openapi-ts/src/utils/write/class.ts index 4a4943751..fb538b819 100644 --- a/packages/openapi-ts/src/utils/write/class.ts +++ b/packages/openapi-ts/src/utils/write/class.ts @@ -13,15 +13,15 @@ import { sortByName } from '../sort'; * The index file just contains all the exports you need to use the client as a standalone * library. But yuo can also import individual models and services directly. * @param openApi {@link OpenApi} Dereferenced OpenAPI specification - * @param client Client containing models, schemas, and services * @param outputPath Directory to write the generated files to + * @param client Client containing models, schemas, and services * @param config {@link Config} passed to the `createClient()` method * @param templates The loaded handlebar templates */ export const writeClientClass = async ( openApi: OpenApi, - client: Client, outputPath: string, + client: Client, config: Config, templates: Templates ): Promise => { diff --git a/packages/openapi-ts/src/utils/write/client.ts b/packages/openapi-ts/src/utils/write/client.ts index f33c19a93..7a95034be 100644 --- a/packages/openapi-ts/src/utils/write/client.ts +++ b/packages/openapi-ts/src/utils/write/client.ts @@ -82,8 +82,8 @@ export const writeClient = async ( }); await section.fn( openApi, - client, sectionPath, + client, { ...config, name: config.name!, diff --git a/packages/openapi-ts/src/utils/write/core.ts b/packages/openapi-ts/src/utils/write/core.ts index ece4566c4..3707b31a8 100644 --- a/packages/openapi-ts/src/utils/write/core.ts +++ b/packages/openapi-ts/src/utils/write/core.ts @@ -10,15 +10,15 @@ import type { Templates } from '../handlebars'; /** * Generate OpenAPI core files, this includes the basic boilerplate code to handle requests. * @param openApi {@link OpenApi} Dereferenced OpenAPI specification - * @param client Client containing models, schemas, and services * @param outputPath Directory to write the generated files to + * @param client Client containing models, schemas, and services * @param config {@link Config} passed to the `createClient()` method * @param templates The loaded handlebar templates */ export const writeClientCore = async ( openApi: OpenApi, - client: Client, outputPath: string, + client: Client, config: Config, templates: Templates ): Promise => { diff --git a/packages/openapi-ts/src/utils/write/models.ts b/packages/openapi-ts/src/utils/write/models.ts index 52be84f45..c44f416e5 100644 --- a/packages/openapi-ts/src/utils/write/models.ts +++ b/packages/openapi-ts/src/utils/write/models.ts @@ -165,14 +165,14 @@ const processModel = (config: Config, client: Client, model: Model) => { /** * Generate Models using the Handlebar template and write to disk. * @param openApi {@link OpenApi} Dereferenced OpenAPI specification - * @param client Client containing models, schemas, and services * @param outputPath Directory to write the generated files to + * @param client Client containing models, schemas, and services * @param config {@link Config} passed to the `createClient()` method */ export const writeClientModels = async ( openApi: OpenApi, - client: Client, outputPath: string, + client: Client, config: Config ): Promise => { if (!client.models.length) { diff --git a/packages/openapi-ts/src/utils/write/schemas.ts b/packages/openapi-ts/src/utils/write/schemas.ts index 682d22a6e..eab0dc76c 100644 --- a/packages/openapi-ts/src/utils/write/schemas.ts +++ b/packages/openapi-ts/src/utils/write/schemas.ts @@ -1,302 +1,49 @@ import path from 'node:path'; import compiler, { TypeScriptFile } from '../../compiler'; -import type { Model, OpenApi } from '../../openApi'; -import type { Client } from '../../types/client'; -import type { Config } from '../../types/config'; -import { escapeDescription } from '../escape'; - -const escapeNewline = (value: string) => value.replace(/\n/g, '\\n'); - -const processArray = (config: Config, model: Model) => { - const properties: Record = { - type: 'array', - }; - - if (model.link) { - properties.contains = processModel(config, model.link); - } else { - properties.contains = { - type: model.base, - }; - } - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - return properties; -}; - -const processComposition = (config: Config, model: Model) => { - const properties: Record = { - type: model.export, - }; - if (model.description) { - properties.description = `\`${escapeDescription(model.description)}\``; - } - - properties.contains = model.properties.map(property => processModel(config, property)); - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - return properties; -}; - -const processDict = (config: Config, model: Model) => { - const properties: Record = { - type: 'dictionary', - }; - - if (model.link) { - properties.contains = processModel(config, model.link); - } else { - properties.contains = { - type: model.base, - }; - } - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - return properties; -}; - -const processEnum = (config: Config, model: Model) => { - const properties: Record = { - type: 'Enum', - }; - if (model.enum.length) { - properties.enum = model.enum.map(enumerator => enumerator.value); - } - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - return properties; -}; - -const processGeneric = (config: Config, model: Model) => { - const properties: Record = {}; - if (model.type) { - properties.type = model.type; - } - - if (model.description) { - properties.description = `\`${escapeDescription(model.description)}\``; - } - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - if (model.format) { - properties.format = model.format; - } - - if (model.maximum !== undefined && model.maximum !== null) { - properties.maximum = model.maximum; - } - - if (model.exclusiveMaximum !== undefined && model.exclusiveMaximum !== null) { - properties.exclusiveMaximum = model.exclusiveMaximum; - } - - if (model.minimum !== undefined && model.minimum !== null) { - properties.minimum = model.minimum; - } - - if (model.exclusiveMinimum !== undefined && model.exclusiveMinimum !== null) { - properties.exclusiveMinimum = model.exclusiveMinimum; - } - - if (model.multipleOf !== undefined && model.multipleOf !== null) { - properties.multipleOf = model.multipleOf; - } - - if (model.maxLength !== undefined && model.maxLength !== null) { - properties.maxLength = model.maxLength; - } - - if (model.minLength !== undefined && model.minLength !== null) { - properties.minLength = model.minLength; - } - - if (model.pattern) { - properties.pattern = escapeNewline(model.pattern); - } - - if (model.maxItems !== undefined && model.maxItems !== null) { - properties.maxItems = model.maxItems; - } - - if (model.minItems !== undefined && model.minItems !== null) { - properties.minItems = model.minItems; - } - - if (model.uniqueItems !== undefined && model.uniqueItems !== null) { - properties.uniqueItems = model.uniqueItems; - } - - if (model.maxProperties !== undefined && model.maxProperties !== null) { - properties.maxProperties = model.maxProperties; - } - - if (model.minProperties !== undefined && model.minProperties !== null) { - properties.minProperties = model.minProperties; - } - - return properties; -}; - -const processInterface = (config: Config, model: Model) => { - const properties: Record = {}; - - if (model.description) { - properties.description = `\`${escapeDescription(model.description)}\``; - } - - const props: Record = {}; - model.properties - .filter(property => property.name !== '[key: string]') - .forEach(property => { - props[property.name] = processModel(config, property); - }); - properties.properties = props; - - if (model.default !== undefined) { - properties.default = model.default; - } - - if (model.isReadOnly) { - properties.isReadOnly = true; - } - - if (model.isRequired) { - properties.isRequired = true; - } - - if (model.isNullable) { - properties.isNullable = true; - } - - return properties; -}; - -const processModel = (config: Config, model: Model) => { - switch (model.export) { - case 'all-of': - case 'any-of': - case 'one-of': - return processComposition(config, model); - case 'array': - return processArray(config, model); - case 'dictionary': - return processDict(config, model); - case 'enum': - return processEnum(config, model); - case 'interface': - return processInterface(config, model); - default: - return processGeneric(config, model); - } -}; - -const exportSchema = (config: Config, model: Model) => { - const obj = processModel(config, model); - const expression = compiler.types.object(obj); - return compiler.export.asConst(`$${model.name}`, expression); -}; +import type { OpenApi } from '../../openApi'; /** * Generate Schemas using the Handlebar template and write to disk. * @param openApi {@link OpenApi} Dereferenced OpenAPI specification - * @param client Client containing models, schemas, and services * @param outputPath Directory to write the generated files to - * @param config {@link Config} passed to the `createClient()` method */ -export const writeClientSchemas = async ( - openApi: OpenApi, - client: Client, - outputPath: string, - config: Config -): Promise => { - if (!client.models.length) { - return; - } - +export const writeClientSchemas = async (openApi: OpenApi, outputPath: string): Promise => { const file = new TypeScriptFile(); - for (const model of client.models) { - const result = exportSchema(config, model); - file.add(result); - } - const expression = compiler.types.object(openApi); - file.add(compiler.export.asConst(`$OpenApi`, expression)); + const addSchema = (name: string, obj: any) => { + const expression = compiler.types.object(obj); + const statement = compiler.export.asConst(name, expression); + file.add(statement); + }; + + // OpenAPI 2.0 + if ('swagger' in openApi) { + for (const name in openApi.definitions) { + if (openApi.definitions.hasOwnProperty(name)) { + const definition = openApi.definitions[name]; + addSchema(`$${name}`, definition); + } + } + } + + // OpenAPI 3.x + if ('openapi' in openApi) { + if (openApi.components) { + for (const name in openApi.components.schemas) { + if (openApi.components.schemas.hasOwnProperty(name)) { + const schema = openApi.components.schemas[name]; + addSchema(`$${name}`, schema); + } + } + for (const name in openApi.components.parameters) { + if (openApi.components.parameters.hasOwnProperty(name)) { + const parameter = openApi.components.parameters[name]; + addSchema(`$${name}`, parameter); + } + } + } + } file.write(path.resolve(outputPath, 'schemas.ts'), '\n\n'); }; diff --git a/packages/openapi-ts/src/utils/write/services.ts b/packages/openapi-ts/src/utils/write/services.ts index c18faa515..8130d08d9 100644 --- a/packages/openapi-ts/src/utils/write/services.ts +++ b/packages/openapi-ts/src/utils/write/services.ts @@ -11,15 +11,15 @@ import { unique } from '../unique'; /** * Generate Services using the Handlebar template and write to disk. * @param openApi {@link OpenApi} Dereferenced OpenAPI specification - * @param client Client containing models, schemas, and services * @param outputPath Directory to write the generated files to + * @param client Client containing models, schemas, and services * @param config {@link Config} passed to the `createClient()` method * @param templates The loaded handlebar templates */ export const writeClientServices = async ( openApi: OpenApi, - client: Client, outputPath: string, + client: Client, config: Config, templates: Templates ): Promise => { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap index d580dd7f8..e0613ec52 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap @@ -1,134 +1,147 @@ export const $CommentWithBreaks = { - type: 'number', description: `Testing multiline comments in string: First line Second line Fourth line`, + type: 'integer', } as const; export const $CommentWithBackticks = { - type: 'number', - description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', } as const; export const $CommentWithSlashes = { - type: 'number', - description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', } as const; export const $CommentWithExpressionPlaceholders = { - type: 'number', - description: `Testing expression placeholders in string: \${expression} should work`, + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', } as const; export const $CommentWithQuotes = { - type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', } as const; export const $CommentWithReservedCharacters = { - type: 'number', - description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', } as const; export const $SimpleInteger = { - type: 'number', - description: `This is a simple number`, + description: 'This is a simple number', + type: 'integer', } as const; export const $SimpleBoolean = { + description: 'This is a simple boolean', type: 'boolean', - description: `This is a simple boolean`, } as const; export const $SimpleString = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, } as const; export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string', - description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; export const $SimpleFile = { - type: 'binary', - description: `This is a simple file`, + description: 'This is a simple file', + type: 'file', } as const; export const $SimpleReference = { - type: 'ModelWithString', - description: `This is a simple reference`, + description: 'This is a simple reference', + $ref: '#/definitions/ModelWithString', } as const; export const $SimpleStringWithPattern = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', } as const; export const $EnumWithStrings = { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; export const $EnumWithNumbers = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], } as const; export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', type: 'number', - description: `Success=1,Warning=2,Error=3`, } as const; export const $EnumWithExtensions = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], } as const; export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', type: 'array', - contains: { - type: 'number', + items: { + type: 'integer', }, } as const; export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', type: 'array', - contains: { + items: { type: 'boolean', }, } as const; export const $ArrayWithStrings = { + description: 'This is a simple array with strings', type: 'array', - contains: { + items: { type: 'string', }, } as const; export const $ArrayWithReferences = { + description: 'This is a simple array with references', type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/definitions/ModelWithString', }, } as const; export const $ArrayWithArray = { + description: 'This is a simple array containing an array', type: 'array', - contains: { + items: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/definitions/ModelWithString', }, }, } as const; export const $ArrayWithProperties = { + description: 'This is a simple array with properties', type: 'array', - contains: { + items: { + type: 'object', properties: { foo: { type: 'string', @@ -141,42 +154,48 @@ export const $ArrayWithProperties = { } as const; export const $DictionaryWithString = { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { type: 'string', }, } as const; export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/definitions/ModelWithString', }, } as const; export const $DictionaryWithArray = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/definitions/ModelWithString', }, }, } as const; export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', }, }, } as const; export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', properties: { foo: { type: 'string', @@ -189,146 +208,154 @@ export const $DictionaryWithProperties = { } as const; export const $Date = { + description: 'This is a type-only model that defines Date as a string', type: 'string', - description: `This is a type-only model that defines Date as a string`, } as const; export const $ModelWithInteger = { - description: `This is a model with one number property`, + description: 'This is a model with one number property', + type: 'object', properties: { prop: { - type: 'number', - description: `This is a simple number property`, + description: 'This is a simple number property', + type: 'integer', }, }, } as const; export const $ModelWithBoolean = { - description: `This is a model with one boolean property`, + description: 'This is a model with one boolean property', + type: 'object', properties: { prop: { + description: 'This is a simple boolean property', type: 'boolean', - description: `This is a simple boolean property`, }, }, } as const; export const $ModelWithString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, } as const; export const $ModelWithNullableString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp'], properties: { nullableProp: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isNullable: true, + 'x-nullable': true, }, nullableRequiredProp: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + 'x-nullable': true, }, }, } as const; export const $ModelWithEnum = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, statusCode: { - type: 'Enum', + description: 'These are the HTTP error code enums', enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], }, bool: { + description: 'Simple boolean enum', type: 'boolean', - description: `Simple boolean enum`, + enum: [true], }, }, } as const; export const $ModelWithEnumFromDescription = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, } as const; export const $ModelWithNestedEnums = { - description: `This is a model with nested enums`, + description: 'This is a model with nested enums', + type: 'object', properties: { dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', + type: 'object', + additionalProperties: { enum: ['Success', 'Warning', 'Error'], }, }, dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, arrayWithEnum: { type: 'array', - contains: { - type: 'Enum', + items: { enum: ['Success', 'Warning', 'Error'], }, }, arrayWithDescription: { type: 'array', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, }, } as const; export const $ModelWithReference = { - description: `This is a model with one property containing a reference`, + description: 'This is a model with one property containing a reference', + type: 'object', properties: { prop: { - type: 'ModelWithProperties', + $ref: '#/definitions/ModelWithProperties', }, }, } as const; export const $ModelWithArray = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/definitions/ModelWithString', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -336,11 +363,12 @@ export const $ModelWithArray = { } as const; export const $ModelWithDictionary = { - description: `This is a model with one property containing a dictionary`, + description: 'This is a model with one property containing a dictionary', + type: 'object', properties: { prop: { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'string', }, }, @@ -348,25 +376,26 @@ export const $ModelWithDictionary = { } as const; export const $ModelWithCircularReference = { - description: `This is a model with one property containing a circular reference`, + description: 'This is a model with one property containing a circular reference', + type: 'object', properties: { prop: { - type: 'ModelWithCircularReference', + $ref: '#/definitions/ModelWithCircularReference', }, }, } as const; export const $ModelWithProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly'], properties: { required: { type: 'string', - isRequired: true, }, requiredAndReadOnly: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, string: { type: 'string', @@ -378,7 +407,7 @@ export const $ModelWithProperties = { type: 'boolean', }, reference: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, 'property with space': { type: 'string', @@ -391,49 +420,54 @@ export const $ModelWithProperties = { }, '@namespace.string': { type: 'string', - isReadOnly: true, + readOnly: true, }, '@namespace.integer': { - type: 'number', - isReadOnly: true, + type: 'integer', + readOnly: true, }, }, } as const; export const $ModelWithNestedProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], properties: { first: { + type: 'object', + required: ['second'], + readOnly: true, properties: { second: { + type: 'object', + required: ['third'], + readOnly: true, properties: { third: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, }, - isReadOnly: true, - isRequired: true, }, }, - isReadOnly: true, - isRequired: true, }, }, } as const; export const $ModelWithDuplicateProperties = { - description: `This is a model with duplicated properties`, + description: 'This is a model with duplicated properties', + type: 'object', properties: { prop: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, }, } as const; export const $ModelWithOrderedProperties = { - description: `This is a model with ordered properties`, + description: 'This is a model with ordered properties', + type: 'object', properties: { zebra: { type: 'string', @@ -448,34 +482,36 @@ export const $ModelWithOrderedProperties = { } as const; export const $ModelWithDuplicateImports = { - description: `This is a model with duplicated imports`, + description: 'This is a model with duplicated imports', + type: 'object', properties: { propA: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, propB: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, propC: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, }, } as const; export const $ModelThatExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, { + type: 'object', properties: { propExtendsA: { type: 'string', }, propExtendsB: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, }, }, @@ -483,29 +519,31 @@ export const $ModelThatExtends = { } as const; export const $ModelThatExtendsExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, { - type: 'ModelThatExtends', + $ref: '#/definitions/ModelThatExtends', }, { + type: 'object', properties: { propExtendsC: { type: 'string', }, propExtendsD: { - type: 'ModelWithString', + $ref: '#/definitions/ModelWithString', }, }, }, ], } as const; -export const $_default = { +export const $default = { + type: 'object', properties: { name: { type: 'string', @@ -514,35 +552,35 @@ export const $_default = { } as const; export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], properties: { key: { - type: 'string', - isRequired: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, name: { - type: 'string', - isRequired: true, maxLength: 255, + type: 'string', }, enabled: { type: 'boolean', - isReadOnly: true, + readOnly: true, }, modified: { type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, id: { type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + pattern: '^d{2}-d{3}-d{4}$', }, text: { type: 'string', - pattern: '^\\w+$', + pattern: '^w+$', }, patternWithSingleQuotes: { type: 'string', @@ -550,7 +588,8 @@ export const $ModelWithPattern = { }, patternWithNewline: { type: 'string', - pattern: 'aaa\nbbb', + pattern: `aaa +bbb`, }, patternWithBacktick: { type: 'string', @@ -558,1443 +597,3 @@ export const $ModelWithPattern = { }, }, } as const; - -export const $OpenApi = { - swagger: '2.0', - info: { - title: 'swagger', - version: 'v1.0', - }, - host: 'localhost:3000', - basePath: '/base', - schemes: ['http'], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', - }, - }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', - }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', - }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', - }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', - }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', - }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', - }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', - }, - }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that is sent as request body', - name: 'parameterBody', - in: 'body', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - type: 'string', - required: true, - }, - { - name: 'api-version', - in: 'path', - type: 'string', - required: true, - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - type: 'string', - required: false, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - type: 'string', - required: false, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - type: 'string', - required: false, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - type: 'string', - required: false, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - type: 'string', - required: true, - }, - { - description: 'This is the parameter that is sent as request body', - name: 'PARAMETER-BODY', - in: 'body', - type: 'string', - required: true, - }, - { - name: 'api-version', - in: 'path', - type: 'string', - required: true, - }, - ], - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - required: true, - default: 'Hello World!', - type: 'string', - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - required: true, - default: 123, - type: 'number', - }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - required: true, - default: true, - type: 'boolean', - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - required: true, - default: 0, - schema: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - required: true, - default: { - prop: 'Hello World!', - }, - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - default: 'Hello World!', - type: 'string', - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - default: 123, - type: 'number', - }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - default: true, - type: 'boolean', - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - default: 0, - schema: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - default: { - prop: 'Hello World!', - }, - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - default: 'Hello World!', - type: 'string', - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - default: '', - type: 'string', - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - type: 'string', - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - default: 'Hello World!', - type: 'string', - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - default: '', - type: 'string', - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - type: 'string', - }, - { - 'x-nullable': true, - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - type: 'string', - }, - { - 'x-nullable': true, - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - type: 'string', - default: null, - }, - ], - }, - }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate', 'Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate', 'Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate', 'Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate', 'Duplicate'], - operationId: 'DuplicateName', - }, - }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - description: 'Message for default response', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 202: { - description: 'Message for 202 response', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 500: { - description: 'Message for 500 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 501: { - description: 'Message for 501 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 502: { - description: 'Message for 502 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - default: { - description: 'Message for default response', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - schema: { - $ref: '#/definitions/ModelThatExtends', - }, - }, - 202: { - description: 'Message for 202 response', - schema: { - $ref: '#/definitions/ModelThatExtendsExtends', - }, - }, - 500: { - description: 'Message for 500 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 501: { - description: 'Message for 501 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - 502: { - description: 'Message for 502 error', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - default: { - description: 'Message for default response', - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - }, - }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - collectionFormat: 'multi', - }, - ], - }, - }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - default: 123, - type: 'number', - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - default: 'default', - type: 'string', - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - default: true, - type: 'boolean', - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - default: null, - type: 'object', - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - type: 'array', - items: { - type: 'string', - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - type: 'object', - items: { - type: 'string', - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - schema: { - type: 'number', - }, - }, - 201: { - description: 'Response is a simple string', - schema: { - type: 'string', - }, - }, - 202: { - description: 'Response is a simple boolean', - schema: { - type: 'boolean', - }, - }, - 203: { - description: 'Response is a simple object', - default: null, - schema: { - type: 'object', - }, - }, - }, - }, - }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/definitions/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - schema: { - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - type: 'string', - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - type: 'string', - required: true, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, - }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - schema: { - $ref: '#/definitions/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - definitions: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/definitions/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/definitions/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - Date: { - description: 'This is a type-only model that defines Date as a string', - type: 'string', - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp'], - properties: { - nullableProp: { - description: 'This is a simple string property', - type: 'string', - 'x-nullable': true, - }, - nullableRequiredProp: { - description: 'This is a simple string property', - type: 'string', - 'x-nullable': true, - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/definitions/ModelWithProperties', - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/definitions/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/definitions/ModelWithCircularReference', - }, - }, - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/definitions/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - properties: { - third: { - type: 'string', - readOnly: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/definitions/ModelWithString', - }, - propB: { - $ref: '#/definitions/ModelWithString', - }, - propC: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/definitions/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/definitions/ModelWithString', - }, - { - $ref: '#/definitions/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/definitions/ModelWithString', - }, - }, - }, - ], - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - }, -} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap index f7f419e44..d4f2992e7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap @@ -1,142 +1,155 @@ export const $CommentWithBreaks = { - type: 'number', description: `Testing multiline comments in string: First line Second line Fourth line`, + type: 'integer', } as const; export const $CommentWithBackticks = { - type: 'number', - description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', } as const; export const $CommentWithSlashes = { - type: 'number', - description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', } as const; export const $CommentWithExpressionPlaceholders = { - type: 'number', - description: `Testing expression placeholders in string: \${expression} should work`, + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', } as const; export const $CommentWithQuotes = { - type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', } as const; export const $CommentWithReservedCharacters = { - type: 'number', - description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', } as const; export const $SimpleInteger = { - type: 'number', - description: `This is a simple number`, + description: 'This is a simple number', + type: 'integer', } as const; export const $SimpleBoolean = { + description: 'This is a simple boolean', type: 'boolean', - description: `This is a simple boolean`, } as const; export const $SimpleString = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, } as const; export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string', - description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; export const $SimpleFile = { - type: 'binary', - description: `This is a simple file`, + description: 'This is a simple file', + type: 'file', } as const; export const $SimpleReference = { - type: 'ModelWithString', - description: `This is a simple reference`, + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', } as const; export const $SimpleStringWithPattern = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, - isNullable: true, + nullable: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', } as const; export const $EnumWithStrings = { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; export const $EnumWithReplacedCharacters = { - type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', } as const; export const $EnumWithNumbers = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], default: 200, } as const; export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', type: 'number', - description: `Success=1,Warning=2,Error=3`, } as const; export const $EnumWithExtensions = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], } as const; export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', type: 'array', - contains: { - type: 'number', + items: { + type: 'integer', }, } as const; export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', type: 'array', - contains: { + items: { type: 'boolean', }, } as const; export const $ArrayWithStrings = { + description: 'This is a simple array with strings', type: 'array', - contains: { + items: { type: 'string', }, default: ['test'], } as const; export const $ArrayWithReferences = { + description: 'This is a simple array with references', type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $ArrayWithArray = { + description: 'This is a simple array containing an array', type: 'array', - contains: { + items: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ArrayWithProperties = { + description: 'This is a simple array with properties', type: 'array', - contains: { + items: { + type: 'object', properties: { foo: { type: 'string', @@ -149,11 +162,12 @@ export const $ArrayWithProperties = { } as const; export const $ArrayWithAnyOfProperties = { + description: 'This is a simple array with any of properties', type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -162,6 +176,7 @@ export const $ArrayWithAnyOfProperties = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -173,13 +188,11 @@ export const $ArrayWithAnyOfProperties = { } as const; export const $AnyOfAnyAndNull = { + type: 'object', properties: { data: { - type: 'any-of', - contains: [ - { - properties: {}, - }, + anyOf: [ + {}, { type: 'null', }, @@ -189,14 +202,14 @@ export const $AnyOfAnyAndNull = { } as const; export const $AnyOfArrays = { - description: `This is a simple array with any of properties`, + description: 'This is a simple array with any of properties', + type: 'object', properties: { results: { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -204,6 +217,7 @@ export const $AnyOfArrays = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -212,47 +226,54 @@ export const $AnyOfArrays = { }, ], }, + type: 'array', }, }, } as const; export const $DictionaryWithString = { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { type: 'string', }, } as const; export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $DictionaryWithArray = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', }, }, } as const; export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', properties: { foo: { type: 'string', @@ -265,171 +286,178 @@ export const $DictionaryWithProperties = { } as const; export const $ModelWithInteger = { - description: `This is a model with one number property`, + description: 'This is a model with one number property', + type: 'object', properties: { prop: { - type: 'number', - description: `This is a simple number property`, + description: 'This is a simple number property', + type: 'integer', }, }, } as const; export const $ModelWithBoolean = { - description: `This is a model with one boolean property`, + description: 'This is a model with one boolean property', + type: 'object', properties: { prop: { + description: 'This is a simple boolean property', type: 'boolean', - description: `This is a simple boolean property`, }, }, } as const; export const $ModelWithString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, } as const; export const $ModelWithNullableString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], properties: { nullableProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isNullable: true, + nullable: true, }, nullableRequiredProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + nullable: true, }, nullableProp2: { - type: 'string', - description: `This is a simple string property`, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, nullableRequiredProp2: { - type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithEnum = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, statusCode: { - type: 'Enum', + description: 'These are the HTTP error code enums', enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], }, bool: { + description: 'Simple boolean enum', type: 'boolean', - description: `Simple boolean enum`, + enum: [true], }, }, } as const; export const $ModelWithEnumWithHyphen = { - description: `This is a model with one enum with escaped name`, + description: 'This is a model with one enum with escaped name', + type: 'object', properties: { 'foo-bar-baz-qux': { - type: 'Enum', + type: 'string', enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', default: '3.0', }, }, } as const; export const $ModelWithEnumFromDescription = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, } as const; export const $ModelWithNestedEnums = { - description: `This is a model with nested enums`, + description: 'This is a model with nested enums', + type: 'object', properties: { dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', + type: 'object', + additionalProperties: { enum: ['Success', 'Warning', 'Error'], }, }, dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, arrayWithEnum: { type: 'array', - contains: { - type: 'Enum', + items: { enum: ['Success', 'Warning', 'Error'], }, }, arrayWithDescription: { type: 'array', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithReference = { - description: `This is a model with one property containing a reference`, + description: 'This is a model with one property containing a reference', + type: 'object', properties: { prop: { - type: 'ModelWithProperties', + $ref: '#/components/schemas/ModelWithProperties', }, }, } as const; export const $ModelWithArrayReadOnlyAndWriteOnly = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithReadOnlyAndWriteOnly', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -437,23 +465,24 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } as const; export const $ModelWithArray = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -461,11 +490,12 @@ export const $ModelWithArray = { } as const; export const $ModelWithDictionary = { - description: `This is a model with one property containing a dictionary`, + description: 'This is a model with one property containing a dictionary', + type: 'object', properties: { prop: { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'string', }, }, @@ -473,41 +503,46 @@ export const $ModelWithDictionary = { } as const; export const $DeprecatedModel = { - description: `This is a deprecated model with a deprecated property`, + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', properties: { prop: { + deprecated: true, + description: 'This is a deprecated property', type: 'string', - description: `This is a deprecated property`, }, }, } as const; export const $ModelWithCircularReference = { - description: `This is a model with one property containing a circular reference`, + description: 'This is a model with one property containing a circular reference', + type: 'object', properties: { prop: { - type: 'ModelWithCircularReference', + $ref: '#/components/schemas/ModelWithCircularReference', }, }, } as const; export const $CompositionWithOneOf = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -515,13 +550,15 @@ export const $CompositionWithOneOf = { } as const; export const $CompositionWithOneOfAnonymous = { - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -529,12 +566,12 @@ export const $CompositionWithOneOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -542,11 +579,12 @@ export const $CompositionWithOneOfAnonymous = { } as const; export const $ModelCircle = { - description: `Circle`, + description: 'Circle', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, radius: { type: 'number', @@ -555,11 +593,12 @@ export const $ModelCircle = { } as const; export const $ModelSquare = { - description: `Square`, + description: 'Square', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, sideLength: { type: 'number', @@ -568,35 +607,43 @@ export const $ModelSquare = { } as const; export const $CompositionWithOneOfDiscriminator = { - type: 'one-of', - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, - contains: [ + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + oneOf: [ { - type: 'ModelCircle', + $ref: '#/components/schemas/ModelCircle', }, { - type: 'ModelSquare', + $ref: '#/components/schemas/ModelSquare', }, ], + discriminator: { + propertyName: 'kind', + mapping: { + circle: '#/components/schemas/ModelCircle', + square: '#/components/schemas/ModelSquare', + }, + }, } as const; export const $CompositionWithAnyOf = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -604,13 +651,15 @@ export const $CompositionWithAnyOf = { } as const; export const $CompositionWithAnyOfAnonymous = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -618,12 +667,12 @@ export const $CompositionWithAnyOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -631,38 +680,37 @@ export const $CompositionWithAnyOfAnonymous = { } as const; export const $CompositionWithNestedAnyAndTypeNull = { - description: `This is a model with nested 'any of' property with a type null`, + description: "This is a model with nested 'any of' property with a type null", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, { type: 'null', }, ], }, + type: 'array', }, { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { type: 'null', }, ], }, + type: 'array', }, ], }, @@ -670,49 +718,53 @@ export const $CompositionWithNestedAnyAndTypeNull = { } as const; export const $Enum1 = { - type: 'Enum', enum: ['Bird', 'Dog'], + type: 'string', } as const; export const $ConstValue = { - type: '"ConstValue"', + type: 'string', + const: 'ConstValue', } as const; export const $CompositionWithNestedAnyOfAndNull = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'Enum1', + $ref: '#/components/schemas/Enum1', }, { - type: 'ConstValue', + $ref: '#/components/schemas/ConstValue', }, ], }, + type: 'array', }, { type: 'null', }, ], + title: 'Scopes', }, }, } as const; export const $CompositionWithOneOfAndNullable = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + nullable: true, + type: 'object', + oneOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -720,32 +772,31 @@ export const $CompositionWithOneOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithOneOfAndSimpleDictionary = { - description: `This is a model that contains a simple dictionary within composition`, + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'number', }, }, @@ -755,19 +806,19 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } as const; export const $CompositionWithOneOfAndSimpleArrayDictionary = { - description: `This is a model that contains a dictionary of simple arrays within composition`, + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { + items: { type: 'boolean', }, }, @@ -778,21 +829,20 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } as const; export const $CompositionWithOneOfAndComplexArrayDictionary = { - description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, + description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'one-of', - contains: [ + items: { + oneOf: [ { type: 'number', }, @@ -809,12 +859,15 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } as const; export const $CompositionWithAllOfAndNullable = { - description: `This is a model with one property with a 'all of' relationship`, + description: "This is a model with one property with a 'all of' relationship", + type: 'object', properties: { propA: { - type: 'all-of', - contains: [ + nullable: true, + type: 'object', + allOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -822,27 +875,29 @@ export const $CompositionWithAllOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithAnyOfAndNullable = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + nullable: true, + type: 'object', + anyOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -850,22 +905,22 @@ export const $CompositionWithAnyOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionBaseModel = { - description: `This is a base model with two simple optional properties`, + description: 'This is a base model with two simple optional properties', + type: 'object', properties: { firstName: { type: 'string', @@ -877,47 +932,36 @@ export const $CompositionBaseModel = { } as const; export const $CompositionExtendedModel = { - type: 'all-of', - description: `This is a model that extends the base model`, - contains: [ - { - type: 'CompositionBaseModel', - }, + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ { - properties: { - firstName: { - type: 'string', - isRequired: true, - }, - lastname: { - type: 'string', - isRequired: true, - }, - age: { - type: 'number', - isRequired: true, - }, - }, + $ref: '#/components/schemas/CompositionBaseModel', }, ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], } as const; export const $ModelWithProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], properties: { required: { type: 'string', - isRequired: true, }, requiredAndReadOnly: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, requiredAndNullable: { type: 'string', - isRequired: true, - isNullable: true, + nullable: true, }, string: { type: 'string', @@ -929,7 +973,7 @@ export const $ModelWithProperties = { type: 'boolean', }, reference: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, 'property with space': { type: 'string', @@ -942,52 +986,58 @@ export const $ModelWithProperties = { }, '@namespace.string': { type: 'string', - isReadOnly: true, + readOnly: true, }, '@namespace.integer': { - type: 'number', - isReadOnly: true, + type: 'integer', + readOnly: true, }, }, } as const; export const $ModelWithNestedProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], properties: { first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, properties: { second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, properties: { third: { type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + required: true, + readOnly: true, + nullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, } as const; export const $ModelWithDuplicateProperties = { - description: `This is a model with duplicated properties`, + description: 'This is a model with duplicated properties', + type: 'object', properties: { prop: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelWithOrderedProperties = { - description: `This is a model with ordered properties`, + description: 'This is a model with ordered properties', + type: 'object', properties: { zebra: { type: 'string', @@ -1002,34 +1052,36 @@ export const $ModelWithOrderedProperties = { } as const; export const $ModelWithDuplicateImports = { - description: `This is a model with duplicated imports`, + description: 'This is a model with duplicated imports', + type: 'object', properties: { propA: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propC: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelThatExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { + type: 'object', properties: { propExtendsA: { type: 'string', }, propExtendsB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1037,22 +1089,23 @@ export const $ModelThatExtends = { } as const; export const $ModelThatExtendsExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelThatExtends', + $ref: '#/components/schemas/ModelThatExtends', }, { + type: 'object', properties: { propExtendsC: { type: 'string', }, propExtendsD: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1060,35 +1113,35 @@ export const $ModelThatExtendsExtends = { } as const; export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], properties: { key: { - type: 'string', - isRequired: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, name: { - type: 'string', - isRequired: true, maxLength: 255, + type: 'string', }, enabled: { type: 'boolean', - isReadOnly: true, + readOnly: true, }, modified: { type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, id: { type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + pattern: '^d{2}-d{3}-d{4}$', }, text: { type: 'string', - pattern: '^\\w+$', + pattern: '^w+$', }, patternWithSingleQuotes: { type: 'string', @@ -1096,7 +1149,8 @@ export const $ModelWithPattern = { }, patternWithNewline: { type: 'string', - pattern: 'aaa\nbbb', + pattern: `aaa +bbb`, }, patternWithBacktick: { type: 'string', @@ -1106,37 +1160,44 @@ export const $ModelWithPattern = { } as const; export const $File = { + required: ['mime'], + type: 'object', properties: { id: { + title: 'Id', type: 'string', - isReadOnly: true, + readOnly: true, minLength: 1, }, updated_at: { + title: 'Updated at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, created_at: { + title: 'Created at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, mime: { + title: 'Mime', type: 'string', - isRequired: true, maxLength: 24, minLength: 1, }, file: { + title: 'File', type: 'string', - isReadOnly: true, + readOnly: true, format: 'uri', }, }, } as const; -export const $_default = { +export const $default = { + type: 'object', properties: { name: { type: 'string', @@ -1145,21 +1206,22 @@ export const $_default = { } as const; export const $Pageable = { + type: 'object', properties: { page: { - type: 'number', - default: 0, - format: 'int32', minimum: 0, + type: 'integer', + format: 'int32', + default: 0, }, size: { - type: 'number', - format: 'int32', minimum: 1, + type: 'integer', + format: 'int32', }, sort: { type: 'array', - contains: { + items: { type: 'string', }, }, @@ -1167,63 +1229,60 @@ export const $Pageable = { } as const; export const $FreeFormObjectWithoutAdditionalProperties = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object without additionalProperties.', + type: 'object', } as const; export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, } as const; export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, } as const; export const $ModelWithConst = { + type: 'object', properties: { String: { - type: '"String"', + const: 'String', }, number: { - type: '0', + const: 0, }, null: { - type: 'null', + const: null, }, withType: { - type: '"Some string"', + type: 'string', + const: 'Some string', }, }, } as const; export const $ModelWithAdditionalPropertiesEqTrue = { - description: `This is a model with one property and additionalProperties: true`, + description: 'This is a model with one property and additionalProperties: true', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, + additionalProperties: true, } as const; export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { type: 'string', }, @@ -1232,6 +1291,7 @@ export const $NestedAnyOfArraysNullable = { }, ], }, + type: 'array', }, { type: 'null', @@ -1239,141 +1299,137 @@ export const $NestedAnyOfArraysNullable = { ], }, }, + type: 'object', } as const; export const $CompositionWithOneOfAndProperties = { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'SimpleParameter', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/parameters/SimpleParameter', }, }, + additionalProperties: false, }, { + type: 'object', + required: ['bar'], properties: { bar: { - type: 'NonAsciiStringæøåÆØÅöôêÊ字符串', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', }, }, + additionalProperties: false, }, ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, } as const; export const $NullableObject = { - description: `An object that can be null`, + type: 'object', + nullable: true, + description: 'An object that can be null', properties: { foo: { type: 'string', }, }, default: null, - isNullable: true, } as const; export const $ModelWithNullableObject = { + type: 'object', properties: { data: { - type: 'NullableObject', + $ref: '#/components/schemas/NullableObject', }, }, } as const; export const $ModelWithOneOfEnum = { - type: 'one-of', - contains: [ + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Bar'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Baz'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Qux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'string', - isRequired: true, format: 'date-time', }, foo: { - type: 'Enum', + type: 'string', enum: ['Quux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'array', - contains: { - type: 'any-of', - contains: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - }, - isRequired: true, + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, }, foo: { - type: 'Enum', + type: 'string', enum: ['Corge'], - isRequired: true, }, }, }, @@ -1381,45 +1437,46 @@ export const $ModelWithOneOfEnum = { } as const; export const $ModelWithNestedArrayEnumsDataFoo = { - type: 'Enum', enum: ['foo', 'bar'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsDataBar = { - type: 'Enum', enum: ['baz', 'qux'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsData = { + type: 'object', properties: { foo: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataFoo', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, }, bar: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataBar', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', }, }, }, } as const; export const $ModelWithNestedArrayEnums = { + type: 'object', properties: { array_strings: { type: 'array', - contains: { + items: { type: 'string', }, }, data: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsData', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', }, ], }, @@ -1427,12 +1484,12 @@ export const $ModelWithNestedArrayEnums = { } as const; export const $ModelWithNestedCompositionEnums = { + type: 'object', properties: { foo: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsDataFoo', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, ], }, @@ -1440,3071 +1497,29 @@ export const $ModelWithNestedCompositionEnums = { } as const; export const $ModelWithReadOnlyAndWriteOnly = { + type: 'object', + required: ['foo', 'bar', 'baz'], properties: { foo: { type: 'string', - isRequired: true, }, bar: { + readOnly: true, type: 'string', - isReadOnly: true, - isRequired: true, }, baz: { type: 'string', - isRequired: true, + writeOnly: true, }, }, } as const; export const $SimpleParameter = { - type: 'string', - description: `This is a reusable parameter`, -} as const; - -export const $OpenApi = { - openapi: '3.0.0', - info: { - title: 'swagger', - version: 'v1.0', - }, - servers: [ - { - url: 'http://localhost:3000/base', - }, - ], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', - }, - post: { - operationId: 'PostServiceWithEmptyTag', - requestBody: { - required: true, - content: { - 'application/json': { - schema: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - { - $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', - }, - ], - }, - }, - }, - }, - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', - }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', - }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', - }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', - }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', - }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', - }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', - }, - }, - '/api/v{api-version}/foo/{foo}/bar/{bar}': { - delete: { - tags: ['Parameters'], - operationId: 'deleteFoo', - parameters: [ - { - description: 'foo in method', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in method', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - parameters: [ - { - description: 'foo in global parameters', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in global parameters', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, - }, - '/api/v{api-version}/parameters/deprecated': { - post: { - tags: ['Deprecated'], - deprecated: true, - operationId: 'DeprecatedCall', - parameters: [ - { - deprecated: true, - description: 'This parameter is deprecated', - name: 'parameter', - in: 'header', - required: true, - nullable: true, - schema: { - $ref: '#/components/schemas/DeprecatedModel', - }, - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - required: false, - schema: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - name: 'foo_ref_enum', - in: 'query', - }, - { - required: true, - schema: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - name: 'foo_all_of_enum', - in: 'query', - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'parameterCookie', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'PARAMETER-COOKIE', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/': { - get: { - tags: ['Parameters'], - operationId: 'GetCallWithOptionalParam', - parameters: [ - { - description: 'This is an optional parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is a required parameter', - required: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithOneOfEnum', - }, - }, - }, - }, - }, - post: { - tags: ['Parameters'], - operationId: 'PostCallWithOptionalParam', - parameters: [ - { - description: 'This is a required parameter', - name: 'parameter', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/Pageable', - }, - }, - ], - requestBody: { - description: 'This is an optional parameter', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/requestBody/': { - post: { - tags: ['RequestBody'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleRequestBody', - }, - }, - }, - '/api/v{api-version}/formData/': { - post: { - tags: ['FormData'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleFormData', - }, - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - nullable: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - nullable: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - nullable: true, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - nullable: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - required: false, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - required: false, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - required: false, - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - required: false, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - }, - }, - { - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - default: null, - }, - }, - ], - }, - }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - content: { - 'application/json': { - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtends', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtendsExtends', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'multi', - }, - ], - }, - }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'default', - nullable: true, - }, - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - schema: { - type: 'boolean', - default: true, - nullable: true, - }, - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - default: null, - nullable: true, - }, - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - schema: { - type: 'object', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - nullable: true, - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 201: { - description: 'Response is a simple string', - content: { - 'application/json': { - schema: { - type: 'string', - }, - }, - }, - }, - 202: { - description: 'Response is a simple boolean', - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - 203: { - description: 'Response is a simple object', - content: { - 'application/json': { - schema: { - type: 'object', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/upload': { - post: { - tags: ['Upload'], - operationId: 'UploadFile', - parameters: [ - { - description: 'Supply a file reference for upload', - name: 'file', - in: 'formData', - required: true, - schema: { - type: 'file', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - nullable: true, - }, - }, - ], - responses: { - 200: { - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/file/{id}': { - get: { - tags: ['FileResponse'], - operationId: 'FileResponse', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - responses: { - 200: { - description: 'Success', - content: { - 'audio/*': { - schema: { - type: 'file', - }, - }, - 'video/*': { - schema: { - type: 'file', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/multipart': { - post: { - tags: ['multipart'], - operationId: 'MultipartRequest', - requestBody: { - content: { - 'multipart/form-data': { - schema: { - type: 'object', - properties: { - content: { - type: 'string', - format: 'binary', - }, - data: { - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - ], - nullable: true, - }, - }, - }, - encoding: { - content: { - style: 'form', - }, - data: { - style: 'form', - }, - }, - }, - }, - }, - }, - get: { - tags: ['multipart'], - operationId: 'MultipartResponse', - responses: { - 200: { - description: 'OK', - content: { - 'multipart/mixed': { - schema: { - type: 'object', - properties: { - file: { - type: 'string', - format: 'binary', - }, - metadata: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex/{id}': { - put: { - tags: ['Complex'], - operationId: 'ComplexParams', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'integer', - format: 'int32', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - content: { - 'application/json-patch+json': { - schema: { - required: ['key', 'name', 'parameters', 'type'], - type: 'object', - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - nullable: true, - readOnly: true, - }, - name: { - maxLength: 255, - type: 'string', - nullable: true, - }, - enabled: { - type: 'boolean', - default: true, - }, - type: { - enum: ['Monkey', 'Horse', 'Bird'], - type: 'string', - readOnly: true, - }, - listOfModels: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - nullable: true, - }, - listOfStrings: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - parameters: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - user: { - type: 'object', - properties: { - id: { - type: 'integer', - format: 'int32', - readOnly: true, - }, - name: { - type: 'string', - nullable: true, - readOnly: true, - }, - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - responses: { - 200: { - description: 'Success', - content: { - 'application/json; type=collection': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - schema: { - type: 'string', - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, - }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - }, - }, - }, - components: { - requestBodies: { - SimpleRequestBody: { - 'x-body-name': 'foo', - description: 'A reusable request body', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - SimpleFormData: { - description: 'A reusable request body', - required: false, - content: { - 'multipart/form-data': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - parameters: { - SimpleParameter: { - description: 'This is a reusable parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - }, - schemas: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/components/schemas/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - nullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: [ - 'Success', - 'Warning', - 'Error', - "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串', - ], - }, - EnumWithReplacedCharacters: { - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], - type: 'string', - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - default: 200, - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - default: ['test'], - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ArrayWithAnyOfProperties: { - description: 'This is a simple array with any of properties', - type: 'array', - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - default: 'test', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - }, - AnyOfAnyAndNull: { - type: 'object', - properties: { - data: { - anyOf: [ - {}, - { - type: 'null', - }, - ], - }, - }, - }, - AnyOfArrays: { - description: 'This is a simple array with any of properties', - type: 'object', - properties: { - results: { - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - type: 'array', - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp1', 'nullableRequiredProp2'], - properties: { - nullableProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableRequiredProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - nullableRequiredProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumWithHyphen: { - description: 'This is a model with one enum with escaped name', - type: 'object', - properties: { - 'foo-bar-baz-qux': { - type: 'string', - enum: ['3.0'], - title: 'Foo-Bar-Baz-Qux', - default: '3.0', - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithProperties', - }, - }, - }, - ModelWithArrayReadOnlyAndWriteOnly: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - DeprecatedModel: { - deprecated: true, - description: 'This is a deprecated model with a deprecated property', - type: 'object', - properties: { - prop: { - deprecated: true, - description: 'This is a deprecated property', - type: 'string', - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithCircularReference', - }, - }, - }, - CompositionWithOneOf: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAnonymous: { - description: - "This is a model with one property with a 'one of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - 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', - properties: { - propA: { - type: 'object', - anyOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAnonymous: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - CompositionWithNestedAnyAndTypeNull: { - description: "This is a model with nested 'any of' property with a type null", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - ], - }, - }, - }, - Enum1: { - enum: ['Bird', 'Dog'], - type: 'string', - }, - ConstValue: { - type: 'string', - const: 'ConstValue', - }, - CompositionWithNestedAnyOfAndNull: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/Enum1', - }, - { - $ref: '#/components/schemas/ConstValue', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Scopes', - }, - }, - }, - CompositionWithOneOfAndNullable: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - oneOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleDictionary: { - description: 'This is a model that contains a simple dictionary within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'number', - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleArrayDictionary: { - description: 'This is a model that contains a dictionary of simple arrays within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - type: 'boolean', - }, - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndComplexArrayDictionary: { - description: - 'This is a model that contains a dictionary of complex arrays (composited) within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ], - }, - }, - }, - ], - }, - }, - }, - CompositionWithAllOfAndNullable: { - description: "This is a model with one property with a 'all of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - allOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAndNullable: { - description: "This is a model with one property with a 'any of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionBaseModel: { - description: 'This is a base model with two simple optional properties', - type: 'object', - properties: { - firstName: { - type: 'string', - }, - lastname: { - type: 'string', - }, - }, - }, - CompositionExtendedModel: { - description: 'This is a model that extends the base model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/CompositionBaseModel', - }, - ], - properties: { - age: { - type: 'number', - }, - }, - required: ['firstName', 'lastname', 'age'], - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - requiredAndNullable: { - type: 'string', - nullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/components/schemas/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - nullable: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - nullable: true, - properties: { - third: { - type: 'string', - required: true, - readOnly: true, - nullable: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/components/schemas/ModelWithString', - }, - propB: { - $ref: '#/components/schemas/ModelWithString', - }, - propC: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - File: { - required: ['mime'], - type: 'object', - properties: { - id: { - title: 'Id', - type: 'string', - readOnly: true, - minLength: 1, - }, - updated_at: { - title: 'Updated at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - created_at: { - title: 'Created at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - mime: { - title: 'Mime', - type: 'string', - maxLength: 24, - minLength: 1, - }, - file: { - title: 'File', - type: 'string', - readOnly: true, - format: 'uri', - }, - }, - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - Pageable: { - type: 'object', - properties: { - page: { - minimum: 0, - type: 'integer', - format: 'int32', - default: 0, - }, - size: { - minimum: 1, - type: 'integer', - format: 'int32', - }, - sort: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - FreeFormObjectWithoutAdditionalProperties: { - description: 'This is a free-form object without additionalProperties.', - type: 'object', - }, - FreeFormObjectWithAdditionalPropertiesEqTrue: { - description: 'This is a free-form object with additionalProperties: true.', - type: 'object', - additionalProperties: true, - }, - FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { - description: 'This is a free-form object with additionalProperties: {}.', - type: 'object', - additionalProperties: {}, - }, - ModelWithConst: { - type: 'object', - properties: { - String: { - const: 'String', - }, - number: { - const: 0, - }, - null: { - const: null, - }, - withType: { - type: 'string', - const: 'Some string', - }, - }, - }, - ModelWithAdditionalPropertiesEqTrue: { - description: 'This is a model with one property and additionalProperties: true', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - additionalProperties: true, - }, - NestedAnyOfArraysNullable: { - properties: { - nullableArray: { - anyOf: [ - { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - }, - }, - type: 'object', - }, - CompositionWithOneOfAndProperties: { - type: 'object', - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - $ref: '#/components/parameters/SimpleParameter', - }, - }, - additionalProperties: false, - }, - { - type: 'object', - required: ['bar'], - properties: { - bar: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - additionalProperties: false, - }, - ], - required: ['baz', 'qux'], - properties: { - baz: { - type: 'integer', - format: 'uint16', - minimum: 0, - nullable: true, - }, - qux: { - type: 'integer', - format: 'uint8', - minimum: 0, - }, - }, - }, - NullableObject: { - type: 'object', - nullable: true, - description: 'An object that can be null', - properties: { - foo: { - type: 'string', - }, - }, - default: null, - }, - ModelWithNullableObject: { - type: 'object', - properties: { - data: { - $ref: '#/components/schemas/NullableObject', - }, - }, - }, - ModelWithOneOfEnum: { - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Bar'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Baz'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Qux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'string', - format: 'date-time', - }, - foo: { - type: 'string', - enum: ['Quux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'array', - items: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - maxItems: 2, - minItems: 2, - }, - foo: { - type: 'string', - enum: ['Corge'], - }, - }, - }, - ], - }, - ModelWithNestedArrayEnumsDataFoo: { - enum: ['foo', 'bar'], - type: 'string', - }, - ModelWithNestedArrayEnumsDataBar: { - enum: ['baz', 'qux'], - type: 'string', - }, - ModelWithNestedArrayEnumsData: { - type: 'object', - properties: { - foo: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - }, - bar: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', - }, - }, - }, - }, - ModelWithNestedArrayEnums: { - type: 'object', - properties: { - array_strings: { - type: 'array', - items: { - type: 'string', - }, - }, - data: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', - }, - ], - }, - }, - }, - ModelWithNestedCompositionEnums: { - type: 'object', - properties: { - foo: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - }, - }, - ModelWithReadOnlyAndWriteOnly: { - type: 'object', - required: ['foo', 'bar', 'baz'], - properties: { - foo: { - type: 'string', - }, - bar: { - readOnly: true, - type: 'string', - }, - baz: { - type: 'string', - writeOnly: true, - }, - }, - }, - }, + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', }, } as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap index f7f419e44..d4f2992e7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap @@ -1,142 +1,155 @@ export const $CommentWithBreaks = { - type: 'number', description: `Testing multiline comments in string: First line Second line Fourth line`, + type: 'integer', } as const; export const $CommentWithBackticks = { - type: 'number', - description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', } as const; export const $CommentWithSlashes = { - type: 'number', - description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', } as const; export const $CommentWithExpressionPlaceholders = { - type: 'number', - description: `Testing expression placeholders in string: \${expression} should work`, + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', } as const; export const $CommentWithQuotes = { - type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', } as const; export const $CommentWithReservedCharacters = { - type: 'number', - description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', } as const; export const $SimpleInteger = { - type: 'number', - description: `This is a simple number`, + description: 'This is a simple number', + type: 'integer', } as const; export const $SimpleBoolean = { + description: 'This is a simple boolean', type: 'boolean', - description: `This is a simple boolean`, } as const; export const $SimpleString = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, } as const; export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string', - description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; export const $SimpleFile = { - type: 'binary', - description: `This is a simple file`, + description: 'This is a simple file', + type: 'file', } as const; export const $SimpleReference = { - type: 'ModelWithString', - description: `This is a simple reference`, + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', } as const; export const $SimpleStringWithPattern = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, - isNullable: true, + nullable: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', } as const; export const $EnumWithStrings = { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; export const $EnumWithReplacedCharacters = { - type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', } as const; export const $EnumWithNumbers = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], default: 200, } as const; export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', type: 'number', - description: `Success=1,Warning=2,Error=3`, } as const; export const $EnumWithExtensions = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], } as const; export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', type: 'array', - contains: { - type: 'number', + items: { + type: 'integer', }, } as const; export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', type: 'array', - contains: { + items: { type: 'boolean', }, } as const; export const $ArrayWithStrings = { + description: 'This is a simple array with strings', type: 'array', - contains: { + items: { type: 'string', }, default: ['test'], } as const; export const $ArrayWithReferences = { + description: 'This is a simple array with references', type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $ArrayWithArray = { + description: 'This is a simple array containing an array', type: 'array', - contains: { + items: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ArrayWithProperties = { + description: 'This is a simple array with properties', type: 'array', - contains: { + items: { + type: 'object', properties: { foo: { type: 'string', @@ -149,11 +162,12 @@ export const $ArrayWithProperties = { } as const; export const $ArrayWithAnyOfProperties = { + description: 'This is a simple array with any of properties', type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -162,6 +176,7 @@ export const $ArrayWithAnyOfProperties = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -173,13 +188,11 @@ export const $ArrayWithAnyOfProperties = { } as const; export const $AnyOfAnyAndNull = { + type: 'object', properties: { data: { - type: 'any-of', - contains: [ - { - properties: {}, - }, + anyOf: [ + {}, { type: 'null', }, @@ -189,14 +202,14 @@ export const $AnyOfAnyAndNull = { } as const; export const $AnyOfArrays = { - description: `This is a simple array with any of properties`, + description: 'This is a simple array with any of properties', + type: 'object', properties: { results: { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -204,6 +217,7 @@ export const $AnyOfArrays = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -212,47 +226,54 @@ export const $AnyOfArrays = { }, ], }, + type: 'array', }, }, } as const; export const $DictionaryWithString = { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { type: 'string', }, } as const; export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $DictionaryWithArray = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', }, }, } as const; export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', properties: { foo: { type: 'string', @@ -265,171 +286,178 @@ export const $DictionaryWithProperties = { } as const; export const $ModelWithInteger = { - description: `This is a model with one number property`, + description: 'This is a model with one number property', + type: 'object', properties: { prop: { - type: 'number', - description: `This is a simple number property`, + description: 'This is a simple number property', + type: 'integer', }, }, } as const; export const $ModelWithBoolean = { - description: `This is a model with one boolean property`, + description: 'This is a model with one boolean property', + type: 'object', properties: { prop: { + description: 'This is a simple boolean property', type: 'boolean', - description: `This is a simple boolean property`, }, }, } as const; export const $ModelWithString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, } as const; export const $ModelWithNullableString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], properties: { nullableProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isNullable: true, + nullable: true, }, nullableRequiredProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + nullable: true, }, nullableProp2: { - type: 'string', - description: `This is a simple string property`, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, nullableRequiredProp2: { - type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithEnum = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, statusCode: { - type: 'Enum', + description: 'These are the HTTP error code enums', enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], }, bool: { + description: 'Simple boolean enum', type: 'boolean', - description: `Simple boolean enum`, + enum: [true], }, }, } as const; export const $ModelWithEnumWithHyphen = { - description: `This is a model with one enum with escaped name`, + description: 'This is a model with one enum with escaped name', + type: 'object', properties: { 'foo-bar-baz-qux': { - type: 'Enum', + type: 'string', enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', default: '3.0', }, }, } as const; export const $ModelWithEnumFromDescription = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, } as const; export const $ModelWithNestedEnums = { - description: `This is a model with nested enums`, + description: 'This is a model with nested enums', + type: 'object', properties: { dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', + type: 'object', + additionalProperties: { enum: ['Success', 'Warning', 'Error'], }, }, dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, arrayWithEnum: { type: 'array', - contains: { - type: 'Enum', + items: { enum: ['Success', 'Warning', 'Error'], }, }, arrayWithDescription: { type: 'array', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithReference = { - description: `This is a model with one property containing a reference`, + description: 'This is a model with one property containing a reference', + type: 'object', properties: { prop: { - type: 'ModelWithProperties', + $ref: '#/components/schemas/ModelWithProperties', }, }, } as const; export const $ModelWithArrayReadOnlyAndWriteOnly = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithReadOnlyAndWriteOnly', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -437,23 +465,24 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } as const; export const $ModelWithArray = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -461,11 +490,12 @@ export const $ModelWithArray = { } as const; export const $ModelWithDictionary = { - description: `This is a model with one property containing a dictionary`, + description: 'This is a model with one property containing a dictionary', + type: 'object', properties: { prop: { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'string', }, }, @@ -473,41 +503,46 @@ export const $ModelWithDictionary = { } as const; export const $DeprecatedModel = { - description: `This is a deprecated model with a deprecated property`, + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', properties: { prop: { + deprecated: true, + description: 'This is a deprecated property', type: 'string', - description: `This is a deprecated property`, }, }, } as const; export const $ModelWithCircularReference = { - description: `This is a model with one property containing a circular reference`, + description: 'This is a model with one property containing a circular reference', + type: 'object', properties: { prop: { - type: 'ModelWithCircularReference', + $ref: '#/components/schemas/ModelWithCircularReference', }, }, } as const; export const $CompositionWithOneOf = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -515,13 +550,15 @@ export const $CompositionWithOneOf = { } as const; export const $CompositionWithOneOfAnonymous = { - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -529,12 +566,12 @@ export const $CompositionWithOneOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -542,11 +579,12 @@ export const $CompositionWithOneOfAnonymous = { } as const; export const $ModelCircle = { - description: `Circle`, + description: 'Circle', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, radius: { type: 'number', @@ -555,11 +593,12 @@ export const $ModelCircle = { } as const; export const $ModelSquare = { - description: `Square`, + description: 'Square', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, sideLength: { type: 'number', @@ -568,35 +607,43 @@ export const $ModelSquare = { } as const; export const $CompositionWithOneOfDiscriminator = { - type: 'one-of', - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, - contains: [ + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + oneOf: [ { - type: 'ModelCircle', + $ref: '#/components/schemas/ModelCircle', }, { - type: 'ModelSquare', + $ref: '#/components/schemas/ModelSquare', }, ], + discriminator: { + propertyName: 'kind', + mapping: { + circle: '#/components/schemas/ModelCircle', + square: '#/components/schemas/ModelSquare', + }, + }, } as const; export const $CompositionWithAnyOf = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -604,13 +651,15 @@ export const $CompositionWithAnyOf = { } as const; export const $CompositionWithAnyOfAnonymous = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -618,12 +667,12 @@ export const $CompositionWithAnyOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -631,38 +680,37 @@ export const $CompositionWithAnyOfAnonymous = { } as const; export const $CompositionWithNestedAnyAndTypeNull = { - description: `This is a model with nested 'any of' property with a type null`, + description: "This is a model with nested 'any of' property with a type null", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, { type: 'null', }, ], }, + type: 'array', }, { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { type: 'null', }, ], }, + type: 'array', }, ], }, @@ -670,49 +718,53 @@ export const $CompositionWithNestedAnyAndTypeNull = { } as const; export const $Enum1 = { - type: 'Enum', enum: ['Bird', 'Dog'], + type: 'string', } as const; export const $ConstValue = { - type: '"ConstValue"', + type: 'string', + const: 'ConstValue', } as const; export const $CompositionWithNestedAnyOfAndNull = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'Enum1', + $ref: '#/components/schemas/Enum1', }, { - type: 'ConstValue', + $ref: '#/components/schemas/ConstValue', }, ], }, + type: 'array', }, { type: 'null', }, ], + title: 'Scopes', }, }, } as const; export const $CompositionWithOneOfAndNullable = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + nullable: true, + type: 'object', + oneOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -720,32 +772,31 @@ export const $CompositionWithOneOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithOneOfAndSimpleDictionary = { - description: `This is a model that contains a simple dictionary within composition`, + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'number', }, }, @@ -755,19 +806,19 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } as const; export const $CompositionWithOneOfAndSimpleArrayDictionary = { - description: `This is a model that contains a dictionary of simple arrays within composition`, + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { + items: { type: 'boolean', }, }, @@ -778,21 +829,20 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } as const; export const $CompositionWithOneOfAndComplexArrayDictionary = { - description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, + description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'one-of', - contains: [ + items: { + oneOf: [ { type: 'number', }, @@ -809,12 +859,15 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } as const; export const $CompositionWithAllOfAndNullable = { - description: `This is a model with one property with a 'all of' relationship`, + description: "This is a model with one property with a 'all of' relationship", + type: 'object', properties: { propA: { - type: 'all-of', - contains: [ + nullable: true, + type: 'object', + allOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -822,27 +875,29 @@ export const $CompositionWithAllOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithAnyOfAndNullable = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + nullable: true, + type: 'object', + anyOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -850,22 +905,22 @@ export const $CompositionWithAnyOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionBaseModel = { - description: `This is a base model with two simple optional properties`, + description: 'This is a base model with two simple optional properties', + type: 'object', properties: { firstName: { type: 'string', @@ -877,47 +932,36 @@ export const $CompositionBaseModel = { } as const; export const $CompositionExtendedModel = { - type: 'all-of', - description: `This is a model that extends the base model`, - contains: [ - { - type: 'CompositionBaseModel', - }, + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ { - properties: { - firstName: { - type: 'string', - isRequired: true, - }, - lastname: { - type: 'string', - isRequired: true, - }, - age: { - type: 'number', - isRequired: true, - }, - }, + $ref: '#/components/schemas/CompositionBaseModel', }, ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], } as const; export const $ModelWithProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], properties: { required: { type: 'string', - isRequired: true, }, requiredAndReadOnly: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, requiredAndNullable: { type: 'string', - isRequired: true, - isNullable: true, + nullable: true, }, string: { type: 'string', @@ -929,7 +973,7 @@ export const $ModelWithProperties = { type: 'boolean', }, reference: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, 'property with space': { type: 'string', @@ -942,52 +986,58 @@ export const $ModelWithProperties = { }, '@namespace.string': { type: 'string', - isReadOnly: true, + readOnly: true, }, '@namespace.integer': { - type: 'number', - isReadOnly: true, + type: 'integer', + readOnly: true, }, }, } as const; export const $ModelWithNestedProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], properties: { first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, properties: { second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, properties: { third: { type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + required: true, + readOnly: true, + nullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, } as const; export const $ModelWithDuplicateProperties = { - description: `This is a model with duplicated properties`, + description: 'This is a model with duplicated properties', + type: 'object', properties: { prop: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelWithOrderedProperties = { - description: `This is a model with ordered properties`, + description: 'This is a model with ordered properties', + type: 'object', properties: { zebra: { type: 'string', @@ -1002,34 +1052,36 @@ export const $ModelWithOrderedProperties = { } as const; export const $ModelWithDuplicateImports = { - description: `This is a model with duplicated imports`, + description: 'This is a model with duplicated imports', + type: 'object', properties: { propA: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propC: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelThatExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { + type: 'object', properties: { propExtendsA: { type: 'string', }, propExtendsB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1037,22 +1089,23 @@ export const $ModelThatExtends = { } as const; export const $ModelThatExtendsExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelThatExtends', + $ref: '#/components/schemas/ModelThatExtends', }, { + type: 'object', properties: { propExtendsC: { type: 'string', }, propExtendsD: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1060,35 +1113,35 @@ export const $ModelThatExtendsExtends = { } as const; export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], properties: { key: { - type: 'string', - isRequired: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, name: { - type: 'string', - isRequired: true, maxLength: 255, + type: 'string', }, enabled: { type: 'boolean', - isReadOnly: true, + readOnly: true, }, modified: { type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, id: { type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + pattern: '^d{2}-d{3}-d{4}$', }, text: { type: 'string', - pattern: '^\\w+$', + pattern: '^w+$', }, patternWithSingleQuotes: { type: 'string', @@ -1096,7 +1149,8 @@ export const $ModelWithPattern = { }, patternWithNewline: { type: 'string', - pattern: 'aaa\nbbb', + pattern: `aaa +bbb`, }, patternWithBacktick: { type: 'string', @@ -1106,37 +1160,44 @@ export const $ModelWithPattern = { } as const; export const $File = { + required: ['mime'], + type: 'object', properties: { id: { + title: 'Id', type: 'string', - isReadOnly: true, + readOnly: true, minLength: 1, }, updated_at: { + title: 'Updated at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, created_at: { + title: 'Created at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, mime: { + title: 'Mime', type: 'string', - isRequired: true, maxLength: 24, minLength: 1, }, file: { + title: 'File', type: 'string', - isReadOnly: true, + readOnly: true, format: 'uri', }, }, } as const; -export const $_default = { +export const $default = { + type: 'object', properties: { name: { type: 'string', @@ -1145,21 +1206,22 @@ export const $_default = { } as const; export const $Pageable = { + type: 'object', properties: { page: { - type: 'number', - default: 0, - format: 'int32', minimum: 0, + type: 'integer', + format: 'int32', + default: 0, }, size: { - type: 'number', - format: 'int32', minimum: 1, + type: 'integer', + format: 'int32', }, sort: { type: 'array', - contains: { + items: { type: 'string', }, }, @@ -1167,63 +1229,60 @@ export const $Pageable = { } as const; export const $FreeFormObjectWithoutAdditionalProperties = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object without additionalProperties.', + type: 'object', } as const; export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, } as const; export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, } as const; export const $ModelWithConst = { + type: 'object', properties: { String: { - type: '"String"', + const: 'String', }, number: { - type: '0', + const: 0, }, null: { - type: 'null', + const: null, }, withType: { - type: '"Some string"', + type: 'string', + const: 'Some string', }, }, } as const; export const $ModelWithAdditionalPropertiesEqTrue = { - description: `This is a model with one property and additionalProperties: true`, + description: 'This is a model with one property and additionalProperties: true', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, + additionalProperties: true, } as const; export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { type: 'string', }, @@ -1232,6 +1291,7 @@ export const $NestedAnyOfArraysNullable = { }, ], }, + type: 'array', }, { type: 'null', @@ -1239,141 +1299,137 @@ export const $NestedAnyOfArraysNullable = { ], }, }, + type: 'object', } as const; export const $CompositionWithOneOfAndProperties = { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'SimpleParameter', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/parameters/SimpleParameter', }, }, + additionalProperties: false, }, { + type: 'object', + required: ['bar'], properties: { bar: { - type: 'NonAsciiStringæøåÆØÅöôêÊ字符串', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', }, }, + additionalProperties: false, }, ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, } as const; export const $NullableObject = { - description: `An object that can be null`, + type: 'object', + nullable: true, + description: 'An object that can be null', properties: { foo: { type: 'string', }, }, default: null, - isNullable: true, } as const; export const $ModelWithNullableObject = { + type: 'object', properties: { data: { - type: 'NullableObject', + $ref: '#/components/schemas/NullableObject', }, }, } as const; export const $ModelWithOneOfEnum = { - type: 'one-of', - contains: [ + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Bar'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Baz'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Qux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'string', - isRequired: true, format: 'date-time', }, foo: { - type: 'Enum', + type: 'string', enum: ['Quux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'array', - contains: { - type: 'any-of', - contains: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - }, - isRequired: true, + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, }, foo: { - type: 'Enum', + type: 'string', enum: ['Corge'], - isRequired: true, }, }, }, @@ -1381,45 +1437,46 @@ export const $ModelWithOneOfEnum = { } as const; export const $ModelWithNestedArrayEnumsDataFoo = { - type: 'Enum', enum: ['foo', 'bar'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsDataBar = { - type: 'Enum', enum: ['baz', 'qux'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsData = { + type: 'object', properties: { foo: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataFoo', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, }, bar: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataBar', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', }, }, }, } as const; export const $ModelWithNestedArrayEnums = { + type: 'object', properties: { array_strings: { type: 'array', - contains: { + items: { type: 'string', }, }, data: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsData', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', }, ], }, @@ -1427,12 +1484,12 @@ export const $ModelWithNestedArrayEnums = { } as const; export const $ModelWithNestedCompositionEnums = { + type: 'object', properties: { foo: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsDataFoo', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, ], }, @@ -1440,3071 +1497,29 @@ export const $ModelWithNestedCompositionEnums = { } as const; export const $ModelWithReadOnlyAndWriteOnly = { + type: 'object', + required: ['foo', 'bar', 'baz'], properties: { foo: { type: 'string', - isRequired: true, }, bar: { + readOnly: true, type: 'string', - isReadOnly: true, - isRequired: true, }, baz: { type: 'string', - isRequired: true, + writeOnly: true, }, }, } as const; export const $SimpleParameter = { - type: 'string', - description: `This is a reusable parameter`, -} as const; - -export const $OpenApi = { - openapi: '3.0.0', - info: { - title: 'swagger', - version: 'v1.0', - }, - servers: [ - { - url: 'http://localhost:3000/base', - }, - ], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', - }, - post: { - operationId: 'PostServiceWithEmptyTag', - requestBody: { - required: true, - content: { - 'application/json': { - schema: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - { - $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', - }, - ], - }, - }, - }, - }, - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', - }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', - }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', - }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', - }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', - }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', - }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', - }, - }, - '/api/v{api-version}/foo/{foo}/bar/{bar}': { - delete: { - tags: ['Parameters'], - operationId: 'deleteFoo', - parameters: [ - { - description: 'foo in method', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in method', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - parameters: [ - { - description: 'foo in global parameters', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in global parameters', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, - }, - '/api/v{api-version}/parameters/deprecated': { - post: { - tags: ['Deprecated'], - deprecated: true, - operationId: 'DeprecatedCall', - parameters: [ - { - deprecated: true, - description: 'This parameter is deprecated', - name: 'parameter', - in: 'header', - required: true, - nullable: true, - schema: { - $ref: '#/components/schemas/DeprecatedModel', - }, - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - required: false, - schema: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - name: 'foo_ref_enum', - in: 'query', - }, - { - required: true, - schema: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - name: 'foo_all_of_enum', - in: 'query', - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'parameterCookie', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'PARAMETER-COOKIE', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/': { - get: { - tags: ['Parameters'], - operationId: 'GetCallWithOptionalParam', - parameters: [ - { - description: 'This is an optional parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is a required parameter', - required: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithOneOfEnum', - }, - }, - }, - }, - }, - post: { - tags: ['Parameters'], - operationId: 'PostCallWithOptionalParam', - parameters: [ - { - description: 'This is a required parameter', - name: 'parameter', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/Pageable', - }, - }, - ], - requestBody: { - description: 'This is an optional parameter', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/requestBody/': { - post: { - tags: ['RequestBody'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleRequestBody', - }, - }, - }, - '/api/v{api-version}/formData/': { - post: { - tags: ['FormData'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleFormData', - }, - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - nullable: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - nullable: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - nullable: true, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - nullable: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - required: false, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - required: false, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - required: false, - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - required: false, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - }, - }, - { - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - default: null, - }, - }, - ], - }, - }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - content: { - 'application/json': { - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtends', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtendsExtends', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'multi', - }, - ], - }, - }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'default', - nullable: true, - }, - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - schema: { - type: 'boolean', - default: true, - nullable: true, - }, - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - default: null, - nullable: true, - }, - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - schema: { - type: 'object', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - nullable: true, - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 201: { - description: 'Response is a simple string', - content: { - 'application/json': { - schema: { - type: 'string', - }, - }, - }, - }, - 202: { - description: 'Response is a simple boolean', - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - 203: { - description: 'Response is a simple object', - content: { - 'application/json': { - schema: { - type: 'object', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/upload': { - post: { - tags: ['Upload'], - operationId: 'UploadFile', - parameters: [ - { - description: 'Supply a file reference for upload', - name: 'file', - in: 'formData', - required: true, - schema: { - type: 'file', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - nullable: true, - }, - }, - ], - responses: { - 200: { - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/file/{id}': { - get: { - tags: ['FileResponse'], - operationId: 'FileResponse', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - responses: { - 200: { - description: 'Success', - content: { - 'audio/*': { - schema: { - type: 'file', - }, - }, - 'video/*': { - schema: { - type: 'file', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/multipart': { - post: { - tags: ['multipart'], - operationId: 'MultipartRequest', - requestBody: { - content: { - 'multipart/form-data': { - schema: { - type: 'object', - properties: { - content: { - type: 'string', - format: 'binary', - }, - data: { - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - ], - nullable: true, - }, - }, - }, - encoding: { - content: { - style: 'form', - }, - data: { - style: 'form', - }, - }, - }, - }, - }, - }, - get: { - tags: ['multipart'], - operationId: 'MultipartResponse', - responses: { - 200: { - description: 'OK', - content: { - 'multipart/mixed': { - schema: { - type: 'object', - properties: { - file: { - type: 'string', - format: 'binary', - }, - metadata: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex/{id}': { - put: { - tags: ['Complex'], - operationId: 'ComplexParams', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'integer', - format: 'int32', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - content: { - 'application/json-patch+json': { - schema: { - required: ['key', 'name', 'parameters', 'type'], - type: 'object', - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - nullable: true, - readOnly: true, - }, - name: { - maxLength: 255, - type: 'string', - nullable: true, - }, - enabled: { - type: 'boolean', - default: true, - }, - type: { - enum: ['Monkey', 'Horse', 'Bird'], - type: 'string', - readOnly: true, - }, - listOfModels: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - nullable: true, - }, - listOfStrings: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - parameters: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - user: { - type: 'object', - properties: { - id: { - type: 'integer', - format: 'int32', - readOnly: true, - }, - name: { - type: 'string', - nullable: true, - readOnly: true, - }, - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - responses: { - 200: { - description: 'Success', - content: { - 'application/json; type=collection': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - schema: { - type: 'string', - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, - }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - }, - }, - }, - components: { - requestBodies: { - SimpleRequestBody: { - 'x-body-name': 'foo', - description: 'A reusable request body', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - SimpleFormData: { - description: 'A reusable request body', - required: false, - content: { - 'multipart/form-data': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - parameters: { - SimpleParameter: { - description: 'This is a reusable parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - }, - schemas: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/components/schemas/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - nullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: [ - 'Success', - 'Warning', - 'Error', - "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串', - ], - }, - EnumWithReplacedCharacters: { - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], - type: 'string', - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - default: 200, - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - default: ['test'], - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ArrayWithAnyOfProperties: { - description: 'This is a simple array with any of properties', - type: 'array', - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - default: 'test', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - }, - AnyOfAnyAndNull: { - type: 'object', - properties: { - data: { - anyOf: [ - {}, - { - type: 'null', - }, - ], - }, - }, - }, - AnyOfArrays: { - description: 'This is a simple array with any of properties', - type: 'object', - properties: { - results: { - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - type: 'array', - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp1', 'nullableRequiredProp2'], - properties: { - nullableProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableRequiredProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - nullableRequiredProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumWithHyphen: { - description: 'This is a model with one enum with escaped name', - type: 'object', - properties: { - 'foo-bar-baz-qux': { - type: 'string', - enum: ['3.0'], - title: 'Foo-Bar-Baz-Qux', - default: '3.0', - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithProperties', - }, - }, - }, - ModelWithArrayReadOnlyAndWriteOnly: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - DeprecatedModel: { - deprecated: true, - description: 'This is a deprecated model with a deprecated property', - type: 'object', - properties: { - prop: { - deprecated: true, - description: 'This is a deprecated property', - type: 'string', - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithCircularReference', - }, - }, - }, - CompositionWithOneOf: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAnonymous: { - description: - "This is a model with one property with a 'one of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - 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', - properties: { - propA: { - type: 'object', - anyOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAnonymous: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - CompositionWithNestedAnyAndTypeNull: { - description: "This is a model with nested 'any of' property with a type null", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - ], - }, - }, - }, - Enum1: { - enum: ['Bird', 'Dog'], - type: 'string', - }, - ConstValue: { - type: 'string', - const: 'ConstValue', - }, - CompositionWithNestedAnyOfAndNull: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/Enum1', - }, - { - $ref: '#/components/schemas/ConstValue', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Scopes', - }, - }, - }, - CompositionWithOneOfAndNullable: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - oneOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleDictionary: { - description: 'This is a model that contains a simple dictionary within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'number', - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleArrayDictionary: { - description: 'This is a model that contains a dictionary of simple arrays within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - type: 'boolean', - }, - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndComplexArrayDictionary: { - description: - 'This is a model that contains a dictionary of complex arrays (composited) within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ], - }, - }, - }, - ], - }, - }, - }, - CompositionWithAllOfAndNullable: { - description: "This is a model with one property with a 'all of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - allOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAndNullable: { - description: "This is a model with one property with a 'any of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionBaseModel: { - description: 'This is a base model with two simple optional properties', - type: 'object', - properties: { - firstName: { - type: 'string', - }, - lastname: { - type: 'string', - }, - }, - }, - CompositionExtendedModel: { - description: 'This is a model that extends the base model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/CompositionBaseModel', - }, - ], - properties: { - age: { - type: 'number', - }, - }, - required: ['firstName', 'lastname', 'age'], - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - requiredAndNullable: { - type: 'string', - nullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/components/schemas/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - nullable: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - nullable: true, - properties: { - third: { - type: 'string', - required: true, - readOnly: true, - nullable: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/components/schemas/ModelWithString', - }, - propB: { - $ref: '#/components/schemas/ModelWithString', - }, - propC: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - File: { - required: ['mime'], - type: 'object', - properties: { - id: { - title: 'Id', - type: 'string', - readOnly: true, - minLength: 1, - }, - updated_at: { - title: 'Updated at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - created_at: { - title: 'Created at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - mime: { - title: 'Mime', - type: 'string', - maxLength: 24, - minLength: 1, - }, - file: { - title: 'File', - type: 'string', - readOnly: true, - format: 'uri', - }, - }, - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - Pageable: { - type: 'object', - properties: { - page: { - minimum: 0, - type: 'integer', - format: 'int32', - default: 0, - }, - size: { - minimum: 1, - type: 'integer', - format: 'int32', - }, - sort: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - FreeFormObjectWithoutAdditionalProperties: { - description: 'This is a free-form object without additionalProperties.', - type: 'object', - }, - FreeFormObjectWithAdditionalPropertiesEqTrue: { - description: 'This is a free-form object with additionalProperties: true.', - type: 'object', - additionalProperties: true, - }, - FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { - description: 'This is a free-form object with additionalProperties: {}.', - type: 'object', - additionalProperties: {}, - }, - ModelWithConst: { - type: 'object', - properties: { - String: { - const: 'String', - }, - number: { - const: 0, - }, - null: { - const: null, - }, - withType: { - type: 'string', - const: 'Some string', - }, - }, - }, - ModelWithAdditionalPropertiesEqTrue: { - description: 'This is a model with one property and additionalProperties: true', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - additionalProperties: true, - }, - NestedAnyOfArraysNullable: { - properties: { - nullableArray: { - anyOf: [ - { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - }, - }, - type: 'object', - }, - CompositionWithOneOfAndProperties: { - type: 'object', - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - $ref: '#/components/parameters/SimpleParameter', - }, - }, - additionalProperties: false, - }, - { - type: 'object', - required: ['bar'], - properties: { - bar: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - additionalProperties: false, - }, - ], - required: ['baz', 'qux'], - properties: { - baz: { - type: 'integer', - format: 'uint16', - minimum: 0, - nullable: true, - }, - qux: { - type: 'integer', - format: 'uint8', - minimum: 0, - }, - }, - }, - NullableObject: { - type: 'object', - nullable: true, - description: 'An object that can be null', - properties: { - foo: { - type: 'string', - }, - }, - default: null, - }, - ModelWithNullableObject: { - type: 'object', - properties: { - data: { - $ref: '#/components/schemas/NullableObject', - }, - }, - }, - ModelWithOneOfEnum: { - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Bar'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Baz'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Qux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'string', - format: 'date-time', - }, - foo: { - type: 'string', - enum: ['Quux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'array', - items: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - maxItems: 2, - minItems: 2, - }, - foo: { - type: 'string', - enum: ['Corge'], - }, - }, - }, - ], - }, - ModelWithNestedArrayEnumsDataFoo: { - enum: ['foo', 'bar'], - type: 'string', - }, - ModelWithNestedArrayEnumsDataBar: { - enum: ['baz', 'qux'], - type: 'string', - }, - ModelWithNestedArrayEnumsData: { - type: 'object', - properties: { - foo: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - }, - bar: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', - }, - }, - }, - }, - ModelWithNestedArrayEnums: { - type: 'object', - properties: { - array_strings: { - type: 'array', - items: { - type: 'string', - }, - }, - data: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', - }, - ], - }, - }, - }, - ModelWithNestedCompositionEnums: { - type: 'object', - properties: { - foo: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - }, - }, - ModelWithReadOnlyAndWriteOnly: { - type: 'object', - required: ['foo', 'bar', 'baz'], - properties: { - foo: { - type: 'string', - }, - bar: { - readOnly: true, - type: 'string', - }, - baz: { - type: 'string', - writeOnly: true, - }, - }, - }, - }, + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', }, } as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap index aa980d0b0..d4f2992e7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap @@ -1,3092 +1,1525 @@ -export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, +export const $CommentWithBreaks = { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer', +} as const; + +export const $CommentWithBackticks = { + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', +} as const; + +export const $CommentWithSlashes = { + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', +} as const; + +export const $CommentWithExpressionPlaceholders = { + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', +} as const; + +export const $CommentWithQuotes = { + description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', +} as const; + +export const $CommentWithReservedCharacters = { + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', +} as const; + +export const $SimpleInteger = { + description: 'This is a simple number', + type: 'integer', +} as const; + +export const $SimpleBoolean = { + description: 'This is a simple boolean', + type: 'boolean', +} as const; + +export const $SimpleString = { + description: 'This is a simple string', + type: 'string', +} as const; + +export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', + type: 'string', +} as const; + +export const $SimpleFile = { + description: 'This is a simple file', + type: 'file', +} as const; + +export const $SimpleReference = { + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', +} as const; + +export const $SimpleStringWithPattern = { + description: 'This is a simple string', + type: 'string', + nullable: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', +} as const; + +export const $EnumWithStrings = { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + +export const $EnumWithReplacedCharacters = { + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', +} as const; + +export const $EnumWithNumbers = { + description: 'This is a simple enum with numbers', + enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], + default: 200, +} as const; + +export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', + type: 'number', +} as const; + +export const $EnumWithExtensions = { + description: 'This is a simple enum with numbers', + enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], +} as const; + +export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', + type: 'array', + items: { + type: 'integer', + }, +} as const; + +export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', + type: 'array', + items: { + type: 'boolean', + }, +} as const; + +export const $ArrayWithStrings = { + description: 'This is a simple array with strings', + type: 'array', + items: { + type: 'string', + }, + default: ['test'], +} as const; + +export const $ArrayWithReferences = { + description: 'This is a simple array with references', + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, +} as const; + +export const $ArrayWithArray = { + description: 'This is a simple array containing an array', + type: 'array', + items: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, +} as const; + +export const $ArrayWithProperties = { + description: 'This is a simple array with properties', + type: 'array', + items: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +} as const; + +export const $ArrayWithAnyOfProperties = { + description: 'This is a simple array with any of properties', + type: 'array', + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + default: 'test', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, +} as const; + +export const $AnyOfAnyAndNull = { + type: 'object', properties: { - key: { - type: 'string', - isRequired: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', + data: { + anyOf: [ + {}, + { + type: 'null', + }, + ], }, - name: { + }, +} as const; + +export const $AnyOfArrays = { + description: 'This is a simple array with any of properties', + type: 'object', + properties: { + results: { + items: { + anyOf: [ + { + type: 'object', + properties: { + foo: { + type: 'string', + }, + }, + }, + { + type: 'object', + properties: { + bar: { + type: 'string', + }, + }, + }, + ], + }, + type: 'array', + }, + }, +} as const; + +export const $DictionaryWithString = { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'string', + }, +} as const; + +export const $DictionaryWithReference = { + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', + }, +} as const; + +export const $DictionaryWithArray = { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', + }, + }, +} as const; + +export const $DictionaryWithDictionary = { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', - isRequired: true, - maxLength: 255, }, - enabled: { + }, +} as const; + +export const $DictionaryWithProperties = { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'string', + }, + }, + }, +} as const; + +export const $ModelWithInteger = { + description: 'This is a model with one number property', + type: 'object', + properties: { + prop: { + description: 'This is a simple number property', + type: 'integer', + }, + }, +} as const; + +export const $ModelWithBoolean = { + description: 'This is a model with one boolean property', + type: 'object', + properties: { + prop: { + description: 'This is a simple boolean property', type: 'boolean', - isReadOnly: true, }, - modified: { + }, +} as const; + +export const $ModelWithString = { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', type: 'string', - isReadOnly: true, - format: 'date-time', }, - id: { + }, +} as const; + +export const $ModelWithNullableString = { + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], + properties: { + nullableProp1: { + description: 'This is a simple string property', type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + nullable: true, }, - text: { + nullableRequiredProp1: { + description: 'This is a simple string property', type: 'string', - pattern: '^\\w+$', + nullable: true, }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", + nullableProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], }, - patternWithNewline: { - type: 'string', - pattern: 'aaa\nbbb', + nullableRequiredProp2: { + description: 'This is a simple string property', + type: ['string', 'null'], }, - patternWithBacktick: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, +} as const; + +export const $ModelWithEnum = { + description: 'This is a model with one enum', + type: 'object', + properties: { + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + statusCode: { + description: 'These are the HTTP error code enums', + enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], + }, + bool: { + description: 'Simple boolean enum', + type: 'boolean', + enum: [true], + }, + }, +} as const; + +export const $ModelWithEnumWithHyphen = { + description: 'This is a model with one enum with escaped name', + type: 'object', + properties: { + 'foo-bar-baz-qux': { type: 'string', - pattern: 'aaa`bbb', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0', }, }, } as const; -export const $OpenApi = { - openapi: '3.0.0', - info: { - title: 'swagger', - version: 'v1.0', +export const $ModelWithEnumFromDescription = { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', + }, }, - servers: [ - { - url: 'http://localhost:3000/base', +} as const; + +export const $ModelWithNestedEnums = { + description: 'This is a model with nested enums', + type: 'object', + properties: { + dictionaryWithEnum: { + type: 'object', + additionalProperties: { + enum: ['Success', 'Warning', 'Error'], + }, }, - ], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', + dictionaryWithEnumFromDescription: { + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, - post: { - operationId: 'PostServiceWithEmptyTag', - requestBody: { - required: true, - content: { - 'application/json': { - schema: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - { - $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', - }, - ], - }, - }, - }, - }, - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - }, - }, - }, + }, + arrayWithEnum: { + type: 'array', + items: { + enum: ['Success', 'Warning', 'Error'], }, }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', + arrayWithDescription: { + type: 'array', + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', + }, + 'foo_bar-enum': { + description: 'This is a simple enum with strings', + enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], + }, + }, +} as const; + +export const $ModelWithReference = { + description: 'This is a model with one property containing a reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithProperties', + }, + }, +} as const; + +export const $ModelWithArrayReadOnlyAndWriteOnly = { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', + }, + propWithFile: { + type: 'array', + items: { + type: 'file', }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', + }, + }, +} as const; + +export const $ModelWithArray = { + description: 'This is a model with one property containing an array', + type: 'object', + properties: { + prop: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithString', }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', + }, + propWithFile: { + type: 'array', + items: { + type: 'file', }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', + }, + propWithNumber: { + type: 'array', + items: { + type: 'number', }, }, - '/api/v{api-version}/foo/{foo}/bar/{bar}': { - delete: { - tags: ['Parameters'], - operationId: 'deleteFoo', - parameters: [ - { - description: 'foo in method', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in method', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], + }, +} as const; + +export const $ModelWithDictionary = { + description: 'This is a model with one property containing a dictionary', + type: 'object', + properties: { + prop: { + type: 'object', + additionalProperties: { + type: 'string', }, - parameters: [ - { - description: 'foo in global parameters', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in global parameters', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line + }, +} as const; -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, +export const $DeprecatedModel = { + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', + properties: { + prop: { + deprecated: true, + description: 'This is a deprecated property', + type: 'string', }, - '/api/v{api-version}/parameters/deprecated': { - post: { - tags: ['Deprecated'], - deprecated: true, - operationId: 'DeprecatedCall', - parameters: [ - { - deprecated: true, - description: 'This parameter is deprecated', - name: 'parameter', - in: 'header', - required: true, - nullable: true, - schema: { - $ref: '#/components/schemas/DeprecatedModel', - }, - }, - ], - }, + }, +} as const; + +export const $ModelWithCircularReference = { + description: 'This is a model with one property containing a circular reference', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithCircularReference', }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - required: false, - schema: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - name: 'foo_ref_enum', - in: 'query', - }, - { - required: true, - schema: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - name: 'foo_all_of_enum', - in: 'query', - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'parameterCookie', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, + }, +} as const; + +export const $CompositionWithOneOf = { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + $ref: '#/components/schemas/ModelWithString', }, - }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'PARAMETER-COOKIE', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { + }, +} as const; + +export const $CompositionWithOneOfAnonymous = { + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + oneOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { type: 'string', }, }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, }, - }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], }, - '/api/v{api-version}/parameters/': { - get: { - tags: ['Parameters'], - operationId: 'GetCallWithOptionalParam', - parameters: [ - { - description: 'This is an optional parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { + }, +} as const; + +export const $ModelCircle = { + description: 'Circle', + type: 'object', + required: ['kind'], + properties: { + kind: { + type: 'string', + }, + radius: { + type: 'number', + }, + }, +} as const; + +export const $ModelSquare = { + description: 'Square', + type: 'object', + required: ['kind'], + properties: { + kind: { + type: 'string', + }, + sideLength: { + type: 'number', + }, + }, +} as const; + +export const $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', + }, + }, +} as const; + +export const $CompositionWithAnyOf = { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, +} as const; + +export const $CompositionWithAnyOfAnonymous = { + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + description: 'Anonymous object type', + type: 'object', + properties: { + propA: { type: 'string', }, }, - ], - requestBody: { - description: 'This is a required parameter', - required: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithOneOfEnum', + }, + { + description: 'Anonymous string type', + type: 'string', + }, + { + description: 'Anonymous integer type', + type: 'integer', + }, + ], + }, + }, +} as const; + +export const $CompositionWithNestedAnyAndTypeNull = { + description: "This is a model with nested 'any of' property with a type null", + type: 'object', + properties: { + propA: { + type: 'object', + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithDictionary', }, - }, + { + type: 'null', + }, + ], }, + type: 'array', }, - }, - post: { - tags: ['Parameters'], - operationId: 'PostCallWithOptionalParam', - parameters: [ - { - description: 'This is a required parameter', - name: 'parameter', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/Pageable', - }, - }, - ], - requestBody: { - description: 'This is an optional parameter', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/ModelWithArray', }, - }, + { + type: 'null', + }, + ], }, + type: 'array', }, - }, + ], }, - '/api/v{api-version}/requestBody/': { - post: { - tags: ['RequestBody'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', + }, +} as const; + +export const $Enum1 = { + enum: ['Bird', 'Dog'], + type: 'string', +} as const; + +export const $ConstValue = { + type: 'string', + const: 'ConstValue', +} as const; + +export const $CompositionWithNestedAnyOfAndNull = { + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', + properties: { + propA: { + anyOf: [ + { + items: { + anyOf: [ + { + $ref: '#/components/schemas/Enum1', + }, + { + $ref: '#/components/schemas/ConstValue', + }, + ], }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleRequestBody', + type: 'array', }, - }, + { + type: 'null', + }, + ], + title: 'Scopes', }, - '/api/v{api-version}/formData/': { - post: { - tags: ['FormData'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', + }, +} as const; + +export const $CompositionWithOneOfAndNullable = { + description: "This is a model with one property with a 'one of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + oneOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', + }, }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleFormData', }, - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - nullable: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - nullable: true, - schema: { - type: 'number', - default: 123, - }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, +} as const; + +export const $CompositionWithOneOfAndSimpleDictionary = { + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'number', }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - nullable: true, - schema: { + }, + ], + }, + }, +} as const; + +export const $CompositionWithOneOfAndSimpleArrayDictionary = { + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - nullable: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, }, }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - required: false, - schema: { - type: 'number', - default: 123, + }, + ], + }, + }, +} as const; + +export const $CompositionWithOneOfAndComplexArrayDictionary = { + description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', + properties: { + propA: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'object', + additionalProperties: { + type: 'array', + items: { + oneOf: [ + { + type: 'number', + }, + { + type: 'string', + }, + ], }, }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - required: false, - schema: { + }, + ], + }, + }, +} as const; + +export const $CompositionWithAllOfAndNullable = { + description: "This is a model with one property with a 'all of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + allOf: [ + { + type: 'object', + properties: { + boolean: { type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - required: false, - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - required: false, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - schema: { - type: 'string', }, }, - { - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, +} as const; + +export const $CompositionWithAnyOfAndNullable = { + description: "This is a model with one property with a 'any of' relationship", + type: 'object', + properties: { + propA: { + nullable: true, + type: 'object', + anyOf: [ + { + type: 'object', + properties: { + boolean: { + type: 'boolean', }, }, - { - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - schema: { + }, + { + $ref: '#/components/schemas/ModelWithEnum', + }, + { + $ref: '#/components/schemas/ModelWithArray', + }, + { + $ref: '#/components/schemas/ModelWithDictionary', + }, + ], + }, + }, +} as const; + +export const $CompositionBaseModel = { + description: 'This is a base model with two simple optional properties', + type: 'object', + properties: { + firstName: { + type: 'string', + }, + lastname: { + type: 'string', + }, + }, +} as const; + +export const $CompositionExtendedModel = { + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/CompositionBaseModel', + }, + ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], +} as const; + +export const $ModelWithProperties = { + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], + properties: { + required: { + type: 'string', + }, + requiredAndReadOnly: { + type: 'string', + readOnly: true, + }, + requiredAndNullable: { + type: 'string', + nullable: true, + }, + string: { + type: 'string', + }, + number: { + type: 'number', + }, + boolean: { + type: 'boolean', + }, + reference: { + $ref: '#/components/schemas/ModelWithString', + }, + 'property with space': { + type: 'string', + }, + default: { + type: 'string', + }, + try: { + type: 'string', + }, + '@namespace.string': { + type: 'string', + readOnly: true, + }, + '@namespace.integer': { + type: 'integer', + readOnly: true, + }, + }, +} as const; + +export const $ModelWithNestedProperties = { + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], + properties: { + first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, + properties: { + second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, + properties: { + third: { type: 'string', + required: true, + readOnly: true, nullable: true, - default: null, }, }, - ], + }, }, }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, + }, +} as const; + +export const $ModelWithDuplicateProperties = { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + $ref: '#/components/schemas/ModelWithString', }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, + }, +} as const; + +export const $ModelWithOrderedProperties = { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string', }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, + apple: { + type: 'string', + }, + hawaii: { + type: 'string', + }, + }, +} as const; + +export const $ModelWithDuplicateImports = { + description: 'This is a model with duplicated imports', + type: 'object', + properties: { + propA: { + $ref: '#/components/schemas/ModelWithString', + }, + propB: { + $ref: '#/components/schemas/ModelWithString', + }, + propC: { + $ref: '#/components/schemas/ModelWithString', + }, + }, +} as const; + +export const $ModelThatExtends = { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + type: 'object', + properties: { + propExtendsA: { + type: 'string', + }, + propExtendsB: { + $ref: '#/components/schemas/ModelWithString', }, }, }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, + ], +} as const; + +export const $ModelThatExtendsExtends = { + description: 'This is a model that extends another model', + type: 'object', + allOf: [ + { + $ref: '#/components/schemas/ModelWithString', + }, + { + $ref: '#/components/schemas/ModelThatExtends', + }, + { + type: 'object', + properties: { + propExtendsC: { + type: 'string', + }, + propExtendsD: { + $ref: '#/components/schemas/ModelWithString', }, }, }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, + ], +} as const; + +export const $ModelWithPattern = { + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], + properties: { + key: { + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - content: { - 'application/json': { - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtends', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtendsExtends', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, + name: { + maxLength: 255, + type: 'string', }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'multi', - }, - ], - }, + enabled: { + type: 'boolean', + readOnly: true, }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'default', - nullable: true, - }, - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - schema: { - type: 'boolean', - default: true, - nullable: true, - }, - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - default: null, - nullable: true, - }, - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - schema: { - type: 'object', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - nullable: true, - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 201: { - description: 'Response is a simple string', - content: { - 'application/json': { - schema: { - type: 'string', - }, - }, - }, - }, - 202: { - description: 'Response is a simple boolean', - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - 203: { - description: 'Response is a simple object', - content: { - 'application/json': { - schema: { - type: 'object', - }, - }, - }, - }, - }, - }, + modified: { + type: 'string', + format: 'date-time', + readOnly: true, }, - '/api/v{api-version}/upload': { - post: { - tags: ['Upload'], - operationId: 'UploadFile', - parameters: [ - { - description: 'Supply a file reference for upload', - name: 'file', - in: 'formData', - required: true, - schema: { - type: 'file', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - nullable: true, - }, - }, - ], - responses: { - 200: { - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - }, - }, + id: { + type: 'string', + pattern: '^d{2}-d{3}-d{4}$', }, - '/api/v{api-version}/file/{id}': { - get: { - tags: ['FileResponse'], - operationId: 'FileResponse', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - responses: { - 200: { - description: 'Success', - content: { - 'audio/*': { - schema: { - type: 'file', - }, - }, - 'video/*': { - schema: { - type: 'file', - }, - }, - }, - }, - }, - }, + text: { + type: 'string', + pattern: '^w+$', }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, + patternWithSingleQuotes: { + type: 'string', + pattern: "^[a-zA-Z0-9']*$", }, - '/api/v{api-version}/multipart': { - post: { - tags: ['multipart'], - operationId: 'MultipartRequest', - requestBody: { - content: { - 'multipart/form-data': { - schema: { - type: 'object', - properties: { - content: { - type: 'string', - format: 'binary', - }, - data: { - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - ], - nullable: true, - }, - }, - }, - encoding: { - content: { - style: 'form', - }, - data: { - style: 'form', - }, - }, - }, - }, - }, - }, - get: { - tags: ['multipart'], - operationId: 'MultipartResponse', - responses: { - 200: { - description: 'OK', - content: { - 'multipart/mixed': { - schema: { - type: 'object', - properties: { - file: { - type: 'string', - format: 'binary', - }, - metadata: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, + patternWithNewline: { + type: 'string', + pattern: `aaa +bbb`, }, - '/api/v{api-version}/complex/{id}': { - put: { - tags: ['Complex'], - operationId: 'ComplexParams', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'integer', - format: 'int32', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - content: { - 'application/json-patch+json': { - schema: { - required: ['key', 'name', 'parameters', 'type'], - type: 'object', - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - nullable: true, - readOnly: true, - }, - name: { - maxLength: 255, - type: 'string', - nullable: true, - }, - enabled: { - type: 'boolean', - default: true, - }, - type: { - enum: ['Monkey', 'Horse', 'Bird'], - type: 'string', - readOnly: true, - }, - listOfModels: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - nullable: true, - }, - listOfStrings: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - parameters: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - user: { - type: 'object', - properties: { - id: { - type: 'integer', - format: 'int32', - readOnly: true, - }, - name: { - type: 'string', - nullable: true, - readOnly: true, - }, - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - responses: { - 200: { - description: 'Success', - content: { - 'application/json; type=collection': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa`bbb', }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - schema: { - type: 'string', - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, + }, +} as const; + +export const $File = { + required: ['mime'], + type: 'object', + properties: { + id: { + title: 'Id', + type: 'string', + readOnly: true, + minLength: 1, }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, + updated_at: { + title: 'Updated at', + type: 'string', + format: 'date-time', + readOnly: true, }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - }, + created_at: { + title: 'Created at', + type: 'string', + format: 'date-time', + readOnly: true, }, - }, - components: { - requestBodies: { - SimpleRequestBody: { - 'x-body-name': 'foo', - description: 'A reusable request body', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - SimpleFormData: { - description: 'A reusable request body', - required: false, - content: { - 'multipart/form-data': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, + mime: { + title: 'Mime', + type: 'string', + maxLength: 24, + minLength: 1, }, - parameters: { - SimpleParameter: { - description: 'This is a reusable parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, + file: { + title: 'File', + type: 'string', + readOnly: true, + format: 'uri', }, - schemas: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line + }, +} as const; -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/components/schemas/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - nullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: [ - 'Success', - 'Warning', - 'Error', - "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串', - ], - }, - EnumWithReplacedCharacters: { - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], - type: 'string', - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - default: 200, - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - default: ['test'], - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ArrayWithAnyOfProperties: { - description: 'This is a simple array with any of properties', - type: 'array', - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - default: 'test', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - }, - AnyOfAnyAndNull: { - type: 'object', - properties: { - data: { - anyOf: [ - {}, - { - type: 'null', - }, - ], - }, - }, - }, - AnyOfArrays: { - description: 'This is a simple array with any of properties', - type: 'object', - properties: { - results: { - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - type: 'array', - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp1', 'nullableRequiredProp2'], - properties: { - nullableProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableRequiredProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - nullableRequiredProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumWithHyphen: { - description: 'This is a model with one enum with escaped name', - type: 'object', - properties: { - 'foo-bar-baz-qux': { - type: 'string', - enum: ['3.0'], - title: 'Foo-Bar-Baz-Qux', - default: '3.0', - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithProperties', - }, - }, - }, - ModelWithArrayReadOnlyAndWriteOnly: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - DeprecatedModel: { - deprecated: true, - description: 'This is a deprecated model with a deprecated property', - type: 'object', - properties: { - prop: { - deprecated: true, - description: 'This is a deprecated property', - type: 'string', - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithCircularReference', - }, - }, - }, - CompositionWithOneOf: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAnonymous: { - description: - "This is a model with one property with a 'one of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - 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', - properties: { - propA: { - type: 'object', - anyOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAnonymous: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - CompositionWithNestedAnyAndTypeNull: { - description: "This is a model with nested 'any of' property with a type null", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - ], - }, - }, - }, - Enum1: { - enum: ['Bird', 'Dog'], - type: 'string', - }, - ConstValue: { - type: 'string', - const: 'ConstValue', - }, - CompositionWithNestedAnyOfAndNull: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/Enum1', - }, - { - $ref: '#/components/schemas/ConstValue', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Scopes', - }, - }, - }, - CompositionWithOneOfAndNullable: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - oneOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleDictionary: { - description: 'This is a model that contains a simple dictionary within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'number', - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleArrayDictionary: { - description: 'This is a model that contains a dictionary of simple arrays within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - type: 'boolean', - }, - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndComplexArrayDictionary: { - description: - 'This is a model that contains a dictionary of complex arrays (composited) within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ], - }, - }, - }, - ], - }, - }, - }, - CompositionWithAllOfAndNullable: { - description: "This is a model with one property with a 'all of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - allOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAndNullable: { - description: "This is a model with one property with a 'any of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionBaseModel: { - description: 'This is a base model with two simple optional properties', - type: 'object', - properties: { - firstName: { - type: 'string', - }, - lastname: { - type: 'string', - }, - }, - }, - CompositionExtendedModel: { - description: 'This is a model that extends the base model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/CompositionBaseModel', - }, - ], - properties: { - age: { - type: 'number', - }, - }, - required: ['firstName', 'lastname', 'age'], - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - requiredAndNullable: { - type: 'string', - nullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/components/schemas/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - nullable: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - nullable: true, - properties: { - third: { - type: 'string', - required: true, - readOnly: true, - nullable: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/components/schemas/ModelWithString', - }, - propB: { - $ref: '#/components/schemas/ModelWithString', - }, - propC: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - File: { - required: ['mime'], - type: 'object', - properties: { - id: { - title: 'Id', - type: 'string', - readOnly: true, - minLength: 1, - }, - updated_at: { - title: 'Updated at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - created_at: { - title: 'Created at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - mime: { - title: 'Mime', - type: 'string', - maxLength: 24, - minLength: 1, - }, - file: { - title: 'File', - type: 'string', - readOnly: true, - format: 'uri', - }, - }, - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - Pageable: { - type: 'object', - properties: { - page: { - minimum: 0, - type: 'integer', - format: 'int32', - default: 0, - }, - size: { - minimum: 1, - type: 'integer', - format: 'int32', - }, - sort: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - FreeFormObjectWithoutAdditionalProperties: { - description: 'This is a free-form object without additionalProperties.', - type: 'object', - }, - FreeFormObjectWithAdditionalPropertiesEqTrue: { - description: 'This is a free-form object with additionalProperties: true.', - type: 'object', - additionalProperties: true, - }, - FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { - description: 'This is a free-form object with additionalProperties: {}.', - type: 'object', - additionalProperties: {}, - }, - ModelWithConst: { - type: 'object', - properties: { - String: { - const: 'String', - }, - number: { - const: 0, - }, - null: { - const: null, - }, - withType: { - type: 'string', - const: 'Some string', - }, - }, - }, - ModelWithAdditionalPropertiesEqTrue: { - description: 'This is a model with one property and additionalProperties: true', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - additionalProperties: true, +export const $default = { + type: 'object', + properties: { + name: { + type: 'string', + }, + }, +} as const; + +export const $Pageable = { + type: 'object', + properties: { + page: { + minimum: 0, + type: 'integer', + format: 'int32', + default: 0, + }, + size: { + minimum: 1, + type: 'integer', + format: 'int32', + }, + sort: { + type: 'array', + items: { + type: 'string', }, - NestedAnyOfArraysNullable: { - properties: { - nullableArray: { + }, + }, +} as const; + +export const $FreeFormObjectWithoutAdditionalProperties = { + description: 'This is a free-form object without additionalProperties.', + type: 'object', +} as const; + +export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, +} as const; + +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, +} as const; + +export const $ModelWithConst = { + type: 'object', + properties: { + String: { + const: 'String', + }, + number: { + const: 0, + }, + null: { + const: null, + }, + withType: { + type: 'string', + const: 'Some string', + }, + }, +} as const; + +export const $ModelWithAdditionalPropertiesEqTrue = { + description: 'This is a model with one property and additionalProperties: true', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string', + }, + }, + additionalProperties: true, +} as const; + +export const $NestedAnyOfArraysNullable = { + properties: { + nullableArray: { + anyOf: [ + { + items: { anyOf: [ { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - type: 'array', + type: 'string', }, { - type: 'null', + type: 'boolean', }, ], }, + type: 'array', }, - type: 'object', - }, - CompositionWithOneOfAndProperties: { - type: 'object', - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - $ref: '#/components/parameters/SimpleParameter', - }, - }, - additionalProperties: false, - }, - { - type: 'object', - required: ['bar'], - properties: { - bar: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - additionalProperties: false, - }, - ], - required: ['baz', 'qux'], - properties: { - baz: { - type: 'integer', - format: 'uint16', - minimum: 0, - nullable: true, - }, - qux: { - type: 'integer', - format: 'uint8', - minimum: 0, - }, + { + type: 'null', }, - }, - NullableObject: { - type: 'object', - nullable: true, - description: 'An object that can be null', - properties: { - foo: { - type: 'string', - }, + ], + }, + }, + type: 'object', +} as const; + +export const $CompositionWithOneOfAndProperties = { + type: 'object', + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + $ref: '#/components/parameters/SimpleParameter', }, - default: null, }, - ModelWithNullableObject: { - type: 'object', - properties: { - data: { - $ref: '#/components/schemas/NullableObject', - }, + additionalProperties: false, + }, + { + type: 'object', + required: ['bar'], + properties: { + bar: { + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', }, }, - ModelWithOneOfEnum: { - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Bar'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Baz'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Qux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'string', - format: 'date-time', - }, - foo: { - type: 'string', - enum: ['Quux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'array', - items: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - maxItems: 2, - minItems: 2, - }, - foo: { - type: 'string', - enum: ['Corge'], - }, - }, - }, - ], + additionalProperties: false, + }, + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, +} as const; + +export const $NullableObject = { + type: 'object', + nullable: true, + description: 'An object that can be null', + properties: { + foo: { + type: 'string', + }, + }, + default: null, +} as const; + +export const $ModelWithNullableObject = { + type: 'object', + properties: { + data: { + $ref: '#/components/schemas/NullableObject', + }, + }, +} as const; + +export const $ModelWithOneOfEnum = { + oneOf: [ + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Bar'], + }, }, - ModelWithNestedArrayEnumsDataFoo: { - enum: ['foo', 'bar'], - type: 'string', + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Baz'], + }, }, - ModelWithNestedArrayEnumsDataBar: { - enum: ['baz', 'qux'], - type: 'string', + }, + { + type: 'object', + required: ['foo'], + properties: { + foo: { + type: 'string', + enum: ['Qux'], + }, }, - ModelWithNestedArrayEnumsData: { - type: 'object', - properties: { - foo: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - }, - bar: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', - }, - }, + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'string', + format: 'date-time', + }, + foo: { + type: 'string', + enum: ['Quux'], }, }, - ModelWithNestedArrayEnums: { - type: 'object', - properties: { - array_strings: { - type: 'array', - items: { + }, + { + type: 'object', + required: ['content', 'foo'], + properties: { + content: { + type: 'array', + items: [ + { type: 'string', + format: 'date-time', }, - }, - data: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', - }, - ], - }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, }, - }, - ModelWithNestedCompositionEnums: { - type: 'object', - properties: { - foo: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, + foo: { + type: 'string', + enum: ['Corge'], }, }, - ModelWithReadOnlyAndWriteOnly: { - type: 'object', - required: ['foo', 'bar', 'baz'], - properties: { - foo: { - type: 'string', - }, - bar: { - readOnly: true, - type: 'string', - }, - baz: { - type: 'string', - writeOnly: true, - }, - }, + }, + ], +} as const; + +export const $ModelWithNestedArrayEnumsDataFoo = { + enum: ['foo', 'bar'], + type: 'string', +} as const; + +export const $ModelWithNestedArrayEnumsDataBar = { + enum: ['baz', 'qux'], + type: 'string', +} as const; + +export const $ModelWithNestedArrayEnumsData = { + type: 'object', + properties: { + foo: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + }, + bar: { + type: 'array', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', }, }, }, } as const; + +export const $ModelWithNestedArrayEnums = { + type: 'object', + properties: { + array_strings: { + type: 'array', + items: { + type: 'string', + }, + }, + data: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', + }, + ], + }, + }, +} as const; + +export const $ModelWithNestedCompositionEnums = { + type: 'object', + properties: { + foo: { + allOf: [ + { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', + }, + ], + }, + }, +} as const; + +export const $ModelWithReadOnlyAndWriteOnly = { + type: 'object', + required: ['foo', 'bar', 'baz'], + properties: { + foo: { + type: 'string', + }, + bar: { + readOnly: true, + type: 'string', + }, + baz: { + type: 'string', + writeOnly: true, + }, + }, +} as const; + +export const $SimpleParameter = { + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', + }, +} as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap index f7f419e44..d4f2992e7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap @@ -1,142 +1,155 @@ export const $CommentWithBreaks = { - type: 'number', description: `Testing multiline comments in string: First line Second line Fourth line`, + type: 'integer', } as const; export const $CommentWithBackticks = { - type: 'number', - description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', } as const; export const $CommentWithSlashes = { - type: 'number', - description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', } as const; export const $CommentWithExpressionPlaceholders = { - type: 'number', - description: `Testing expression placeholders in string: \${expression} should work`, + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', } as const; export const $CommentWithQuotes = { - type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', } as const; export const $CommentWithReservedCharacters = { - type: 'number', - description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', } as const; export const $SimpleInteger = { - type: 'number', - description: `This is a simple number`, + description: 'This is a simple number', + type: 'integer', } as const; export const $SimpleBoolean = { + description: 'This is a simple boolean', type: 'boolean', - description: `This is a simple boolean`, } as const; export const $SimpleString = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, } as const; export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string', - description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; export const $SimpleFile = { - type: 'binary', - description: `This is a simple file`, + description: 'This is a simple file', + type: 'file', } as const; export const $SimpleReference = { - type: 'ModelWithString', - description: `This is a simple reference`, + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', } as const; export const $SimpleStringWithPattern = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, - isNullable: true, + nullable: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', } as const; export const $EnumWithStrings = { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; export const $EnumWithReplacedCharacters = { - type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', } as const; export const $EnumWithNumbers = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], default: 200, } as const; export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', type: 'number', - description: `Success=1,Warning=2,Error=3`, } as const; export const $EnumWithExtensions = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], } as const; export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', type: 'array', - contains: { - type: 'number', + items: { + type: 'integer', }, } as const; export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', type: 'array', - contains: { + items: { type: 'boolean', }, } as const; export const $ArrayWithStrings = { + description: 'This is a simple array with strings', type: 'array', - contains: { + items: { type: 'string', }, default: ['test'], } as const; export const $ArrayWithReferences = { + description: 'This is a simple array with references', type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $ArrayWithArray = { + description: 'This is a simple array containing an array', type: 'array', - contains: { + items: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ArrayWithProperties = { + description: 'This is a simple array with properties', type: 'array', - contains: { + items: { + type: 'object', properties: { foo: { type: 'string', @@ -149,11 +162,12 @@ export const $ArrayWithProperties = { } as const; export const $ArrayWithAnyOfProperties = { + description: 'This is a simple array with any of properties', type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -162,6 +176,7 @@ export const $ArrayWithAnyOfProperties = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -173,13 +188,11 @@ export const $ArrayWithAnyOfProperties = { } as const; export const $AnyOfAnyAndNull = { + type: 'object', properties: { data: { - type: 'any-of', - contains: [ - { - properties: {}, - }, + anyOf: [ + {}, { type: 'null', }, @@ -189,14 +202,14 @@ export const $AnyOfAnyAndNull = { } as const; export const $AnyOfArrays = { - description: `This is a simple array with any of properties`, + description: 'This is a simple array with any of properties', + type: 'object', properties: { results: { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -204,6 +217,7 @@ export const $AnyOfArrays = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -212,47 +226,54 @@ export const $AnyOfArrays = { }, ], }, + type: 'array', }, }, } as const; export const $DictionaryWithString = { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { type: 'string', }, } as const; export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $DictionaryWithArray = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', }, }, } as const; export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', properties: { foo: { type: 'string', @@ -265,171 +286,178 @@ export const $DictionaryWithProperties = { } as const; export const $ModelWithInteger = { - description: `This is a model with one number property`, + description: 'This is a model with one number property', + type: 'object', properties: { prop: { - type: 'number', - description: `This is a simple number property`, + description: 'This is a simple number property', + type: 'integer', }, }, } as const; export const $ModelWithBoolean = { - description: `This is a model with one boolean property`, + description: 'This is a model with one boolean property', + type: 'object', properties: { prop: { + description: 'This is a simple boolean property', type: 'boolean', - description: `This is a simple boolean property`, }, }, } as const; export const $ModelWithString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, } as const; export const $ModelWithNullableString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], properties: { nullableProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isNullable: true, + nullable: true, }, nullableRequiredProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + nullable: true, }, nullableProp2: { - type: 'string', - description: `This is a simple string property`, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, nullableRequiredProp2: { - type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithEnum = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, statusCode: { - type: 'Enum', + description: 'These are the HTTP error code enums', enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], }, bool: { + description: 'Simple boolean enum', type: 'boolean', - description: `Simple boolean enum`, + enum: [true], }, }, } as const; export const $ModelWithEnumWithHyphen = { - description: `This is a model with one enum with escaped name`, + description: 'This is a model with one enum with escaped name', + type: 'object', properties: { 'foo-bar-baz-qux': { - type: 'Enum', + type: 'string', enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', default: '3.0', }, }, } as const; export const $ModelWithEnumFromDescription = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, } as const; export const $ModelWithNestedEnums = { - description: `This is a model with nested enums`, + description: 'This is a model with nested enums', + type: 'object', properties: { dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', + type: 'object', + additionalProperties: { enum: ['Success', 'Warning', 'Error'], }, }, dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, arrayWithEnum: { type: 'array', - contains: { - type: 'Enum', + items: { enum: ['Success', 'Warning', 'Error'], }, }, arrayWithDescription: { type: 'array', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithReference = { - description: `This is a model with one property containing a reference`, + description: 'This is a model with one property containing a reference', + type: 'object', properties: { prop: { - type: 'ModelWithProperties', + $ref: '#/components/schemas/ModelWithProperties', }, }, } as const; export const $ModelWithArrayReadOnlyAndWriteOnly = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithReadOnlyAndWriteOnly', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -437,23 +465,24 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } as const; export const $ModelWithArray = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -461,11 +490,12 @@ export const $ModelWithArray = { } as const; export const $ModelWithDictionary = { - description: `This is a model with one property containing a dictionary`, + description: 'This is a model with one property containing a dictionary', + type: 'object', properties: { prop: { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'string', }, }, @@ -473,41 +503,46 @@ export const $ModelWithDictionary = { } as const; export const $DeprecatedModel = { - description: `This is a deprecated model with a deprecated property`, + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', properties: { prop: { + deprecated: true, + description: 'This is a deprecated property', type: 'string', - description: `This is a deprecated property`, }, }, } as const; export const $ModelWithCircularReference = { - description: `This is a model with one property containing a circular reference`, + description: 'This is a model with one property containing a circular reference', + type: 'object', properties: { prop: { - type: 'ModelWithCircularReference', + $ref: '#/components/schemas/ModelWithCircularReference', }, }, } as const; export const $CompositionWithOneOf = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -515,13 +550,15 @@ export const $CompositionWithOneOf = { } as const; export const $CompositionWithOneOfAnonymous = { - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -529,12 +566,12 @@ export const $CompositionWithOneOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -542,11 +579,12 @@ export const $CompositionWithOneOfAnonymous = { } as const; export const $ModelCircle = { - description: `Circle`, + description: 'Circle', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, radius: { type: 'number', @@ -555,11 +593,12 @@ export const $ModelCircle = { } as const; export const $ModelSquare = { - description: `Square`, + description: 'Square', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, sideLength: { type: 'number', @@ -568,35 +607,43 @@ export const $ModelSquare = { } as const; export const $CompositionWithOneOfDiscriminator = { - type: 'one-of', - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, - contains: [ + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + oneOf: [ { - type: 'ModelCircle', + $ref: '#/components/schemas/ModelCircle', }, { - type: 'ModelSquare', + $ref: '#/components/schemas/ModelSquare', }, ], + discriminator: { + propertyName: 'kind', + mapping: { + circle: '#/components/schemas/ModelCircle', + square: '#/components/schemas/ModelSquare', + }, + }, } as const; export const $CompositionWithAnyOf = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -604,13 +651,15 @@ export const $CompositionWithAnyOf = { } as const; export const $CompositionWithAnyOfAnonymous = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -618,12 +667,12 @@ export const $CompositionWithAnyOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -631,38 +680,37 @@ export const $CompositionWithAnyOfAnonymous = { } as const; export const $CompositionWithNestedAnyAndTypeNull = { - description: `This is a model with nested 'any of' property with a type null`, + description: "This is a model with nested 'any of' property with a type null", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, { type: 'null', }, ], }, + type: 'array', }, { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { type: 'null', }, ], }, + type: 'array', }, ], }, @@ -670,49 +718,53 @@ export const $CompositionWithNestedAnyAndTypeNull = { } as const; export const $Enum1 = { - type: 'Enum', enum: ['Bird', 'Dog'], + type: 'string', } as const; export const $ConstValue = { - type: '"ConstValue"', + type: 'string', + const: 'ConstValue', } as const; export const $CompositionWithNestedAnyOfAndNull = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'Enum1', + $ref: '#/components/schemas/Enum1', }, { - type: 'ConstValue', + $ref: '#/components/schemas/ConstValue', }, ], }, + type: 'array', }, { type: 'null', }, ], + title: 'Scopes', }, }, } as const; export const $CompositionWithOneOfAndNullable = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + nullable: true, + type: 'object', + oneOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -720,32 +772,31 @@ export const $CompositionWithOneOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithOneOfAndSimpleDictionary = { - description: `This is a model that contains a simple dictionary within composition`, + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'number', }, }, @@ -755,19 +806,19 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } as const; export const $CompositionWithOneOfAndSimpleArrayDictionary = { - description: `This is a model that contains a dictionary of simple arrays within composition`, + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { + items: { type: 'boolean', }, }, @@ -778,21 +829,20 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } as const; export const $CompositionWithOneOfAndComplexArrayDictionary = { - description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, + description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'one-of', - contains: [ + items: { + oneOf: [ { type: 'number', }, @@ -809,12 +859,15 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } as const; export const $CompositionWithAllOfAndNullable = { - description: `This is a model with one property with a 'all of' relationship`, + description: "This is a model with one property with a 'all of' relationship", + type: 'object', properties: { propA: { - type: 'all-of', - contains: [ + nullable: true, + type: 'object', + allOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -822,27 +875,29 @@ export const $CompositionWithAllOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithAnyOfAndNullable = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + nullable: true, + type: 'object', + anyOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -850,22 +905,22 @@ export const $CompositionWithAnyOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionBaseModel = { - description: `This is a base model with two simple optional properties`, + description: 'This is a base model with two simple optional properties', + type: 'object', properties: { firstName: { type: 'string', @@ -877,47 +932,36 @@ export const $CompositionBaseModel = { } as const; export const $CompositionExtendedModel = { - type: 'all-of', - description: `This is a model that extends the base model`, - contains: [ - { - type: 'CompositionBaseModel', - }, + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ { - properties: { - firstName: { - type: 'string', - isRequired: true, - }, - lastname: { - type: 'string', - isRequired: true, - }, - age: { - type: 'number', - isRequired: true, - }, - }, + $ref: '#/components/schemas/CompositionBaseModel', }, ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], } as const; export const $ModelWithProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], properties: { required: { type: 'string', - isRequired: true, }, requiredAndReadOnly: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, requiredAndNullable: { type: 'string', - isRequired: true, - isNullable: true, + nullable: true, }, string: { type: 'string', @@ -929,7 +973,7 @@ export const $ModelWithProperties = { type: 'boolean', }, reference: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, 'property with space': { type: 'string', @@ -942,52 +986,58 @@ export const $ModelWithProperties = { }, '@namespace.string': { type: 'string', - isReadOnly: true, + readOnly: true, }, '@namespace.integer': { - type: 'number', - isReadOnly: true, + type: 'integer', + readOnly: true, }, }, } as const; export const $ModelWithNestedProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], properties: { first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, properties: { second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, properties: { third: { type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + required: true, + readOnly: true, + nullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, } as const; export const $ModelWithDuplicateProperties = { - description: `This is a model with duplicated properties`, + description: 'This is a model with duplicated properties', + type: 'object', properties: { prop: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelWithOrderedProperties = { - description: `This is a model with ordered properties`, + description: 'This is a model with ordered properties', + type: 'object', properties: { zebra: { type: 'string', @@ -1002,34 +1052,36 @@ export const $ModelWithOrderedProperties = { } as const; export const $ModelWithDuplicateImports = { - description: `This is a model with duplicated imports`, + description: 'This is a model with duplicated imports', + type: 'object', properties: { propA: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propC: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelThatExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { + type: 'object', properties: { propExtendsA: { type: 'string', }, propExtendsB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1037,22 +1089,23 @@ export const $ModelThatExtends = { } as const; export const $ModelThatExtendsExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelThatExtends', + $ref: '#/components/schemas/ModelThatExtends', }, { + type: 'object', properties: { propExtendsC: { type: 'string', }, propExtendsD: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1060,35 +1113,35 @@ export const $ModelThatExtendsExtends = { } as const; export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], properties: { key: { - type: 'string', - isRequired: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, name: { - type: 'string', - isRequired: true, maxLength: 255, + type: 'string', }, enabled: { type: 'boolean', - isReadOnly: true, + readOnly: true, }, modified: { type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, id: { type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + pattern: '^d{2}-d{3}-d{4}$', }, text: { type: 'string', - pattern: '^\\w+$', + pattern: '^w+$', }, patternWithSingleQuotes: { type: 'string', @@ -1096,7 +1149,8 @@ export const $ModelWithPattern = { }, patternWithNewline: { type: 'string', - pattern: 'aaa\nbbb', + pattern: `aaa +bbb`, }, patternWithBacktick: { type: 'string', @@ -1106,37 +1160,44 @@ export const $ModelWithPattern = { } as const; export const $File = { + required: ['mime'], + type: 'object', properties: { id: { + title: 'Id', type: 'string', - isReadOnly: true, + readOnly: true, minLength: 1, }, updated_at: { + title: 'Updated at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, created_at: { + title: 'Created at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, mime: { + title: 'Mime', type: 'string', - isRequired: true, maxLength: 24, minLength: 1, }, file: { + title: 'File', type: 'string', - isReadOnly: true, + readOnly: true, format: 'uri', }, }, } as const; -export const $_default = { +export const $default = { + type: 'object', properties: { name: { type: 'string', @@ -1145,21 +1206,22 @@ export const $_default = { } as const; export const $Pageable = { + type: 'object', properties: { page: { - type: 'number', - default: 0, - format: 'int32', minimum: 0, + type: 'integer', + format: 'int32', + default: 0, }, size: { - type: 'number', - format: 'int32', minimum: 1, + type: 'integer', + format: 'int32', }, sort: { type: 'array', - contains: { + items: { type: 'string', }, }, @@ -1167,63 +1229,60 @@ export const $Pageable = { } as const; export const $FreeFormObjectWithoutAdditionalProperties = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object without additionalProperties.', + type: 'object', } as const; export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, } as const; export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, } as const; export const $ModelWithConst = { + type: 'object', properties: { String: { - type: '"String"', + const: 'String', }, number: { - type: '0', + const: 0, }, null: { - type: 'null', + const: null, }, withType: { - type: '"Some string"', + type: 'string', + const: 'Some string', }, }, } as const; export const $ModelWithAdditionalPropertiesEqTrue = { - description: `This is a model with one property and additionalProperties: true`, + description: 'This is a model with one property and additionalProperties: true', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, + additionalProperties: true, } as const; export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { type: 'string', }, @@ -1232,6 +1291,7 @@ export const $NestedAnyOfArraysNullable = { }, ], }, + type: 'array', }, { type: 'null', @@ -1239,141 +1299,137 @@ export const $NestedAnyOfArraysNullable = { ], }, }, + type: 'object', } as const; export const $CompositionWithOneOfAndProperties = { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'SimpleParameter', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/parameters/SimpleParameter', }, }, + additionalProperties: false, }, { + type: 'object', + required: ['bar'], properties: { bar: { - type: 'NonAsciiStringæøåÆØÅöôêÊ字符串', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', }, }, + additionalProperties: false, }, ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, } as const; export const $NullableObject = { - description: `An object that can be null`, + type: 'object', + nullable: true, + description: 'An object that can be null', properties: { foo: { type: 'string', }, }, default: null, - isNullable: true, } as const; export const $ModelWithNullableObject = { + type: 'object', properties: { data: { - type: 'NullableObject', + $ref: '#/components/schemas/NullableObject', }, }, } as const; export const $ModelWithOneOfEnum = { - type: 'one-of', - contains: [ + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Bar'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Baz'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Qux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'string', - isRequired: true, format: 'date-time', }, foo: { - type: 'Enum', + type: 'string', enum: ['Quux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'array', - contains: { - type: 'any-of', - contains: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - }, - isRequired: true, + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, }, foo: { - type: 'Enum', + type: 'string', enum: ['Corge'], - isRequired: true, }, }, }, @@ -1381,45 +1437,46 @@ export const $ModelWithOneOfEnum = { } as const; export const $ModelWithNestedArrayEnumsDataFoo = { - type: 'Enum', enum: ['foo', 'bar'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsDataBar = { - type: 'Enum', enum: ['baz', 'qux'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsData = { + type: 'object', properties: { foo: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataFoo', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, }, bar: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataBar', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', }, }, }, } as const; export const $ModelWithNestedArrayEnums = { + type: 'object', properties: { array_strings: { type: 'array', - contains: { + items: { type: 'string', }, }, data: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsData', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', }, ], }, @@ -1427,12 +1484,12 @@ export const $ModelWithNestedArrayEnums = { } as const; export const $ModelWithNestedCompositionEnums = { + type: 'object', properties: { foo: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsDataFoo', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, ], }, @@ -1440,3071 +1497,29 @@ export const $ModelWithNestedCompositionEnums = { } as const; export const $ModelWithReadOnlyAndWriteOnly = { + type: 'object', + required: ['foo', 'bar', 'baz'], properties: { foo: { type: 'string', - isRequired: true, }, bar: { + readOnly: true, type: 'string', - isReadOnly: true, - isRequired: true, }, baz: { type: 'string', - isRequired: true, + writeOnly: true, }, }, } as const; export const $SimpleParameter = { - type: 'string', - description: `This is a reusable parameter`, -} as const; - -export const $OpenApi = { - openapi: '3.0.0', - info: { - title: 'swagger', - version: 'v1.0', - }, - servers: [ - { - url: 'http://localhost:3000/base', - }, - ], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', - }, - post: { - operationId: 'PostServiceWithEmptyTag', - requestBody: { - required: true, - content: { - 'application/json': { - schema: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - { - $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', - }, - ], - }, - }, - }, - }, - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', - }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', - }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', - }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', - }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', - }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', - }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', - }, - }, - '/api/v{api-version}/foo/{foo}/bar/{bar}': { - delete: { - tags: ['Parameters'], - operationId: 'deleteFoo', - parameters: [ - { - description: 'foo in method', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in method', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - parameters: [ - { - description: 'foo in global parameters', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in global parameters', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, - }, - '/api/v{api-version}/parameters/deprecated': { - post: { - tags: ['Deprecated'], - deprecated: true, - operationId: 'DeprecatedCall', - parameters: [ - { - deprecated: true, - description: 'This parameter is deprecated', - name: 'parameter', - in: 'header', - required: true, - nullable: true, - schema: { - $ref: '#/components/schemas/DeprecatedModel', - }, - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - required: false, - schema: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - name: 'foo_ref_enum', - in: 'query', - }, - { - required: true, - schema: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - name: 'foo_all_of_enum', - in: 'query', - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'parameterCookie', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'PARAMETER-COOKIE', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/': { - get: { - tags: ['Parameters'], - operationId: 'GetCallWithOptionalParam', - parameters: [ - { - description: 'This is an optional parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is a required parameter', - required: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithOneOfEnum', - }, - }, - }, - }, - }, - post: { - tags: ['Parameters'], - operationId: 'PostCallWithOptionalParam', - parameters: [ - { - description: 'This is a required parameter', - name: 'parameter', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/Pageable', - }, - }, - ], - requestBody: { - description: 'This is an optional parameter', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/requestBody/': { - post: { - tags: ['RequestBody'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleRequestBody', - }, - }, - }, - '/api/v{api-version}/formData/': { - post: { - tags: ['FormData'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleFormData', - }, - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - nullable: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - nullable: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - nullable: true, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - nullable: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - required: false, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - required: false, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - required: false, - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - required: false, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - }, - }, - { - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - default: null, - }, - }, - ], - }, - }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - content: { - 'application/json': { - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtends', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtendsExtends', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'multi', - }, - ], - }, - }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'default', - nullable: true, - }, - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - schema: { - type: 'boolean', - default: true, - nullable: true, - }, - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - default: null, - nullable: true, - }, - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - schema: { - type: 'object', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - nullable: true, - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 201: { - description: 'Response is a simple string', - content: { - 'application/json': { - schema: { - type: 'string', - }, - }, - }, - }, - 202: { - description: 'Response is a simple boolean', - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - 203: { - description: 'Response is a simple object', - content: { - 'application/json': { - schema: { - type: 'object', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/upload': { - post: { - tags: ['Upload'], - operationId: 'UploadFile', - parameters: [ - { - description: 'Supply a file reference for upload', - name: 'file', - in: 'formData', - required: true, - schema: { - type: 'file', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - nullable: true, - }, - }, - ], - responses: { - 200: { - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/file/{id}': { - get: { - tags: ['FileResponse'], - operationId: 'FileResponse', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - responses: { - 200: { - description: 'Success', - content: { - 'audio/*': { - schema: { - type: 'file', - }, - }, - 'video/*': { - schema: { - type: 'file', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/multipart': { - post: { - tags: ['multipart'], - operationId: 'MultipartRequest', - requestBody: { - content: { - 'multipart/form-data': { - schema: { - type: 'object', - properties: { - content: { - type: 'string', - format: 'binary', - }, - data: { - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - ], - nullable: true, - }, - }, - }, - encoding: { - content: { - style: 'form', - }, - data: { - style: 'form', - }, - }, - }, - }, - }, - }, - get: { - tags: ['multipart'], - operationId: 'MultipartResponse', - responses: { - 200: { - description: 'OK', - content: { - 'multipart/mixed': { - schema: { - type: 'object', - properties: { - file: { - type: 'string', - format: 'binary', - }, - metadata: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex/{id}': { - put: { - tags: ['Complex'], - operationId: 'ComplexParams', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'integer', - format: 'int32', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - content: { - 'application/json-patch+json': { - schema: { - required: ['key', 'name', 'parameters', 'type'], - type: 'object', - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - nullable: true, - readOnly: true, - }, - name: { - maxLength: 255, - type: 'string', - nullable: true, - }, - enabled: { - type: 'boolean', - default: true, - }, - type: { - enum: ['Monkey', 'Horse', 'Bird'], - type: 'string', - readOnly: true, - }, - listOfModels: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - nullable: true, - }, - listOfStrings: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - parameters: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - user: { - type: 'object', - properties: { - id: { - type: 'integer', - format: 'int32', - readOnly: true, - }, - name: { - type: 'string', - nullable: true, - readOnly: true, - }, - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - responses: { - 200: { - description: 'Success', - content: { - 'application/json; type=collection': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - schema: { - type: 'string', - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, - }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - }, - }, - }, - components: { - requestBodies: { - SimpleRequestBody: { - 'x-body-name': 'foo', - description: 'A reusable request body', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - SimpleFormData: { - description: 'A reusable request body', - required: false, - content: { - 'multipart/form-data': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - parameters: { - SimpleParameter: { - description: 'This is a reusable parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - }, - schemas: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/components/schemas/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - nullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: [ - 'Success', - 'Warning', - 'Error', - "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串', - ], - }, - EnumWithReplacedCharacters: { - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], - type: 'string', - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - default: 200, - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - default: ['test'], - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ArrayWithAnyOfProperties: { - description: 'This is a simple array with any of properties', - type: 'array', - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - default: 'test', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - }, - AnyOfAnyAndNull: { - type: 'object', - properties: { - data: { - anyOf: [ - {}, - { - type: 'null', - }, - ], - }, - }, - }, - AnyOfArrays: { - description: 'This is a simple array with any of properties', - type: 'object', - properties: { - results: { - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - type: 'array', - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp1', 'nullableRequiredProp2'], - properties: { - nullableProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableRequiredProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - nullableRequiredProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumWithHyphen: { - description: 'This is a model with one enum with escaped name', - type: 'object', - properties: { - 'foo-bar-baz-qux': { - type: 'string', - enum: ['3.0'], - title: 'Foo-Bar-Baz-Qux', - default: '3.0', - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithProperties', - }, - }, - }, - ModelWithArrayReadOnlyAndWriteOnly: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - DeprecatedModel: { - deprecated: true, - description: 'This is a deprecated model with a deprecated property', - type: 'object', - properties: { - prop: { - deprecated: true, - description: 'This is a deprecated property', - type: 'string', - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithCircularReference', - }, - }, - }, - CompositionWithOneOf: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAnonymous: { - description: - "This is a model with one property with a 'one of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - 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', - properties: { - propA: { - type: 'object', - anyOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAnonymous: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - CompositionWithNestedAnyAndTypeNull: { - description: "This is a model with nested 'any of' property with a type null", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - ], - }, - }, - }, - Enum1: { - enum: ['Bird', 'Dog'], - type: 'string', - }, - ConstValue: { - type: 'string', - const: 'ConstValue', - }, - CompositionWithNestedAnyOfAndNull: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/Enum1', - }, - { - $ref: '#/components/schemas/ConstValue', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Scopes', - }, - }, - }, - CompositionWithOneOfAndNullable: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - oneOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleDictionary: { - description: 'This is a model that contains a simple dictionary within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'number', - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleArrayDictionary: { - description: 'This is a model that contains a dictionary of simple arrays within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - type: 'boolean', - }, - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndComplexArrayDictionary: { - description: - 'This is a model that contains a dictionary of complex arrays (composited) within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ], - }, - }, - }, - ], - }, - }, - }, - CompositionWithAllOfAndNullable: { - description: "This is a model with one property with a 'all of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - allOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAndNullable: { - description: "This is a model with one property with a 'any of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionBaseModel: { - description: 'This is a base model with two simple optional properties', - type: 'object', - properties: { - firstName: { - type: 'string', - }, - lastname: { - type: 'string', - }, - }, - }, - CompositionExtendedModel: { - description: 'This is a model that extends the base model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/CompositionBaseModel', - }, - ], - properties: { - age: { - type: 'number', - }, - }, - required: ['firstName', 'lastname', 'age'], - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - requiredAndNullable: { - type: 'string', - nullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/components/schemas/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - nullable: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - nullable: true, - properties: { - third: { - type: 'string', - required: true, - readOnly: true, - nullable: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/components/schemas/ModelWithString', - }, - propB: { - $ref: '#/components/schemas/ModelWithString', - }, - propC: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - File: { - required: ['mime'], - type: 'object', - properties: { - id: { - title: 'Id', - type: 'string', - readOnly: true, - minLength: 1, - }, - updated_at: { - title: 'Updated at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - created_at: { - title: 'Created at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - mime: { - title: 'Mime', - type: 'string', - maxLength: 24, - minLength: 1, - }, - file: { - title: 'File', - type: 'string', - readOnly: true, - format: 'uri', - }, - }, - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - Pageable: { - type: 'object', - properties: { - page: { - minimum: 0, - type: 'integer', - format: 'int32', - default: 0, - }, - size: { - minimum: 1, - type: 'integer', - format: 'int32', - }, - sort: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - FreeFormObjectWithoutAdditionalProperties: { - description: 'This is a free-form object without additionalProperties.', - type: 'object', - }, - FreeFormObjectWithAdditionalPropertiesEqTrue: { - description: 'This is a free-form object with additionalProperties: true.', - type: 'object', - additionalProperties: true, - }, - FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { - description: 'This is a free-form object with additionalProperties: {}.', - type: 'object', - additionalProperties: {}, - }, - ModelWithConst: { - type: 'object', - properties: { - String: { - const: 'String', - }, - number: { - const: 0, - }, - null: { - const: null, - }, - withType: { - type: 'string', - const: 'Some string', - }, - }, - }, - ModelWithAdditionalPropertiesEqTrue: { - description: 'This is a model with one property and additionalProperties: true', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - additionalProperties: true, - }, - NestedAnyOfArraysNullable: { - properties: { - nullableArray: { - anyOf: [ - { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - }, - }, - type: 'object', - }, - CompositionWithOneOfAndProperties: { - type: 'object', - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - $ref: '#/components/parameters/SimpleParameter', - }, - }, - additionalProperties: false, - }, - { - type: 'object', - required: ['bar'], - properties: { - bar: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - additionalProperties: false, - }, - ], - required: ['baz', 'qux'], - properties: { - baz: { - type: 'integer', - format: 'uint16', - minimum: 0, - nullable: true, - }, - qux: { - type: 'integer', - format: 'uint8', - minimum: 0, - }, - }, - }, - NullableObject: { - type: 'object', - nullable: true, - description: 'An object that can be null', - properties: { - foo: { - type: 'string', - }, - }, - default: null, - }, - ModelWithNullableObject: { - type: 'object', - properties: { - data: { - $ref: '#/components/schemas/NullableObject', - }, - }, - }, - ModelWithOneOfEnum: { - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Bar'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Baz'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Qux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'string', - format: 'date-time', - }, - foo: { - type: 'string', - enum: ['Quux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'array', - items: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - maxItems: 2, - minItems: 2, - }, - foo: { - type: 'string', - enum: ['Corge'], - }, - }, - }, - ], - }, - ModelWithNestedArrayEnumsDataFoo: { - enum: ['foo', 'bar'], - type: 'string', - }, - ModelWithNestedArrayEnumsDataBar: { - enum: ['baz', 'qux'], - type: 'string', - }, - ModelWithNestedArrayEnumsData: { - type: 'object', - properties: { - foo: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - }, - bar: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', - }, - }, - }, - }, - ModelWithNestedArrayEnums: { - type: 'object', - properties: { - array_strings: { - type: 'array', - items: { - type: 'string', - }, - }, - data: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', - }, - ], - }, - }, - }, - ModelWithNestedCompositionEnums: { - type: 'object', - properties: { - foo: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - }, - }, - ModelWithReadOnlyAndWriteOnly: { - type: 'object', - required: ['foo', 'bar', 'baz'], - properties: { - foo: { - type: 'string', - }, - bar: { - readOnly: true, - type: 'string', - }, - baz: { - type: 'string', - writeOnly: true, - }, - }, - }, - }, + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', }, } as const; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap index f7f419e44..d4f2992e7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap @@ -1,142 +1,155 @@ export const $CommentWithBreaks = { - type: 'number', description: `Testing multiline comments in string: First line Second line Fourth line`, + type: 'integer', } as const; export const $CommentWithBackticks = { - type: 'number', - description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, + description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', + type: 'integer', } as const; export const $CommentWithSlashes = { - type: 'number', - description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, + description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', + type: 'integer', } as const; export const $CommentWithExpressionPlaceholders = { - type: 'number', - description: `Testing expression placeholders in string: \${expression} should work`, + description: 'Testing expression placeholders in string: ${expression} should work', + type: 'integer', } as const; export const $CommentWithQuotes = { - type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, + type: 'integer', } as const; export const $CommentWithReservedCharacters = { - type: 'number', - description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, + description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', + type: 'integer', } as const; export const $SimpleInteger = { - type: 'number', - description: `This is a simple number`, + description: 'This is a simple number', + type: 'integer', } as const; export const $SimpleBoolean = { + description: 'This is a simple boolean', type: 'boolean', - description: `This is a simple boolean`, } as const; export const $SimpleString = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, } as const; export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { + description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string', - description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; export const $SimpleFile = { - type: 'binary', - description: `This is a simple file`, + description: 'This is a simple file', + type: 'file', } as const; export const $SimpleReference = { - type: 'ModelWithString', - description: `This is a simple reference`, + description: 'This is a simple reference', + $ref: '#/components/schemas/ModelWithString', } as const; export const $SimpleStringWithPattern = { + description: 'This is a simple string', type: 'string', - description: `This is a simple string`, - isNullable: true, + nullable: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', } as const; export const $EnumWithStrings = { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; export const $EnumWithReplacedCharacters = { - type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], + type: 'string', } as const; export const $EnumWithNumbers = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], default: 200, } as const; export const $EnumFromDescription = { + description: 'Success=1,Warning=2,Error=3', type: 'number', - description: `Success=1,Warning=2,Error=3`, } as const; export const $EnumWithExtensions = { - type: 'Enum', + description: 'This is a simple enum with numbers', enum: [200, 400, 500], + 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], + 'x-enum-descriptions': [ + 'Used when the status of something is successful', + 'Used when the status of something has a warning', + 'Used when the status of something has an error', + ], } as const; export const $ArrayWithNumbers = { + description: 'This is a simple array with numbers', type: 'array', - contains: { - type: 'number', + items: { + type: 'integer', }, } as const; export const $ArrayWithBooleans = { + description: 'This is a simple array with booleans', type: 'array', - contains: { + items: { type: 'boolean', }, } as const; export const $ArrayWithStrings = { + description: 'This is a simple array with strings', type: 'array', - contains: { + items: { type: 'string', }, default: ['test'], } as const; export const $ArrayWithReferences = { + description: 'This is a simple array with references', type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $ArrayWithArray = { + description: 'This is a simple array containing an array', type: 'array', - contains: { + items: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ArrayWithProperties = { + description: 'This is a simple array with properties', type: 'array', - contains: { + items: { + type: 'object', properties: { foo: { type: 'string', @@ -149,11 +162,12 @@ export const $ArrayWithProperties = { } as const; export const $ArrayWithAnyOfProperties = { + description: 'This is a simple array with any of properties', type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -162,6 +176,7 @@ export const $ArrayWithAnyOfProperties = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -173,13 +188,11 @@ export const $ArrayWithAnyOfProperties = { } as const; export const $AnyOfAnyAndNull = { + type: 'object', properties: { data: { - type: 'any-of', - contains: [ - { - properties: {}, - }, + anyOf: [ + {}, { type: 'null', }, @@ -189,14 +202,14 @@ export const $AnyOfAnyAndNull = { } as const; export const $AnyOfArrays = { - description: `This is a simple array with any of properties`, + description: 'This is a simple array with any of properties', + type: 'object', properties: { results: { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { + type: 'object', properties: { foo: { type: 'string', @@ -204,6 +217,7 @@ export const $AnyOfArrays = { }, }, { + type: 'object', properties: { bar: { type: 'string', @@ -212,47 +226,54 @@ export const $AnyOfArrays = { }, ], }, + type: 'array', }, }, } as const; export const $DictionaryWithString = { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { type: 'string', }, } as const; export const $DictionaryWithReference = { - type: 'dictionary', - contains: { - type: 'ModelWithString', + description: 'This is a string reference', + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/ModelWithString', }, } as const; export const $DictionaryWithArray = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $DictionaryWithDictionary = { - type: 'dictionary', - contains: { - type: 'dictionary', - contains: { + description: 'This is a string dictionary', + type: 'object', + additionalProperties: { + type: 'object', + additionalProperties: { type: 'string', }, }, } as const; export const $DictionaryWithProperties = { - type: 'dictionary', - contains: { + description: 'This is a complex dictionary', + type: 'object', + additionalProperties: { + type: 'object', properties: { foo: { type: 'string', @@ -265,171 +286,178 @@ export const $DictionaryWithProperties = { } as const; export const $ModelWithInteger = { - description: `This is a model with one number property`, + description: 'This is a model with one number property', + type: 'object', properties: { prop: { - type: 'number', - description: `This is a simple number property`, + description: 'This is a simple number property', + type: 'integer', }, }, } as const; export const $ModelWithBoolean = { - description: `This is a model with one boolean property`, + description: 'This is a model with one boolean property', + type: 'object', properties: { prop: { + description: 'This is a simple boolean property', type: 'boolean', - description: `This is a simple boolean property`, }, }, } as const; export const $ModelWithString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, } as const; export const $ModelWithNullableString = { - description: `This is a model with one string property`, + description: 'This is a model with one string property', + type: 'object', + required: ['nullableRequiredProp1', 'nullableRequiredProp2'], properties: { nullableProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isNullable: true, + nullable: true, }, nullableRequiredProp1: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + nullable: true, }, nullableProp2: { - type: 'string', - description: `This is a simple string property`, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, nullableRequiredProp2: { - type: 'string', - description: `This is a simple string property`, - isRequired: true, - isNullable: true, + description: 'This is a simple string property', + type: ['string', 'null'], }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithEnum = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, statusCode: { - type: 'Enum', + description: 'These are the HTTP error code enums', enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], }, bool: { + description: 'Simple boolean enum', type: 'boolean', - description: `Simple boolean enum`, + enum: [true], }, }, } as const; export const $ModelWithEnumWithHyphen = { - description: `This is a model with one enum with escaped name`, + description: 'This is a model with one enum with escaped name', + type: 'object', properties: { 'foo-bar-baz-qux': { - type: 'Enum', + type: 'string', enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', default: '3.0', }, }, } as const; export const $ModelWithEnumFromDescription = { - description: `This is a model with one enum`, + description: 'This is a model with one enum', + type: 'object', properties: { test: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, } as const; export const $ModelWithNestedEnums = { - description: `This is a model with nested enums`, + description: 'This is a model with nested enums', + type: 'object', properties: { dictionaryWithEnum: { - type: 'dictionary', - contains: { - type: 'Enum', + type: 'object', + additionalProperties: { enum: ['Success', 'Warning', 'Error'], }, }, dictionaryWithEnumFromDescription: { - type: 'dictionary', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + type: 'object', + additionalProperties: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, arrayWithEnum: { type: 'array', - contains: { - type: 'Enum', + items: { enum: ['Success', 'Warning', 'Error'], }, }, arrayWithDescription: { type: 'array', - contains: { - type: 'number', - description: `Success=1,Warning=2,Error=3`, + items: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3', }, }, 'foo_bar-enum': { - type: 'Enum', + description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], }, }, } as const; export const $ModelWithReference = { - description: `This is a model with one property containing a reference`, + description: 'This is a model with one property containing a reference', + type: 'object', properties: { prop: { - type: 'ModelWithProperties', + $ref: '#/components/schemas/ModelWithProperties', }, }, } as const; export const $ModelWithArrayReadOnlyAndWriteOnly = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithReadOnlyAndWriteOnly', + items: { + $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -437,23 +465,24 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } as const; export const $ModelWithArray = { - description: `This is a model with one property containing an array`, + description: 'This is a model with one property containing an array', + type: 'object', properties: { prop: { type: 'array', - contains: { - type: 'ModelWithString', + items: { + $ref: '#/components/schemas/ModelWithString', }, }, propWithFile: { type: 'array', - contains: { - type: 'binary', + items: { + type: 'file', }, }, propWithNumber: { type: 'array', - contains: { + items: { type: 'number', }, }, @@ -461,11 +490,12 @@ export const $ModelWithArray = { } as const; export const $ModelWithDictionary = { - description: `This is a model with one property containing a dictionary`, + description: 'This is a model with one property containing a dictionary', + type: 'object', properties: { prop: { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'string', }, }, @@ -473,41 +503,46 @@ export const $ModelWithDictionary = { } as const; export const $DeprecatedModel = { - description: `This is a deprecated model with a deprecated property`, + deprecated: true, + description: 'This is a deprecated model with a deprecated property', + type: 'object', properties: { prop: { + deprecated: true, + description: 'This is a deprecated property', type: 'string', - description: `This is a deprecated property`, }, }, } as const; export const $ModelWithCircularReference = { - description: `This is a model with one property containing a circular reference`, + description: 'This is a model with one property containing a circular reference', + type: 'object', properties: { prop: { - type: 'ModelWithCircularReference', + $ref: '#/components/schemas/ModelWithCircularReference', }, }, } as const; export const $CompositionWithOneOf = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -515,13 +550,15 @@ export const $CompositionWithOneOf = { } as const; export const $CompositionWithOneOfAnonymous = { - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -529,12 +566,12 @@ export const $CompositionWithOneOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -542,11 +579,12 @@ export const $CompositionWithOneOfAnonymous = { } as const; export const $ModelCircle = { - description: `Circle`, + description: 'Circle', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, radius: { type: 'number', @@ -555,11 +593,12 @@ export const $ModelCircle = { } as const; export const $ModelSquare = { - description: `Square`, + description: 'Square', + type: 'object', + required: ['kind'], properties: { kind: { type: 'string', - isRequired: true, }, sideLength: { type: 'number', @@ -568,35 +607,43 @@ export const $ModelSquare = { } as const; export const $CompositionWithOneOfDiscriminator = { - type: 'one-of', - description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, - contains: [ + description: "This is a model with one property with a 'one of' relationship where the options are not $ref", + type: 'object', + oneOf: [ { - type: 'ModelCircle', + $ref: '#/components/schemas/ModelCircle', }, { - type: 'ModelSquare', + $ref: '#/components/schemas/ModelSquare', }, ], + discriminator: { + propertyName: 'kind', + mapping: { + circle: '#/components/schemas/ModelCircle', + square: '#/components/schemas/ModelSquare', + }, + }, } as const; export const $CompositionWithAnyOf = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], }, @@ -604,13 +651,15 @@ export const $CompositionWithAnyOf = { } as const; export const $CompositionWithAnyOfAnonymous = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - description: `Anonymous object type`, + description: 'Anonymous object type', + type: 'object', properties: { propA: { type: 'string', @@ -618,12 +667,12 @@ export const $CompositionWithAnyOfAnonymous = { }, }, { + description: 'Anonymous string type', type: 'string', - description: `Anonymous string type`, }, { - type: 'number', - description: `Anonymous integer type`, + description: 'Anonymous integer type', + type: 'integer', }, ], }, @@ -631,38 +680,37 @@ export const $CompositionWithAnyOfAnonymous = { } as const; export const $CompositionWithNestedAnyAndTypeNull = { - description: `This is a model with nested 'any of' property with a type null`, + description: "This is a model with nested 'any of' property with a type null", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + type: 'object', + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, { type: 'null', }, ], }, + type: 'array', }, { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { type: 'null', }, ], }, + type: 'array', }, ], }, @@ -670,49 +718,53 @@ export const $CompositionWithNestedAnyAndTypeNull = { } as const; export const $Enum1 = { - type: 'Enum', enum: ['Bird', 'Dog'], + type: 'string', } as const; export const $ConstValue = { - type: '"ConstValue"', + type: 'string', + const: 'ConstValue', } as const; export const $CompositionWithNestedAnyOfAndNull = { - description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, + description: "This is a model with one property with a 'any of' relationship where the options are not $ref", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { - type: 'Enum1', + $ref: '#/components/schemas/Enum1', }, { - type: 'ConstValue', + $ref: '#/components/schemas/ConstValue', }, ], }, + type: 'array', }, { type: 'null', }, ], + title: 'Scopes', }, }, } as const; export const $CompositionWithOneOfAndNullable = { - description: `This is a model with one property with a 'one of' relationship`, + description: "This is a model with one property with a 'one of' relationship", + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + nullable: true, + type: 'object', + oneOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -720,32 +772,31 @@ export const $CompositionWithOneOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithOneOfAndSimpleDictionary = { - description: `This is a model that contains a simple dictionary within composition`, + description: 'This is a model that contains a simple dictionary within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'number', }, }, @@ -755,19 +806,19 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } as const; export const $CompositionWithOneOfAndSimpleArrayDictionary = { - description: `This is a model that contains a dictionary of simple arrays within composition`, + description: 'This is a model that contains a dictionary of simple arrays within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { + items: { type: 'boolean', }, }, @@ -778,21 +829,20 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } as const; export const $CompositionWithOneOfAndComplexArrayDictionary = { - description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, + description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', + type: 'object', properties: { propA: { - type: 'one-of', - contains: [ + oneOf: [ { type: 'boolean', }, { - type: 'dictionary', - contains: { + type: 'object', + additionalProperties: { type: 'array', - contains: { - type: 'one-of', - contains: [ + items: { + oneOf: [ { type: 'number', }, @@ -809,12 +859,15 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } as const; export const $CompositionWithAllOfAndNullable = { - description: `This is a model with one property with a 'all of' relationship`, + description: "This is a model with one property with a 'all of' relationship", + type: 'object', properties: { propA: { - type: 'all-of', - contains: [ + nullable: true, + type: 'object', + allOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -822,27 +875,29 @@ export const $CompositionWithAllOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionWithAnyOfAndNullable = { - description: `This is a model with one property with a 'any of' relationship`, + description: "This is a model with one property with a 'any of' relationship", + type: 'object', properties: { propA: { - type: 'any-of', - contains: [ + nullable: true, + type: 'object', + anyOf: [ { + type: 'object', properties: { boolean: { type: 'boolean', @@ -850,22 +905,22 @@ export const $CompositionWithAnyOfAndNullable = { }, }, { - type: 'ModelWithEnum', + $ref: '#/components/schemas/ModelWithEnum', }, { - type: 'ModelWithArray', + $ref: '#/components/schemas/ModelWithArray', }, { - type: 'ModelWithDictionary', + $ref: '#/components/schemas/ModelWithDictionary', }, ], - isNullable: true, }, }, } as const; export const $CompositionBaseModel = { - description: `This is a base model with two simple optional properties`, + description: 'This is a base model with two simple optional properties', + type: 'object', properties: { firstName: { type: 'string', @@ -877,47 +932,36 @@ export const $CompositionBaseModel = { } as const; export const $CompositionExtendedModel = { - type: 'all-of', - description: `This is a model that extends the base model`, - contains: [ - { - type: 'CompositionBaseModel', - }, + description: 'This is a model that extends the base model', + type: 'object', + allOf: [ { - properties: { - firstName: { - type: 'string', - isRequired: true, - }, - lastname: { - type: 'string', - isRequired: true, - }, - age: { - type: 'number', - isRequired: true, - }, - }, + $ref: '#/components/schemas/CompositionBaseModel', }, ], + properties: { + age: { + type: 'number', + }, + }, + required: ['firstName', 'lastname', 'age'], } as const; export const $ModelWithProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], properties: { required: { type: 'string', - isRequired: true, }, requiredAndReadOnly: { type: 'string', - isReadOnly: true, - isRequired: true, + readOnly: true, }, requiredAndNullable: { type: 'string', - isRequired: true, - isNullable: true, + nullable: true, }, string: { type: 'string', @@ -929,7 +973,7 @@ export const $ModelWithProperties = { type: 'boolean', }, reference: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, 'property with space': { type: 'string', @@ -942,52 +986,58 @@ export const $ModelWithProperties = { }, '@namespace.string': { type: 'string', - isReadOnly: true, + readOnly: true, }, '@namespace.integer': { - type: 'number', - isReadOnly: true, + type: 'integer', + readOnly: true, }, }, } as const; export const $ModelWithNestedProperties = { - description: `This is a model with one nested property`, + description: 'This is a model with one nested property', + type: 'object', + required: ['first'], properties: { first: { + type: 'object', + required: ['second'], + readOnly: true, + nullable: true, properties: { second: { + type: 'object', + required: ['third'], + readOnly: true, + nullable: true, properties: { third: { type: 'string', - isReadOnly: true, - isRequired: true, - isNullable: true, + required: true, + readOnly: true, + nullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, - isReadOnly: true, - isRequired: true, - isNullable: true, }, }, } as const; export const $ModelWithDuplicateProperties = { - description: `This is a model with duplicated properties`, + description: 'This is a model with duplicated properties', + type: 'object', properties: { prop: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelWithOrderedProperties = { - description: `This is a model with ordered properties`, + description: 'This is a model with ordered properties', + type: 'object', properties: { zebra: { type: 'string', @@ -1002,34 +1052,36 @@ export const $ModelWithOrderedProperties = { } as const; export const $ModelWithDuplicateImports = { - description: `This is a model with duplicated imports`, + description: 'This is a model with duplicated imports', + type: 'object', properties: { propA: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, propC: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, } as const; export const $ModelThatExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { + type: 'object', properties: { propExtendsA: { type: 'string', }, propExtendsB: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1037,22 +1089,23 @@ export const $ModelThatExtends = { } as const; export const $ModelThatExtendsExtends = { - type: 'all-of', - description: `This is a model that extends another model`, - contains: [ + description: 'This is a model that extends another model', + type: 'object', + allOf: [ { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, { - type: 'ModelThatExtends', + $ref: '#/components/schemas/ModelThatExtends', }, { + type: 'object', properties: { propExtendsC: { type: 'string', }, propExtendsD: { - type: 'ModelWithString', + $ref: '#/components/schemas/ModelWithString', }, }, }, @@ -1060,35 +1113,35 @@ export const $ModelThatExtendsExtends = { } as const; export const $ModelWithPattern = { - description: `This is a model that contains a some patterns`, + description: 'This is a model that contains a some patterns', + type: 'object', + required: ['key', 'name'], properties: { key: { - type: 'string', - isRequired: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$', + type: 'string', }, name: { - type: 'string', - isRequired: true, maxLength: 255, + type: 'string', }, enabled: { type: 'boolean', - isReadOnly: true, + readOnly: true, }, modified: { type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, id: { type: 'string', - pattern: '^\\d{2}-\\d{3}-\\d{4}$', + pattern: '^d{2}-d{3}-d{4}$', }, text: { type: 'string', - pattern: '^\\w+$', + pattern: '^w+$', }, patternWithSingleQuotes: { type: 'string', @@ -1096,7 +1149,8 @@ export const $ModelWithPattern = { }, patternWithNewline: { type: 'string', - pattern: 'aaa\nbbb', + pattern: `aaa +bbb`, }, patternWithBacktick: { type: 'string', @@ -1106,37 +1160,44 @@ export const $ModelWithPattern = { } as const; export const $File = { + required: ['mime'], + type: 'object', properties: { id: { + title: 'Id', type: 'string', - isReadOnly: true, + readOnly: true, minLength: 1, }, updated_at: { + title: 'Updated at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, created_at: { + title: 'Created at', type: 'string', - isReadOnly: true, format: 'date-time', + readOnly: true, }, mime: { + title: 'Mime', type: 'string', - isRequired: true, maxLength: 24, minLength: 1, }, file: { + title: 'File', type: 'string', - isReadOnly: true, + readOnly: true, format: 'uri', }, }, } as const; -export const $_default = { +export const $default = { + type: 'object', properties: { name: { type: 'string', @@ -1145,21 +1206,22 @@ export const $_default = { } as const; export const $Pageable = { + type: 'object', properties: { page: { - type: 'number', - default: 0, - format: 'int32', minimum: 0, + type: 'integer', + format: 'int32', + default: 0, }, size: { - type: 'number', - format: 'int32', minimum: 1, + type: 'integer', + format: 'int32', }, sort: { type: 'array', - contains: { + items: { type: 'string', }, }, @@ -1167,63 +1229,60 @@ export const $Pageable = { } as const; export const $FreeFormObjectWithoutAdditionalProperties = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object without additionalProperties.', + type: 'object', } as const; export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: true.', + type: 'object', + additionalProperties: true, } as const; export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - type: 'dictionary', - contains: { - properties: {}, - }, + description: 'This is a free-form object with additionalProperties: {}.', + type: 'object', + additionalProperties: {}, } as const; export const $ModelWithConst = { + type: 'object', properties: { String: { - type: '"String"', + const: 'String', }, number: { - type: '0', + const: 0, }, null: { - type: 'null', + const: null, }, withType: { - type: '"Some string"', + type: 'string', + const: 'Some string', }, }, } as const; export const $ModelWithAdditionalPropertiesEqTrue = { - description: `This is a model with one property and additionalProperties: true`, + description: 'This is a model with one property and additionalProperties: true', + type: 'object', properties: { prop: { + description: 'This is a simple string property', type: 'string', - description: `This is a simple string property`, }, }, + additionalProperties: true, } as const; export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { - type: 'any-of', - contains: [ + anyOf: [ { - type: 'array', - contains: { - type: 'any-of', - contains: [ + items: { + anyOf: [ { type: 'string', }, @@ -1232,6 +1291,7 @@ export const $NestedAnyOfArraysNullable = { }, ], }, + type: 'array', }, { type: 'null', @@ -1239,141 +1299,137 @@ export const $NestedAnyOfArraysNullable = { ], }, }, + type: 'object', } as const; export const $CompositionWithOneOfAndProperties = { - type: 'one-of', - contains: [ + type: 'object', + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'SimpleParameter', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/parameters/SimpleParameter', }, }, + additionalProperties: false, }, { + type: 'object', + required: ['bar'], properties: { bar: { - type: 'NonAsciiStringæøåÆØÅöôêÊ字符串', - isRequired: true, - }, - baz: { - type: 'number', - isRequired: true, - isNullable: true, - format: 'uint16', - minimum: 0, - }, - qux: { - type: 'number', - isRequired: true, - format: 'uint8', - minimum: 0, + $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', }, }, + additionalProperties: false, }, ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true, + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0, + }, + }, } as const; export const $NullableObject = { - description: `An object that can be null`, + type: 'object', + nullable: true, + description: 'An object that can be null', properties: { foo: { type: 'string', }, }, default: null, - isNullable: true, } as const; export const $ModelWithNullableObject = { + type: 'object', properties: { data: { - type: 'NullableObject', + $ref: '#/components/schemas/NullableObject', }, }, } as const; export const $ModelWithOneOfEnum = { - type: 'one-of', - contains: [ + oneOf: [ { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Bar'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Baz'], - isRequired: true, }, }, }, { + type: 'object', + required: ['foo'], properties: { foo: { - type: 'Enum', + type: 'string', enum: ['Qux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'string', - isRequired: true, format: 'date-time', }, foo: { - type: 'Enum', + type: 'string', enum: ['Quux'], - isRequired: true, }, }, }, { + type: 'object', + required: ['content', 'foo'], properties: { content: { type: 'array', - contains: { - type: 'any-of', - contains: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - }, - isRequired: true, + items: [ + { + type: 'string', + format: 'date-time', + }, + { + type: 'string', + }, + ], + maxItems: 2, + minItems: 2, }, foo: { - type: 'Enum', + type: 'string', enum: ['Corge'], - isRequired: true, }, }, }, @@ -1381,45 +1437,46 @@ export const $ModelWithOneOfEnum = { } as const; export const $ModelWithNestedArrayEnumsDataFoo = { - type: 'Enum', enum: ['foo', 'bar'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsDataBar = { - type: 'Enum', enum: ['baz', 'qux'], + type: 'string', } as const; export const $ModelWithNestedArrayEnumsData = { + type: 'object', properties: { foo: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataFoo', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, }, bar: { type: 'array', - contains: { - type: 'ModelWithNestedArrayEnumsDataBar', + items: { + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', }, }, }, } as const; export const $ModelWithNestedArrayEnums = { + type: 'object', properties: { array_strings: { type: 'array', - contains: { + items: { type: 'string', }, }, data: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsData', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', }, ], }, @@ -1427,12 +1484,12 @@ export const $ModelWithNestedArrayEnums = { } as const; export const $ModelWithNestedCompositionEnums = { + type: 'object', properties: { foo: { - type: 'all-of', - contains: [ + allOf: [ { - type: 'ModelWithNestedArrayEnumsDataFoo', + $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', }, ], }, @@ -1440,3071 +1497,29 @@ export const $ModelWithNestedCompositionEnums = { } as const; export const $ModelWithReadOnlyAndWriteOnly = { + type: 'object', + required: ['foo', 'bar', 'baz'], properties: { foo: { type: 'string', - isRequired: true, }, bar: { + readOnly: true, type: 'string', - isReadOnly: true, - isRequired: true, }, baz: { type: 'string', - isRequired: true, + writeOnly: true, }, }, } as const; export const $SimpleParameter = { - type: 'string', - description: `This is a reusable parameter`, -} as const; - -export const $OpenApi = { - openapi: '3.0.0', - info: { - title: 'swagger', - version: 'v1.0', - }, - servers: [ - { - url: 'http://localhost:3000/base', - }, - ], - paths: { - '/api/v{api-version}/no-tag': { - tags: [], - get: { - operationId: 'ServiceWithEmptyTag', - }, - post: { - operationId: 'PostServiceWithEmptyTag', - requestBody: { - required: true, - content: { - 'application/json': { - schema: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - { - $ref: '#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly', - }, - ], - }, - }, - }, - }, - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/simple': { - get: { - tags: ['Simple'], - operationId: 'GetCallWithoutParametersAndResponse', - }, - put: { - tags: ['Simple'], - operationId: 'PutCallWithoutParametersAndResponse', - }, - post: { - tags: ['Simple'], - operationId: 'PostCallWithoutParametersAndResponse', - }, - delete: { - tags: ['Simple'], - operationId: 'DeleteCallWithoutParametersAndResponse', - }, - options: { - tags: ['Simple'], - operationId: 'OptionsCallWithoutParametersAndResponse', - }, - head: { - tags: ['Simple'], - operationId: 'HeadCallWithoutParametersAndResponse', - }, - patch: { - tags: ['Simple'], - operationId: 'PatchCallWithoutParametersAndResponse', - }, - }, - '/api/v{api-version}/foo/{foo}/bar/{bar}': { - delete: { - tags: ['Parameters'], - operationId: 'deleteFoo', - parameters: [ - { - description: 'foo in method', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in method', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - parameters: [ - { - description: 'foo in global parameters', - in: 'path', - name: 'foo', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'bar in global parameters', - in: 'path', - name: 'bar', - required: true, - schema: { - type: 'string', - }, - }, - ], - }, - '/api/v{api-version}/descriptions/': { - post: { - tags: ['Descriptions'], - operationId: 'CallWithDescriptions', - parameters: [ - { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - name: 'parameterWithBreaks', - in: 'query', - type: 'string', - }, - { - description: - 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - name: 'parameterWithBackticks', - in: 'query', - type: 'string', - }, - { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - name: 'parameterWithSlashes', - in: 'query', - type: 'string', - }, - { - description: 'Testing expression placeholders in string: ${expression} should work', - name: 'parameterWithExpressionPlaceholders', - in: 'query', - type: 'string', - }, - { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - name: 'parameterWithQuotes', - in: 'query', - type: 'string', - }, - { - description: - 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - name: 'parameterWithReservedCharacters', - in: 'query', - type: 'string', - }, - ], - }, - }, - '/api/v{api-version}/parameters/deprecated': { - post: { - tags: ['Deprecated'], - deprecated: true, - operationId: 'DeprecatedCall', - parameters: [ - { - deprecated: true, - description: 'This parameter is deprecated', - name: 'parameter', - in: 'header', - required: true, - nullable: true, - schema: { - $ref: '#/components/schemas/DeprecatedModel', - }, - }, - ], - }, - }, - '/api/v{api-version}/parameters/{parameterPath}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithParameters', - parameters: [ - { - description: 'This is the parameter that goes into the header', - name: 'parameterHeader', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - required: false, - schema: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - name: 'foo_ref_enum', - in: 'query', - }, - { - required: true, - schema: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - name: 'foo_all_of_enum', - in: 'query', - }, - { - description: 'This is the parameter that goes into the query params', - name: 'parameterQuery', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the form data', - name: 'parameterForm', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'parameterCookie', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameterPath', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}': { - post: { - tags: ['Parameters'], - operationId: 'CallWithWeirdParameterNames', - parameters: [ - { - description: 'This is the parameter that goes into the path', - name: 'parameter.path.1', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'parameter-path-2', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the path', - name: 'PARAMETER-PATH-3', - in: 'path', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter with a reserved keyword', - name: 'default', - in: 'query', - required: false, - nullable: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request header', - name: 'parameter.header', - in: 'header', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request query params', - name: 'parameter-query', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the request form data', - name: 'parameter_form', - in: 'formData', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is the parameter that goes into the cookie', - name: 'PARAMETER-COOKIE', - in: 'cookie', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - nullable: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is the parameter that goes into the body', - required: true, - nullable: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/parameters/': { - get: { - tags: ['Parameters'], - operationId: 'GetCallWithOptionalParam', - parameters: [ - { - description: 'This is an optional parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - description: 'This is a required parameter', - required: true, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithOneOfEnum', - }, - }, - }, - }, - }, - post: { - tags: ['Parameters'], - operationId: 'PostCallWithOptionalParam', - parameters: [ - { - description: 'This is a required parameter', - name: 'parameter', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/Pageable', - }, - }, - ], - requestBody: { - description: 'This is an optional parameter', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/requestBody/': { - post: { - tags: ['RequestBody'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleRequestBody', - }, - }, - }, - '/api/v{api-version}/formData/': { - post: { - tags: ['FormData'], - parameters: [ - { - $ref: '#/components/parameters/SimpleParameter', - }, - ], - requestBody: { - $ref: '#/components/requestBodies/SimpleFormData', - }, - }, - }, - '/api/v{api-version}/defaults': { - get: { - tags: ['Defaults'], - operationId: 'CallWithDefaultParameters', - parameters: [ - { - description: 'This is a simple string with default value', - name: 'parameterString', - in: 'query', - nullable: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number with default value', - name: 'parameterNumber', - in: 'query', - nullable: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean with default value', - name: 'parameterBoolean', - in: 'query', - nullable: true, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum with default value', - name: 'parameterEnum', - in: 'query', - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model with default value', - name: 'parameterModel', - in: 'query', - nullable: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - post: { - tags: ['Defaults'], - operationId: 'CallWithDefaultOptionalParameters', - parameters: [ - { - description: 'This is a simple string that is optional with default value', - name: 'parameterString', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a simple number that is optional with default value', - name: 'parameterNumber', - in: 'query', - required: false, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a simple boolean that is optional with default value', - name: 'parameterBoolean', - in: 'query', - required: false, - schema: { - type: 'boolean', - default: true, - }, - }, - { - description: 'This is a simple enum that is optional with default value', - name: 'parameterEnum', - in: 'query', - required: false, - schema: { - enum: ['Success', 'Warning', 'Error'], - default: 0, - }, - }, - { - description: 'This is a simple model that is optional with default value', - name: 'parameterModel', - in: 'query', - required: false, - schema: { - $ref: '#/components/schemas/ModelWithString', - default: { - prop: 'Hello World!', - }, - }, - }, - ], - }, - put: { - tags: ['Defaults'], - operationId: 'CallToTestOrderOfParams', - parameters: [ - { - description: 'This is a optional string with default', - name: 'parameterOptionalStringWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a optional string with empty default', - name: 'parameterOptionalStringWithEmptyDefault', - in: 'query', - required: false, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a optional string with no default', - name: 'parameterOptionalStringWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string with default', - name: 'parameterStringWithDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'Hello World!', - }, - }, - { - description: 'This is a string with empty default', - name: 'parameterStringWithEmptyDefault', - in: 'query', - required: true, - schema: { - type: 'string', - default: '', - }, - }, - { - description: 'This is a string with no default', - name: 'parameterStringWithNoDefault', - in: 'query', - required: true, - schema: { - type: 'string', - }, - }, - { - description: 'This is a string that can be null with no default', - name: 'parameterStringNullableWithNoDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - }, - }, - { - description: 'This is a string that can be null with default', - name: 'parameterStringNullableWithDefault', - in: 'query', - required: false, - schema: { - type: 'string', - nullable: true, - default: null, - }, - }, - ], - }, - }, - '/api/v{api-version}/duplicate': { - get: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - post: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - put: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - delete: { - tags: ['Duplicate'], - operationId: 'DuplicateName', - }, - }, - '/api/v{api-version}/no-content': { - get: { - tags: ['NoContent'], - operationId: 'CallWithNoContentResponse', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/response-and-no-content': { - get: { - tags: ['Response', 'NoContent'], - operationId: 'CallWithResponseAndNoContentResponse', - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/a': { - get: { - tags: ['MultipleTags1', 'MultipleTags2'], - operationId: 'DummyA', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/multiple-tags/b': { - get: { - tags: ['MultipleTags1', 'MultipleTags2', 'MultipleTags3'], - operationId: 'DummyB', - responses: { - 204: { - description: 'Success', - }, - }, - }, - }, - '/api/v{api-version}/response': { - get: { - tags: ['Response'], - operationId: 'CallWithResponse', - responses: { - default: { - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - post: { - tags: ['Response'], - operationId: 'CallWithDuplicateResponses', - responses: { - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - put: { - tags: ['Response'], - operationId: 'CallWithResponses', - responses: { - 200: { - description: 'Message for 200 response', - content: { - 'application/json': { - schema: { - type: 'object', - properties: { - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - value: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - 201: { - description: 'Message for 201 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtends', - }, - }, - }, - }, - 202: { - description: 'Message for 202 response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelThatExtendsExtends', - }, - }, - }, - }, - 500: { - description: 'Message for 500 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 501: { - description: 'Message for 501 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - 502: { - description: 'Message for 502 error', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - default: { - description: 'Message for default response', - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/collectionFormat': { - get: { - tags: ['CollectionFormat'], - operationId: 'CollectionFormat', - parameters: [ - { - description: 'This is an array parameter that is sent as csv format (comma-separated values)', - name: 'parameterArrayCSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'csv', - }, - { - description: 'This is an array parameter that is sent as ssv format (space-separated values)', - name: 'parameterArraySSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'ssv', - }, - { - description: 'This is an array parameter that is sent as tsv format (tab-separated values)', - name: 'parameterArrayTSV', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'tsv', - }, - { - description: 'This is an array parameter that is sent as pipes format (pipe-separated values)', - name: 'parameterArrayPipes', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'pipes', - }, - { - description: - 'This is an array parameter that is sent as multi format (multiple parameter instances)', - name: 'parameterArrayMulti', - in: 'query', - required: true, - nullable: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - }, - collectionFormat: 'multi', - }, - ], - }, - }, - '/api/v{api-version}/types': { - get: { - tags: ['Types'], - operationId: 'Types', - parameters: [ - { - description: 'This is a number parameter', - name: 'parameterNumber', - in: 'query', - required: true, - schema: { - type: 'number', - default: 123, - }, - }, - { - description: 'This is a string parameter', - name: 'parameterString', - in: 'query', - required: true, - schema: { - type: 'string', - default: 'default', - nullable: true, - }, - }, - { - description: 'This is a boolean parameter', - name: 'parameterBoolean', - in: 'query', - required: true, - schema: { - type: 'boolean', - default: true, - nullable: true, - }, - }, - { - description: 'This is an object parameter', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - default: null, - nullable: true, - }, - }, - { - description: 'This is an array parameter', - name: 'parameterArray', - in: 'query', - required: true, - schema: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is a dictionary parameter', - name: 'parameterDictionary', - in: 'query', - required: true, - schema: { - type: 'object', - items: { - type: 'string', - }, - nullable: true, - }, - }, - { - description: 'This is an enum parameter', - name: 'parameterEnum', - in: 'query', - required: true, - schema: { - enum: ['Success', 'Warning', 'Error'], - nullable: true, - }, - }, - { - description: 'This is a number parameter', - name: 'id', - in: 'path', - schema: { - type: 'integer', - format: 'int32', - }, - }, - ], - responses: { - 200: { - description: 'Response is a simple number', - content: { - 'application/json': { - schema: { - type: 'number', - }, - }, - }, - }, - 201: { - description: 'Response is a simple string', - content: { - 'application/json': { - schema: { - type: 'string', - }, - }, - }, - }, - 202: { - description: 'Response is a simple boolean', - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - 203: { - description: 'Response is a simple object', - content: { - 'application/json': { - schema: { - type: 'object', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/upload': { - post: { - tags: ['Upload'], - operationId: 'UploadFile', - parameters: [ - { - description: 'Supply a file reference for upload', - name: 'file', - in: 'formData', - required: true, - schema: { - type: 'file', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - nullable: true, - }, - }, - ], - responses: { - 200: { - content: { - 'application/json': { - schema: { - type: 'boolean', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/file/{id}': { - get: { - tags: ['FileResponse'], - operationId: 'FileResponse', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - responses: { - 200: { - description: 'Success', - content: { - 'audio/*': { - schema: { - type: 'file', - }, - }, - 'video/*': { - schema: { - type: 'file', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex': { - get: { - tags: ['Complex'], - operationId: 'ComplexTypes', - parameters: [ - { - description: 'Parameter containing object', - name: 'parameterObject', - in: 'query', - required: true, - schema: { - type: 'object', - properties: { - first: { - type: 'object', - properties: { - second: { - type: 'object', - properties: { - third: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - { - description: 'Parameter containing reference', - name: 'parameterReference', - in: 'query', - required: true, - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/multipart': { - post: { - tags: ['multipart'], - operationId: 'MultipartRequest', - requestBody: { - content: { - 'multipart/form-data': { - schema: { - type: 'object', - properties: { - content: { - type: 'string', - format: 'binary', - }, - data: { - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - ], - nullable: true, - }, - }, - }, - encoding: { - content: { - style: 'form', - }, - data: { - style: 'form', - }, - }, - }, - }, - }, - }, - get: { - tags: ['multipart'], - operationId: 'MultipartResponse', - responses: { - 200: { - description: 'OK', - content: { - 'multipart/mixed': { - schema: { - type: 'object', - properties: { - file: { - type: 'string', - format: 'binary', - }, - metadata: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/complex/{id}': { - put: { - tags: ['Complex'], - operationId: 'ComplexParams', - parameters: [ - { - name: 'id', - in: 'path', - required: true, - schema: { - type: 'integer', - format: 'int32', - }, - }, - { - name: 'api-version', - in: 'path', - required: true, - schema: { - type: 'string', - }, - }, - ], - requestBody: { - content: { - 'application/json-patch+json': { - schema: { - required: ['key', 'name', 'parameters', 'type'], - type: 'object', - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - nullable: true, - readOnly: true, - }, - name: { - maxLength: 255, - type: 'string', - nullable: true, - }, - enabled: { - type: 'boolean', - default: true, - }, - type: { - enum: ['Monkey', 'Horse', 'Bird'], - type: 'string', - readOnly: true, - }, - listOfModels: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - nullable: true, - }, - listOfStrings: { - type: 'array', - items: { - type: 'string', - }, - nullable: true, - }, - parameters: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - user: { - type: 'object', - properties: { - id: { - type: 'integer', - format: 'int32', - readOnly: true, - }, - name: { - type: 'string', - nullable: true, - readOnly: true, - }, - }, - readOnly: true, - }, - }, - }, - }, - }, - }, - responses: { - 200: { - description: 'Success', - content: { - 'application/json; type=collection': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - }, - }, - '/api/v{api-version}/header': { - post: { - tags: ['Header'], - operationId: 'CallWithResultFromHeader', - responses: { - 200: { - description: 'Successful response', - headers: { - 'operation-location': { - schema: { - type: 'string', - }, - }, - }, - }, - 400: { - description: '400 server error', - }, - 500: { - description: '500 server error', - }, - }, - }, - }, - '/api/v{api-version}/error': { - post: { - tags: ['Error'], - operationId: 'testErrorCode', - parameters: [ - { - description: 'Status code to return', - name: 'status', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Custom message: Successful response', - }, - 500: { - description: 'Custom message: Internal Server Error', - }, - 501: { - description: 'Custom message: Not Implemented', - }, - 502: { - description: 'Custom message: Bad Gateway', - }, - 503: { - description: 'Custom message: Service Unavailable', - }, - }, - }, - }, - '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串': { - post: { - tags: ['Non-Ascii-æøåÆØÅöôêÊ'], - operationId: 'nonAsciiæøåÆØÅöôêÊ字符串', - parameters: [ - { - description: 'Dummy input param', - name: 'nonAsciiParamæøåÆØÅöôêÊ', - in: 'query', - required: true, - schema: { - type: 'integer', - }, - }, - ], - responses: { - 200: { - description: 'Successful response', - content: { - 'application/json': { - schema: { - type: 'array', - items: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - }, - }, - }, - }, - }, - }, - }, - components: { - requestBodies: { - SimpleRequestBody: { - 'x-body-name': 'foo', - description: 'A reusable request body', - required: false, - content: { - 'application/json': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - SimpleFormData: { - description: 'A reusable request body', - required: false, - content: { - 'multipart/form-data': { - schema: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - }, - }, - parameters: { - SimpleParameter: { - description: 'This is a reusable parameter', - name: 'parameter', - in: 'query', - required: false, - schema: { - type: 'string', - }, - }, - }, - schemas: { - CommentWithBreaks: { - description: `Testing multiline comments in string: First line -Second line - -Fourth line`, - type: 'integer', - }, - CommentWithBackticks: { - description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', - type: 'integer', - }, - CommentWithSlashes: { - description: 'Testing slashes in string: \backwards\\ and /forwards/// should work', - type: 'integer', - }, - CommentWithExpressionPlaceholders: { - description: 'Testing expression placeholders in string: ${expression} should work', - type: 'integer', - }, - CommentWithQuotes: { - description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, - type: 'integer', - }, - CommentWithReservedCharacters: { - description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', - type: 'integer', - }, - SimpleInteger: { - description: 'This is a simple number', - type: 'integer', - }, - SimpleBoolean: { - description: 'This is a simple boolean', - type: 'boolean', - }, - SimpleString: { - description: 'This is a simple string', - type: 'string', - }, - NonAsciiStringæøåÆØÅöôêÊ字符串: { - description: - 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', - type: 'string', - }, - SimpleFile: { - description: 'This is a simple file', - type: 'file', - }, - SimpleReference: { - description: 'This is a simple reference', - $ref: '#/components/schemas/ModelWithString', - }, - SimpleStringWithPattern: { - description: 'This is a simple string', - type: 'string', - nullable: true, - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - }, - EnumWithStrings: { - description: 'This is a simple enum with strings', - enum: [ - 'Success', - 'Warning', - 'Error', - "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串', - ], - }, - EnumWithReplacedCharacters: { - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], - type: 'string', - }, - EnumWithNumbers: { - description: 'This is a simple enum with numbers', - enum: [1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, -1.3], - default: 200, - }, - EnumFromDescription: { - description: 'Success=1,Warning=2,Error=3', - type: 'number', - }, - EnumWithExtensions: { - description: 'This is a simple enum with numbers', - enum: [200, 400, 500], - 'x-enum-varnames': ['CUSTOM_SUCCESS', 'CUSTOM_WARNING', 'CUSTOM_ERROR'], - 'x-enum-descriptions': [ - 'Used when the status of something is successful', - 'Used when the status of something has a warning', - 'Used when the status of something has an error', - ], - }, - ArrayWithNumbers: { - description: 'This is a simple array with numbers', - type: 'array', - items: { - type: 'integer', - }, - }, - ArrayWithBooleans: { - description: 'This is a simple array with booleans', - type: 'array', - items: { - type: 'boolean', - }, - }, - ArrayWithStrings: { - description: 'This is a simple array with strings', - type: 'array', - items: { - type: 'string', - }, - default: ['test'], - }, - ArrayWithReferences: { - description: 'This is a simple array with references', - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - ArrayWithArray: { - description: 'This is a simple array containing an array', - type: 'array', - items: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ArrayWithProperties: { - description: 'This is a simple array with properties', - type: 'array', - items: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ArrayWithAnyOfProperties: { - description: 'This is a simple array with any of properties', - type: 'array', - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - default: 'test', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - }, - AnyOfAnyAndNull: { - type: 'object', - properties: { - data: { - anyOf: [ - {}, - { - type: 'null', - }, - ], - }, - }, - }, - AnyOfArrays: { - description: 'This is a simple array with any of properties', - type: 'object', - properties: { - results: { - items: { - anyOf: [ - { - type: 'object', - properties: { - foo: { - type: 'string', - }, - }, - }, - { - type: 'object', - properties: { - bar: { - type: 'string', - }, - }, - }, - ], - }, - type: 'array', - }, - }, - }, - DictionaryWithString: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - DictionaryWithReference: { - description: 'This is a string reference', - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - DictionaryWithArray: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - DictionaryWithDictionary: { - description: 'This is a string dictionary', - type: 'object', - additionalProperties: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - DictionaryWithProperties: { - description: 'This is a complex dictionary', - type: 'object', - additionalProperties: { - type: 'object', - properties: { - foo: { - type: 'string', - }, - bar: { - type: 'string', - }, - }, - }, - }, - ModelWithInteger: { - description: 'This is a model with one number property', - type: 'object', - properties: { - prop: { - description: 'This is a simple number property', - type: 'integer', - }, - }, - }, - ModelWithBoolean: { - description: 'This is a model with one boolean property', - type: 'object', - properties: { - prop: { - description: 'This is a simple boolean property', - type: 'boolean', - }, - }, - }, - ModelWithString: { - description: 'This is a model with one string property', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - }, - ModelWithNullableString: { - description: 'This is a model with one string property', - type: 'object', - required: ['nullableRequiredProp1', 'nullableRequiredProp2'], - properties: { - nullableProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableRequiredProp1: { - description: 'This is a simple string property', - type: 'string', - nullable: true, - }, - nullableProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - nullableRequiredProp2: { - description: 'This is a simple string property', - type: ['string', 'null'], - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithEnum: { - description: 'This is a model with one enum', - type: 'object', - properties: { - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - statusCode: { - description: 'These are the HTTP error code enums', - enum: ['100', '200 FOO', '300 FOO_BAR', '400 foo-bar', '500 foo.bar', '600 foo&bar'], - }, - bool: { - description: 'Simple boolean enum', - type: 'boolean', - enum: [true], - }, - }, - }, - ModelWithEnumWithHyphen: { - description: 'This is a model with one enum with escaped name', - type: 'object', - properties: { - 'foo-bar-baz-qux': { - type: 'string', - enum: ['3.0'], - title: 'Foo-Bar-Baz-Qux', - default: '3.0', - }, - }, - }, - ModelWithEnumFromDescription: { - description: 'This is a model with one enum', - type: 'object', - properties: { - test: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - }, - ModelWithNestedEnums: { - description: 'This is a model with nested enums', - type: 'object', - properties: { - dictionaryWithEnum: { - type: 'object', - additionalProperties: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - dictionaryWithEnumFromDescription: { - type: 'object', - additionalProperties: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - arrayWithEnum: { - type: 'array', - items: { - enum: ['Success', 'Warning', 'Error'], - }, - }, - arrayWithDescription: { - type: 'array', - items: { - type: 'integer', - description: 'Success=1,Warning=2,Error=3', - }, - }, - 'foo_bar-enum': { - description: 'This is a simple enum with strings', - enum: ['Success', 'Warning', 'Error', 'ØÆÅ字符串'], - }, - }, - }, - ModelWithReference: { - description: 'This is a model with one property containing a reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithProperties', - }, - }, - }, - ModelWithArrayReadOnlyAndWriteOnly: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithReadOnlyAndWriteOnly', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithArray: { - description: 'This is a model with one property containing an array', - type: 'object', - properties: { - prop: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - propWithFile: { - type: 'array', - items: { - type: 'file', - }, - }, - propWithNumber: { - type: 'array', - items: { - type: 'number', - }, - }, - }, - }, - ModelWithDictionary: { - description: 'This is a model with one property containing a dictionary', - type: 'object', - properties: { - prop: { - type: 'object', - additionalProperties: { - type: 'string', - }, - }, - }, - }, - DeprecatedModel: { - deprecated: true, - description: 'This is a deprecated model with a deprecated property', - type: 'object', - properties: { - prop: { - deprecated: true, - description: 'This is a deprecated property', - type: 'string', - }, - }, - }, - ModelWithCircularReference: { - description: 'This is a model with one property containing a circular reference', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithCircularReference', - }, - }, - }, - CompositionWithOneOf: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAnonymous: { - description: - "This is a model with one property with a 'one of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - oneOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - 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', - properties: { - propA: { - type: 'object', - anyOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAnonymous: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - description: 'Anonymous object type', - type: 'object', - properties: { - propA: { - type: 'string', - }, - }, - }, - { - description: 'Anonymous string type', - type: 'string', - }, - { - description: 'Anonymous integer type', - type: 'integer', - }, - ], - }, - }, - }, - CompositionWithNestedAnyAndTypeNull: { - description: "This is a model with nested 'any of' property with a type null", - type: 'object', - properties: { - propA: { - type: 'object', - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - type: 'null', - }, - ], - }, - type: 'array', - }, - ], - }, - }, - }, - Enum1: { - enum: ['Bird', 'Dog'], - type: 'string', - }, - ConstValue: { - type: 'string', - const: 'ConstValue', - }, - CompositionWithNestedAnyOfAndNull: { - description: - "This is a model with one property with a 'any of' relationship where the options are not $ref", - type: 'object', - properties: { - propA: { - anyOf: [ - { - items: { - anyOf: [ - { - $ref: '#/components/schemas/Enum1', - }, - { - $ref: '#/components/schemas/ConstValue', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - title: 'Scopes', - }, - }, - }, - CompositionWithOneOfAndNullable: { - description: "This is a model with one property with a 'one of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - oneOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleDictionary: { - description: 'This is a model that contains a simple dictionary within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'number', - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndSimpleArrayDictionary: { - description: 'This is a model that contains a dictionary of simple arrays within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - type: 'boolean', - }, - }, - }, - ], - }, - }, - }, - CompositionWithOneOfAndComplexArrayDictionary: { - description: - 'This is a model that contains a dictionary of complex arrays (composited) within composition', - type: 'object', - properties: { - propA: { - oneOf: [ - { - type: 'boolean', - }, - { - type: 'object', - additionalProperties: { - type: 'array', - items: { - oneOf: [ - { - type: 'number', - }, - { - type: 'string', - }, - ], - }, - }, - }, - ], - }, - }, - }, - CompositionWithAllOfAndNullable: { - description: "This is a model with one property with a 'all of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - allOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionWithAnyOfAndNullable: { - description: "This is a model with one property with a 'any of' relationship", - type: 'object', - properties: { - propA: { - nullable: true, - type: 'object', - anyOf: [ - { - type: 'object', - properties: { - boolean: { - type: 'boolean', - }, - }, - }, - { - $ref: '#/components/schemas/ModelWithEnum', - }, - { - $ref: '#/components/schemas/ModelWithArray', - }, - { - $ref: '#/components/schemas/ModelWithDictionary', - }, - ], - }, - }, - }, - CompositionBaseModel: { - description: 'This is a base model with two simple optional properties', - type: 'object', - properties: { - firstName: { - type: 'string', - }, - lastname: { - type: 'string', - }, - }, - }, - CompositionExtendedModel: { - description: 'This is a model that extends the base model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/CompositionBaseModel', - }, - ], - properties: { - age: { - type: 'number', - }, - }, - required: ['firstName', 'lastname', 'age'], - }, - ModelWithProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], - properties: { - required: { - type: 'string', - }, - requiredAndReadOnly: { - type: 'string', - readOnly: true, - }, - requiredAndNullable: { - type: 'string', - nullable: true, - }, - string: { - type: 'string', - }, - number: { - type: 'number', - }, - boolean: { - type: 'boolean', - }, - reference: { - $ref: '#/components/schemas/ModelWithString', - }, - 'property with space': { - type: 'string', - }, - default: { - type: 'string', - }, - try: { - type: 'string', - }, - '@namespace.string': { - type: 'string', - readOnly: true, - }, - '@namespace.integer': { - type: 'integer', - readOnly: true, - }, - }, - }, - ModelWithNestedProperties: { - description: 'This is a model with one nested property', - type: 'object', - required: ['first'], - properties: { - first: { - type: 'object', - required: ['second'], - readOnly: true, - nullable: true, - properties: { - second: { - type: 'object', - required: ['third'], - readOnly: true, - nullable: true, - properties: { - third: { - type: 'string', - required: true, - readOnly: true, - nullable: true, - }, - }, - }, - }, - }, - }, - }, - ModelWithDuplicateProperties: { - description: 'This is a model with duplicated properties', - type: 'object', - properties: { - prop: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelWithOrderedProperties: { - description: 'This is a model with ordered properties', - type: 'object', - properties: { - zebra: { - type: 'string', - }, - apple: { - type: 'string', - }, - hawaii: { - type: 'string', - }, - }, - }, - ModelWithDuplicateImports: { - description: 'This is a model with duplicated imports', - type: 'object', - properties: { - propA: { - $ref: '#/components/schemas/ModelWithString', - }, - propB: { - $ref: '#/components/schemas/ModelWithString', - }, - propC: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ModelThatExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - type: 'object', - properties: { - propExtendsA: { - type: 'string', - }, - propExtendsB: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelThatExtendsExtends: { - description: 'This is a model that extends another model', - type: 'object', - allOf: [ - { - $ref: '#/components/schemas/ModelWithString', - }, - { - $ref: '#/components/schemas/ModelThatExtends', - }, - { - type: 'object', - properties: { - propExtendsC: { - type: 'string', - }, - propExtendsD: { - $ref: '#/components/schemas/ModelWithString', - }, - }, - }, - ], - }, - ModelWithPattern: { - description: 'This is a model that contains a some patterns', - type: 'object', - required: ['key', 'name'], - properties: { - key: { - maxLength: 64, - pattern: '^[a-zA-Z0-9_]*$', - type: 'string', - }, - name: { - maxLength: 255, - type: 'string', - }, - enabled: { - type: 'boolean', - readOnly: true, - }, - modified: { - type: 'string', - format: 'date-time', - readOnly: true, - }, - id: { - type: 'string', - pattern: '^d{2}-d{3}-d{4}$', - }, - text: { - type: 'string', - pattern: '^w+$', - }, - patternWithSingleQuotes: { - type: 'string', - pattern: "^[a-zA-Z0-9']*$", - }, - patternWithNewline: { - type: 'string', - pattern: `aaa -bbb`, - }, - patternWithBacktick: { - type: 'string', - pattern: 'aaa`bbb', - }, - }, - }, - File: { - required: ['mime'], - type: 'object', - properties: { - id: { - title: 'Id', - type: 'string', - readOnly: true, - minLength: 1, - }, - updated_at: { - title: 'Updated at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - created_at: { - title: 'Created at', - type: 'string', - format: 'date-time', - readOnly: true, - }, - mime: { - title: 'Mime', - type: 'string', - maxLength: 24, - minLength: 1, - }, - file: { - title: 'File', - type: 'string', - readOnly: true, - format: 'uri', - }, - }, - }, - default: { - type: 'object', - properties: { - name: { - type: 'string', - }, - }, - }, - Pageable: { - type: 'object', - properties: { - page: { - minimum: 0, - type: 'integer', - format: 'int32', - default: 0, - }, - size: { - minimum: 1, - type: 'integer', - format: 'int32', - }, - sort: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - FreeFormObjectWithoutAdditionalProperties: { - description: 'This is a free-form object without additionalProperties.', - type: 'object', - }, - FreeFormObjectWithAdditionalPropertiesEqTrue: { - description: 'This is a free-form object with additionalProperties: true.', - type: 'object', - additionalProperties: true, - }, - FreeFormObjectWithAdditionalPropertiesEqEmptyObject: { - description: 'This is a free-form object with additionalProperties: {}.', - type: 'object', - additionalProperties: {}, - }, - ModelWithConst: { - type: 'object', - properties: { - String: { - const: 'String', - }, - number: { - const: 0, - }, - null: { - const: null, - }, - withType: { - type: 'string', - const: 'Some string', - }, - }, - }, - ModelWithAdditionalPropertiesEqTrue: { - description: 'This is a model with one property and additionalProperties: true', - type: 'object', - properties: { - prop: { - description: 'This is a simple string property', - type: 'string', - }, - }, - additionalProperties: true, - }, - NestedAnyOfArraysNullable: { - properties: { - nullableArray: { - anyOf: [ - { - items: { - anyOf: [ - { - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - type: 'array', - }, - { - type: 'null', - }, - ], - }, - }, - type: 'object', - }, - CompositionWithOneOfAndProperties: { - type: 'object', - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - $ref: '#/components/parameters/SimpleParameter', - }, - }, - additionalProperties: false, - }, - { - type: 'object', - required: ['bar'], - properties: { - bar: { - $ref: '#/components/schemas/NonAsciiString%C3%A6%C3%B8%C3%A5%C3%86%C3%98%C3%85%C3%B6%C3%B4%C3%AA%C3%8A%E5%AD%97%E7%AC%A6%E4%B8%B2', - }, - }, - additionalProperties: false, - }, - ], - required: ['baz', 'qux'], - properties: { - baz: { - type: 'integer', - format: 'uint16', - minimum: 0, - nullable: true, - }, - qux: { - type: 'integer', - format: 'uint8', - minimum: 0, - }, - }, - }, - NullableObject: { - type: 'object', - nullable: true, - description: 'An object that can be null', - properties: { - foo: { - type: 'string', - }, - }, - default: null, - }, - ModelWithNullableObject: { - type: 'object', - properties: { - data: { - $ref: '#/components/schemas/NullableObject', - }, - }, - }, - ModelWithOneOfEnum: { - oneOf: [ - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Bar'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Baz'], - }, - }, - }, - { - type: 'object', - required: ['foo'], - properties: { - foo: { - type: 'string', - enum: ['Qux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'string', - format: 'date-time', - }, - foo: { - type: 'string', - enum: ['Quux'], - }, - }, - }, - { - type: 'object', - required: ['content', 'foo'], - properties: { - content: { - type: 'array', - items: [ - { - type: 'string', - format: 'date-time', - }, - { - type: 'string', - }, - ], - maxItems: 2, - minItems: 2, - }, - foo: { - type: 'string', - enum: ['Corge'], - }, - }, - }, - ], - }, - ModelWithNestedArrayEnumsDataFoo: { - enum: ['foo', 'bar'], - type: 'string', - }, - ModelWithNestedArrayEnumsDataBar: { - enum: ['baz', 'qux'], - type: 'string', - }, - ModelWithNestedArrayEnumsData: { - type: 'object', - properties: { - foo: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - }, - bar: { - type: 'array', - items: { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataBar', - }, - }, - }, - }, - ModelWithNestedArrayEnums: { - type: 'object', - properties: { - array_strings: { - type: 'array', - items: { - type: 'string', - }, - }, - data: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsData', - }, - ], - }, - }, - }, - ModelWithNestedCompositionEnums: { - type: 'object', - properties: { - foo: { - allOf: [ - { - $ref: '#/components/schemas/ModelWithNestedArrayEnumsDataFoo', - }, - ], - }, - }, - }, - ModelWithReadOnlyAndWriteOnly: { - type: 'object', - required: ['foo', 'bar', 'baz'], - properties: { - foo: { - type: 'string', - }, - bar: { - readOnly: true, - type: 'string', - }, - baz: { - type: 'string', - writeOnly: true, - }, - }, - }, - }, + description: 'This is a reusable parameter', + name: 'parameter', + in: 'query', + required: false, + schema: { + type: 'string', }, } as const; From 71e6d5b88b7f91443ff2053836d3a15c8fffaf9c Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 8 Apr 2024 03:49:32 +0100 Subject: [PATCH 3/3] docs: add release notes --- .changeset/giant-sloths-repair.md | 5 +++++ packages/openapi-ts/src/utils/write/services.ts | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/giant-sloths-repair.md diff --git a/.changeset/giant-sloths-repair.md b/.changeset/giant-sloths-repair.md new file mode 100644 index 000000000..88567b300 --- /dev/null +++ b/.changeset/giant-sloths-repair.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": minor +--- + +feat: export schemas directly from OpenAPI specification (ie. support exporting JSON schemas draft 2020-12 diff --git a/packages/openapi-ts/src/utils/write/services.ts b/packages/openapi-ts/src/utils/write/services.ts index 268507a5c..a1f748286 100644 --- a/packages/openapi-ts/src/utils/write/services.ts +++ b/packages/openapi-ts/src/utils/write/services.ts @@ -4,8 +4,7 @@ import path from 'node:path'; import camelCase from 'camelcase'; import { TypeScriptFile } from '../../compiler'; -import type { OpenApi } from '../../openApi'; -import type { Service } from '../../openApi'; +import type { OpenApi, Service } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { escapeComment } from '../escape';