From c6b044d0bc9dc54cb0eb58d23438f4e1d050cb38 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 4 Sep 2024 06:28:47 +0100 Subject: [PATCH] feat: change schemas name pattern, add schemas.name option --- .changeset/violet-snakes-reply.md | 6 + docs/openapi-ts/migrating.md | 14 + .../src/generate/__tests__/schemas.spec.ts | 56 + packages/openapi-ts/src/generate/schemas.ts | 25 +- packages/openapi-ts/src/types/config.ts | 13 +- .../test/generated/v2/schemas.gen.ts.snap | 108 +- .../v3-schemas-form/schemas.gen.ts.snap | 250 +-- .../v3-schemas-json/schemas.gen.ts.snap | 250 +-- .../generated/v3-schemas-name/index.ts.snap | 2 + .../v3-schemas-name/schemas.gen.ts.snap | 1990 +++++++++++++++++ packages/openapi-ts/test/index.spec.ts | 13 + 11 files changed, 2419 insertions(+), 308 deletions(-) create mode 100644 .changeset/violet-snakes-reply.md create mode 100644 packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/index.ts.snap create mode 100644 packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/schemas.gen.ts.snap diff --git a/.changeset/violet-snakes-reply.md b/.changeset/violet-snakes-reply.md new file mode 100644 index 000000000..5531b95df --- /dev/null +++ b/.changeset/violet-snakes-reply.md @@ -0,0 +1,6 @@ +--- +'@hey-api/openapi-ts': minor +'@hey-api/docs': minor +--- + +feat: change schemas name pattern, add schemas.name option diff --git a/docs/openapi-ts/migrating.md b/docs/openapi-ts/migrating.md index cc36b511a..d50910f42 100644 --- a/docs/openapi-ts/migrating.md +++ b/docs/openapi-ts/migrating.md @@ -52,6 +52,20 @@ This config option is deprecated and will be removed. ## v0.53.0 +### Changed schemas name pattern + +Previously, generated schemas would have their definition names prefixed with `$`. This was problematic when using them with Svelte due to reserved keyword conflicts. The new naming pattern for schemas suffixes their definition names with `Schema`. You can continue using the previous pattern by setting the `schemas.name` configuration option. + +```js +export default { + input: 'path/to/openapi.json', + output: 'src/client', + schemas: { + name: (name) => `$${name}`, // [!code ++] + }, +}; +``` + ### Renamed legacy clients Legacy clients were renamed to signal they are deprecated more clearly. To continue using legacy clients, you will need to update your configuration and prefix them with `legacy/`. diff --git a/packages/openapi-ts/src/generate/__tests__/schemas.spec.ts b/packages/openapi-ts/src/generate/__tests__/schemas.spec.ts index c1cb28e4e..6792cf83c 100644 --- a/packages/openapi-ts/src/generate/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/generate/__tests__/schemas.spec.ts @@ -3,6 +3,7 @@ import path from 'node:path'; import { describe, expect, it, vi } from 'vitest'; +import type { OpenApiSchema } from '../../openApi/v3/interfaces/OpenApiSchema'; import type { Files } from '../../types/utils'; import { setConfig } from '../../utils/config'; import { generateSchemas } from '../schemas'; @@ -58,4 +59,59 @@ describe('generateSchemas', () => { expect.anything(), ); }); + + it('uses custom schema name', async () => { + const nameFn = vi.fn().mockReturnValue('customName'); + + setConfig({ + client: { + name: 'legacy/fetch', + }, + configFile: '', + debug: false, + dryRun: false, + experimental_parser: false, + exportCore: true, + input: '', + name: 'AppClient', + output: { + path: '', + }, + plugins: [], + schemas: { + export: true, + name: nameFn, + }, + services: {}, + types: { + enums: 'javascript', + }, + useOptions: true, + }); + + const schema: OpenApiSchema = { + type: 'object', + }; + + if ('openapi' in openApi) { + openApi.components = { + schemas: { + foo: schema, + }, + }; + } + + const files: Files = {}; + + await generateSchemas({ files, openApi }); + + files.schemas.write(); + + expect(writeFileSync).toHaveBeenCalledWith( + expect.stringContaining(path.resolve('schemas.gen.ts')), + expect.anything(), + ); + + expect(nameFn).toHaveBeenCalledWith('foo', schema); + }); }); diff --git a/packages/openapi-ts/src/generate/schemas.ts b/packages/openapi-ts/src/generate/schemas.ts index 621bc78b2..3a21e7ea7 100644 --- a/packages/openapi-ts/src/generate/schemas.ts +++ b/packages/openapi-ts/src/generate/schemas.ts @@ -1,6 +1,8 @@ import { compiler, TypeScriptFile } from '../compiler'; import type { OpenApi } from '../openApi'; import { ensureValidTypeScriptJavaScriptIdentifier } from '../openApi/common/parser/sanitize'; +import type { OpenApiSchema as OpenApiV2Schema } from '../openApi/v2/interfaces/OpenApiSchema'; +import type { OpenApiSchema as OpenApiV3Schema } from '../openApi/v3/interfaces/OpenApiSchema'; import type { Files } from '../types/utils'; import { getConfig } from '../utils/config'; @@ -52,6 +54,21 @@ const ensureValidSchemaOutput = ( return result; }; +const toSchemaName = ( + name: string, + schema: OpenApiV2Schema | OpenApiV3Schema, +): string => { + const config = getConfig(); + + const validName = ensureValidTypeScriptJavaScriptIdentifier(name); + + if (config.schemas.name) { + return config.schemas.name(validName, schema); + } + + return `${validName}Schema`; +}; + export const generateSchemas = async ({ files, openApi, @@ -70,15 +87,17 @@ export const generateSchemas = async ({ name: 'schemas.ts', }); - const addSchema = (name: string, schema: object) => { - const validName = `$${ensureValidTypeScriptJavaScriptIdentifier(name)}`; + const addSchema = ( + name: string, + schema: OpenApiV2Schema | OpenApiV3Schema, + ) => { const obj = ensureValidSchemaOutput(schema); const expression = compiler.objectExpression({ obj }); const statement = compiler.constVariable({ assertion: 'const', exportConst: true, expression, - name: validName, + name: toSchemaName(name, schema), }); files.schemas.add(statement); }; diff --git a/packages/openapi-ts/src/types/config.ts b/packages/openapi-ts/src/types/config.ts index 1c08031fd..27a596e56 100644 --- a/packages/openapi-ts/src/types/config.ts +++ b/packages/openapi-ts/src/types/config.ts @@ -1,4 +1,6 @@ import type { Operation } from '../openApi'; +import type { OpenApiSchema as OpenApiV2Schema } from '../openApi/v2/interfaces/OpenApiSchema'; +import type { OpenApiSchema as OpenApiV3Schema } from '../openApi/v3/interfaces/OpenApiSchema'; import type { Plugins } from '../plugins/'; import type { ExtractArrayOfObjects } from './utils'; @@ -115,6 +117,15 @@ export interface ClientConfig { * @default true */ export?: boolean; + /** + * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a + * valid JavaScript/TypeScript identifier, e.g. if your schema name is + * "Foo-Bar", `name` value would be "FooBar". + */ + name?: ( + name: string, + schema: OpenApiV2Schema | OpenApiV3Schema, + ) => string; /** * Choose schema type to generate. Select 'form' if you don't want * descriptions to reduce bundle size and you plan to use schemas @@ -162,7 +173,7 @@ export interface ClientConfig { */ include?: string; /** - * Customise the method name of methods within the service. By default, {@link Operation.name} is used. + * Customise the name of methods within the service. By default, {@link Operation.name} is used. */ methodNameBuilder?: (operation: Operation) => string; /** diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.gen.ts.snap index 5960e15a5..e74308467 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.gen.ts.snap @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -export const $CommentWithBreaks = { +export const CommentWithBreaksSchema = { description: `Testing multiline comments in string: First line Second line @@ -8,96 +8,96 @@ Fourth line`, type: 'integer' } as const; -export const $CommentWithBackticks = { +export const CommentWithBackticksSchema = { description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', type: 'integer' } as const; -export const $CommentWithBackticksAndQuotes = { +export const CommentWithBackticksAndQuotesSchema = { description: `Testing backticks and quotes in string: \`backticks\`, 'quotes', "double quotes" and \`\`\`multiple backticks\`\`\` should work`, type: 'integer' } as const; -export const $CommentWithSlashes = { +export const CommentWithSlashesSchema = { description: 'Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work', type: 'integer' } as const; -export const $CommentWithExpressionPlaceholders = { +export const CommentWithExpressionPlaceholdersSchema = { description: 'Testing expression placeholders in string: ${expression} should work', type: 'integer' } as const; -export const $CommentWithQuotes = { +export const CommentWithQuotesSchema = { description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, type: 'integer' } as const; -export const $CommentWithReservedCharacters = { +export const CommentWithReservedCharactersSchema = { description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', type: 'integer' } as const; -export const $SimpleInteger = { +export const SimpleIntegerSchema = { description: 'This is a simple number', type: 'integer' } as const; -export const $SimpleBoolean = { +export const SimpleBooleanSchema = { description: 'This is a simple boolean', type: 'boolean' } as const; -export const $SimpleString = { +export const SimpleStringSchema = { description: 'This is a simple string', type: 'string' } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { +export const NonAsciiStringæøåÆØÅöôêÊ字符串Schema = { description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string' } as const; -export const $SimpleFile = { +export const SimpleFileSchema = { description: 'This is a simple file', type: 'file' } as const; -export const $SimpleReference = { +export const SimpleReferenceSchema = { description: 'This is a simple reference', '$ref': '#/definitions/ModelWithString' } as const; -export const $SimpleStringWithPattern = { +export const SimpleStringWithPatternSchema = { description: 'This is a simple string', type: 'string', maxLength: 64, pattern: '^[a-zA-Z0-9_]*$' } as const; -export const $EnumWithStrings = { +export const EnumWithStringsSchema = { description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'] } as const; -export const $EnumWithNumbers = { +export const EnumWithNumbersSchema = { 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 = { +export const EnumFromDescriptionSchema = { description: 'Success=1,Warning=2,Error=3', type: 'number' } as const; -export const $EnumWithExtensions = { +export const EnumWithExtensionsSchema = { 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 = { +export const ArrayWithNumbersSchema = { description: 'This is a simple array with numbers', type: 'array', items: { @@ -105,7 +105,7 @@ export const $ArrayWithNumbers = { } } as const; -export const $ArrayWithBooleans = { +export const ArrayWithBooleansSchema = { description: 'This is a simple array with booleans', type: 'array', items: { @@ -113,7 +113,7 @@ export const $ArrayWithBooleans = { } } as const; -export const $ArrayWithStrings = { +export const ArrayWithStringsSchema = { description: 'This is a simple array with strings', type: 'array', items: { @@ -121,7 +121,7 @@ export const $ArrayWithStrings = { } } as const; -export const $ArrayWithReferences = { +export const ArrayWithReferencesSchema = { description: 'This is a simple array with references', type: 'array', items: { @@ -129,7 +129,7 @@ export const $ArrayWithReferences = { } } as const; -export const $ArrayWithArray = { +export const ArrayWithArraySchema = { description: 'This is a simple array containing an array', type: 'array', items: { @@ -140,7 +140,7 @@ export const $ArrayWithArray = { } } as const; -export const $ArrayWithProperties = { +export const ArrayWithPropertiesSchema = { description: 'This is a simple array with properties', type: 'array', items: { @@ -156,7 +156,7 @@ export const $ArrayWithProperties = { } } as const; -export const $DictionaryWithString = { +export const DictionaryWithStringSchema = { description: 'This is a string dictionary', type: 'object', additionalProperties: { @@ -164,7 +164,7 @@ export const $DictionaryWithString = { } } as const; -export const $DictionaryWithReference = { +export const DictionaryWithReferenceSchema = { description: 'This is a string reference', type: 'object', additionalProperties: { @@ -172,7 +172,7 @@ export const $DictionaryWithReference = { } } as const; -export const $DictionaryWithArray = { +export const DictionaryWithArraySchema = { description: 'This is a complex dictionary', type: 'object', additionalProperties: { @@ -183,7 +183,7 @@ export const $DictionaryWithArray = { } } as const; -export const $DictionaryWithDictionary = { +export const DictionaryWithDictionarySchema = { description: 'This is a string dictionary', type: 'object', additionalProperties: { @@ -194,7 +194,7 @@ export const $DictionaryWithDictionary = { } } as const; -export const $DictionaryWithProperties = { +export const DictionaryWithPropertiesSchema = { description: 'This is a complex dictionary', type: 'object', additionalProperties: { @@ -210,12 +210,12 @@ export const $DictionaryWithProperties = { } } as const; -export const $Date = { +export const DateSchema = { description: 'This is a type-only model that defines Date as a string', type: 'string' } as const; -export const $ModelWithInteger = { +export const ModelWithIntegerSchema = { description: 'This is a model with one number property', type: 'object', properties: { @@ -226,7 +226,7 @@ export const $ModelWithInteger = { } } as const; -export const $ModelWithBoolean = { +export const ModelWithBooleanSchema = { description: 'This is a model with one boolean property', type: 'object', properties: { @@ -237,7 +237,7 @@ export const $ModelWithBoolean = { } } as const; -export const $ModelWithString = { +export const ModelWithStringSchema = { description: 'This is a model with one string property', type: 'object', properties: { @@ -248,7 +248,7 @@ export const $ModelWithString = { } } as const; -export const $ModelWithStringError = { +export const ModelWithStringErrorSchema = { description: 'This is a model with one string property', type: 'object', properties: { @@ -259,7 +259,7 @@ export const $ModelWithStringError = { } } as const; -export const $ModelWithNullableString = { +export const ModelWithNullableStringSchema = { description: 'This is a model with one string property', type: 'object', required: ['nullableRequiredProp'], @@ -277,7 +277,7 @@ export const $ModelWithNullableString = { } } as const; -export const $ModelWithEnum = { +export const ModelWithEnumSchema = { description: 'This is a model with one enum', type: 'object', properties: { @@ -297,7 +297,7 @@ export const $ModelWithEnum = { } } as const; -export const $ModelWithEnumFromDescription = { +export const ModelWithEnumFromDescriptionSchema = { description: 'This is a model with one enum', type: 'object', properties: { @@ -308,7 +308,7 @@ export const $ModelWithEnumFromDescription = { } } as const; -export const $ModelWithNestedEnums = { +export const ModelWithNestedEnumsSchema = { description: 'This is a model with nested enums', type: 'object', properties: { @@ -341,7 +341,7 @@ export const $ModelWithNestedEnums = { } } as const; -export const $ModelWithReference = { +export const ModelWithReferenceSchema = { description: 'This is a model with one property containing a reference', type: 'object', properties: { @@ -351,7 +351,7 @@ export const $ModelWithReference = { } } as const; -export const $ModelWithArray = { +export const ModelWithArraySchema = { description: 'This is a model with one property containing an array', type: 'object', properties: { @@ -376,7 +376,7 @@ export const $ModelWithArray = { } } as const; -export const $ModelWithDictionary = { +export const ModelWithDictionarySchema = { description: 'This is a model with one property containing a dictionary', type: 'object', properties: { @@ -389,7 +389,7 @@ export const $ModelWithDictionary = { } } as const; -export const $ModelWithCircularReference = { +export const ModelWithCircularReferenceSchema = { description: 'This is a model with one property containing a circular reference', type: 'object', properties: { @@ -399,7 +399,7 @@ export const $ModelWithCircularReference = { } } as const; -export const $ModelWithProperties = { +export const ModelWithPropertiesSchema = { description: 'This is a model with one nested property', type: 'object', required: ['required', 'requiredAndReadOnly'], @@ -443,7 +443,7 @@ export const $ModelWithProperties = { } } as const; -export const $ModelWithNestedProperties = { +export const ModelWithNestedPropertiesSchema = { description: 'This is a model with one nested property', type: 'object', required: ['first'], @@ -469,7 +469,7 @@ export const $ModelWithNestedProperties = { } } as const; -export const $ModelWithDuplicateProperties = { +export const ModelWithDuplicatePropertiesSchema = { description: 'This is a model with duplicated properties', type: 'object', properties: { @@ -479,7 +479,7 @@ export const $ModelWithDuplicateProperties = { } } as const; -export const $ModelWithOrderedProperties = { +export const ModelWithOrderedPropertiesSchema = { description: 'This is a model with ordered properties', type: 'object', properties: { @@ -495,7 +495,7 @@ export const $ModelWithOrderedProperties = { } } as const; -export const $ModelWithDuplicateImports = { +export const ModelWithDuplicateImportsSchema = { description: 'This is a model with duplicated imports', type: 'object', properties: { @@ -511,7 +511,7 @@ export const $ModelWithDuplicateImports = { } } as const; -export const $ModelThatExtends = { +export const ModelThatExtendsSchema = { description: 'This is a model that extends another model', type: 'object', allOf: [ @@ -532,7 +532,7 @@ export const $ModelThatExtends = { ] } as const; -export const $ModelThatExtendsExtends = { +export const ModelThatExtendsExtendsSchema = { description: 'This is a model that extends another model', type: 'object', allOf: [ @@ -556,7 +556,7 @@ export const $ModelThatExtendsExtends = { ] } as const; -export const $default = { +export const defaultSchema = { type: 'object', properties: { name: { @@ -565,7 +565,7 @@ export const $default = { } } as const; -export const $ModelWithPattern = { +export const ModelWithPatternSchema = { description: 'This is a model that contains a some patterns', type: 'object', required: ['key', 'name'], @@ -612,7 +612,7 @@ bbb` } } as const; -export const $parameter_ActivityParams = { +export const parameter_ActivityParamsSchema = { type: 'object', properties: { description: { @@ -633,7 +633,7 @@ export const $parameter_ActivityParams = { } } as const; -export const $response_PostActivityResponse = { +export const response_PostActivityResponseSchema = { type: 'object', properties: { description: { @@ -654,7 +654,7 @@ export const $response_PostActivityResponse = { } } as const; -export const $failure_Failure = { +export const failure_FailureSchema = { type: 'object', properties: { error: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-form/schemas.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-form/schemas.gen.ts.snap index 28b2d53b8..d7d82cf40 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-form/schemas.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-form/schemas.gen.ts.snap @@ -1,113 +1,113 @@ // This file is auto-generated by @hey-api/openapi-ts -export const $_400 = { +export const _400Schema = { type: 'string' } as const; -export const $camelCaseCommentWithBreaks = { +export const camelCaseCommentWithBreaksSchema = { type: 'integer' } as const; -export const $CommentWithBreaks = { +export const CommentWithBreaksSchema = { type: 'integer' } as const; -export const $CommentWithBackticks = { +export const CommentWithBackticksSchema = { type: 'integer' } as const; -export const $CommentWithBackticksAndQuotes = { +export const CommentWithBackticksAndQuotesSchema = { type: 'integer' } as const; -export const $CommentWithSlashes = { +export const CommentWithSlashesSchema = { type: 'integer' } as const; -export const $CommentWithExpressionPlaceholders = { +export const CommentWithExpressionPlaceholdersSchema = { type: 'integer' } as const; -export const $CommentWithQuotes = { +export const CommentWithQuotesSchema = { type: 'integer' } as const; -export const $CommentWithReservedCharacters = { +export const CommentWithReservedCharactersSchema = { type: 'integer' } as const; -export const $SimpleInteger = { +export const SimpleIntegerSchema = { type: 'integer' } as const; -export const $SimpleBoolean = { +export const SimpleBooleanSchema = { type: 'boolean' } as const; -export const $SimpleString = { +export const SimpleStringSchema = { type: 'string' } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { +export const NonAsciiStringæøåÆØÅöôêÊ字符串Schema = { type: 'string' } as const; -export const $SimpleFile = { +export const SimpleFileSchema = { type: 'file' } as const; -export const $SimpleReference = { +export const SimpleReferenceSchema = { '$ref': '#/components/schemas/ModelWithString' } as const; -export const $SimpleStringWithPattern = { +export const SimpleStringWithPatternSchema = { type: 'string', nullable: true, maxLength: 64, pattern: '^[a-zA-Z0-9_]*$' } as const; -export const $EnumWithStrings = { +export const EnumWithStringsSchema = { enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'] } as const; -export const $EnumWithReplacedCharacters = { +export const EnumWithReplacedCharactersSchema = { enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], type: 'string' } as const; -export const $EnumWithNumbers = { +export const EnumWithNumbersSchema = { 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 = { +export const EnumFromDescriptionSchema = { type: 'number' } as const; -export const $EnumWithExtensions = { +export const EnumWithExtensionsSchema = { enum: [200, 400, 500] } as const; -export const $EnumWithXEnumNames = { +export const EnumWithXEnumNamesSchema = { enum: [0, 1, 2] } as const; -export const $ArrayWithNumbers = { +export const ArrayWithNumbersSchema = { type: 'array', items: { type: 'integer' } } as const; -export const $ArrayWithBooleans = { +export const ArrayWithBooleansSchema = { type: 'array', items: { type: 'boolean' } } as const; -export const $ArrayWithStrings = { +export const ArrayWithStringsSchema = { type: 'array', items: { type: 'string' @@ -115,14 +115,14 @@ export const $ArrayWithStrings = { default: ['test'] } as const; -export const $ArrayWithReferences = { +export const ArrayWithReferencesSchema = { type: 'array', items: { '$ref': '#/components/schemas/ModelWithString' } } as const; -export const $ArrayWithArray = { +export const ArrayWithArraySchema = { type: 'array', items: { type: 'array', @@ -132,7 +132,7 @@ export const $ArrayWithArray = { } } as const; -export const $ArrayWithProperties = { +export const ArrayWithPropertiesSchema = { type: 'array', items: { type: 'object', @@ -147,7 +147,7 @@ export const $ArrayWithProperties = { } } as const; -export const $ArrayWithAnyOfProperties = { +export const ArrayWithAnyOfPropertiesSchema = { type: 'array', items: { anyOf: [ @@ -172,7 +172,7 @@ export const $ArrayWithAnyOfProperties = { } } as const; -export const $AnyOfAnyAndNull = { +export const AnyOfAnyAndNullSchema = { type: 'object', properties: { data: { @@ -186,7 +186,7 @@ export const $AnyOfAnyAndNull = { } } as const; -export const $AnyOfArrays = { +export const AnyOfArraysSchema = { type: 'object', properties: { results: { @@ -215,14 +215,14 @@ export const $AnyOfArrays = { } } as const; -export const $DictionaryWithString = { +export const DictionaryWithStringSchema = { type: 'object', additionalProperties: { type: 'string' } } as const; -export const $DictionaryWithPropertiesAndAdditionalProperties = { +export const DictionaryWithPropertiesAndAdditionalPropertiesSchema = { type: 'object', properties: { foo: { @@ -237,14 +237,14 @@ export const $DictionaryWithPropertiesAndAdditionalProperties = { } } as const; -export const $DictionaryWithReference = { +export const DictionaryWithReferenceSchema = { type: 'object', additionalProperties: { '$ref': '#/components/schemas/ModelWithString' } } as const; -export const $DictionaryWithArray = { +export const DictionaryWithArraySchema = { type: 'object', additionalProperties: { type: 'array', @@ -254,7 +254,7 @@ export const $DictionaryWithArray = { } } as const; -export const $DictionaryWithDictionary = { +export const DictionaryWithDictionarySchema = { type: 'object', additionalProperties: { type: 'object', @@ -264,7 +264,7 @@ export const $DictionaryWithDictionary = { } } as const; -export const $DictionaryWithProperties = { +export const DictionaryWithPropertiesSchema = { type: 'object', additionalProperties: { type: 'object', @@ -279,7 +279,7 @@ export const $DictionaryWithProperties = { } } as const; -export const $ModelWithInteger = { +export const ModelWithIntegerSchema = { type: 'object', properties: { prop: { @@ -288,7 +288,7 @@ export const $ModelWithInteger = { } } as const; -export const $ModelWithBoolean = { +export const ModelWithBooleanSchema = { type: 'object', properties: { prop: { @@ -297,7 +297,7 @@ export const $ModelWithBoolean = { } } as const; -export const $ModelWithString = { +export const ModelWithStringSchema = { type: 'object', properties: { prop: { @@ -306,7 +306,7 @@ export const $ModelWithString = { } } as const; -export const $ModelWithStringError = { +export const ModelWithStringErrorSchema = { type: 'object', properties: { prop: { @@ -315,11 +315,11 @@ export const $ModelWithStringError = { } } as const; -export const $Model_From_Zendesk = { +export const Model_From_ZendeskSchema = { type: 'string' } as const; -export const $ModelWithNullableString = { +export const ModelWithNullableStringSchema = { type: 'object', required: ['nullableRequiredProp1', 'nullableRequiredProp2'], properties: { @@ -343,7 +343,7 @@ export const $ModelWithNullableString = { } } as const; -export const $ModelWithEnum = { +export const ModelWithEnumSchema = { type: 'object', properties: { 'foo_bar-enum': { @@ -359,7 +359,7 @@ export const $ModelWithEnum = { } } as const; -export const $ModelWithEnumWithHyphen = { +export const ModelWithEnumWithHyphenSchema = { type: 'object', properties: { 'foo-bar-baz-qux': { @@ -370,7 +370,7 @@ export const $ModelWithEnumWithHyphen = { } } as const; -export const $ModelWithEnumFromDescription = { +export const ModelWithEnumFromDescriptionSchema = { type: 'object', properties: { test: { @@ -379,7 +379,7 @@ export const $ModelWithEnumFromDescription = { } } as const; -export const $ModelWithNestedEnums = { +export const ModelWithNestedEnumsSchema = { type: 'object', properties: { dictionaryWithEnum: { @@ -412,7 +412,7 @@ export const $ModelWithNestedEnums = { } } as const; -export const $ModelWithReference = { +export const ModelWithReferenceSchema = { type: 'object', properties: { prop: { @@ -421,7 +421,7 @@ export const $ModelWithReference = { } } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly = { +export const ModelWithArrayReadOnlyAndWriteOnlySchema = { type: 'object', properties: { prop: { @@ -445,7 +445,7 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } } as const; -export const $ModelWithArray = { +export const ModelWithArraySchema = { type: 'object', properties: { prop: { @@ -469,7 +469,7 @@ export const $ModelWithArray = { } } as const; -export const $ModelWithDictionary = { +export const ModelWithDictionarySchema = { type: 'object', properties: { prop: { @@ -481,7 +481,7 @@ export const $ModelWithDictionary = { } } as const; -export const $DeprecatedModel = { +export const DeprecatedModelSchema = { deprecated: true, type: 'object', properties: { @@ -492,7 +492,7 @@ export const $DeprecatedModel = { } } as const; -export const $ModelWithCircularReference = { +export const ModelWithCircularReferenceSchema = { type: 'object', properties: { prop: { @@ -501,7 +501,7 @@ export const $ModelWithCircularReference = { } } as const; -export const $CompositionWithOneOf = { +export const CompositionWithOneOfSchema = { type: 'object', properties: { propA: { @@ -524,7 +524,7 @@ export const $CompositionWithOneOf = { } } as const; -export const $CompositionWithOneOfAnonymous = { +export const CompositionWithOneOfAnonymousSchema = { type: 'object', properties: { propA: { @@ -549,7 +549,7 @@ export const $CompositionWithOneOfAnonymous = { } } as const; -export const $ModelCircle = { +export const ModelCircleSchema = { type: 'object', required: ['kind'], properties: { @@ -562,7 +562,7 @@ export const $ModelCircle = { } } as const; -export const $ModelSquare = { +export const ModelSquareSchema = { type: 'object', required: ['kind'], properties: { @@ -575,7 +575,7 @@ export const $ModelSquare = { } } as const; -export const $CompositionWithOneOfDiscriminator = { +export const CompositionWithOneOfDiscriminatorSchema = { type: 'object', oneOf: [ { @@ -594,7 +594,7 @@ export const $CompositionWithOneOfDiscriminator = { } } as const; -export const $CompositionWithAnyOf = { +export const CompositionWithAnyOfSchema = { type: 'object', properties: { propA: { @@ -617,7 +617,7 @@ export const $CompositionWithAnyOf = { } } as const; -export const $CompositionWithAnyOfAnonymous = { +export const CompositionWithAnyOfAnonymousSchema = { type: 'object', properties: { propA: { @@ -642,7 +642,7 @@ export const $CompositionWithAnyOfAnonymous = { } } as const; -export const $CompositionWithNestedAnyAndTypeNull = { +export const CompositionWithNestedAnyAndTypeNullSchema = { type: 'object', properties: { propA: { @@ -679,17 +679,17 @@ export const $CompositionWithNestedAnyAndTypeNull = { } } as const; -export const $_3e_num_1Период = { +export const _3e_num_1ПериодSchema = { enum: ['Bird', 'Dog'], type: 'string' } as const; -export const $ConstValue = { +export const ConstValueSchema = { type: 'string', const: 'ConstValue' } as const; -export const $CompositionWithNestedAnyOfAndNull = { +export const CompositionWithNestedAnyOfAndNullSchema = { type: 'object', properties: { propA: { @@ -715,7 +715,7 @@ export const $CompositionWithNestedAnyOfAndNull = { } } as const; -export const $CompositionWithOneOfAndNullable = { +export const CompositionWithOneOfAndNullableSchema = { type: 'object', properties: { propA: { @@ -744,7 +744,7 @@ export const $CompositionWithOneOfAndNullable = { } } as const; -export const $CompositionWithOneOfAndSimpleDictionary = { +export const CompositionWithOneOfAndSimpleDictionarySchema = { type: 'object', properties: { propA: { @@ -763,7 +763,7 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary = { +export const CompositionWithOneOfAndSimpleArrayDictionarySchema = { type: 'object', properties: { propA: { @@ -785,7 +785,7 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary = { +export const CompositionWithOneOfAndComplexArrayDictionarySchema = { type: 'object', properties: { propA: { @@ -814,7 +814,7 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } } as const; -export const $CompositionWithAllOfAndNullable = { +export const CompositionWithAllOfAndNullableSchema = { type: 'object', properties: { propA: { @@ -843,7 +843,7 @@ export const $CompositionWithAllOfAndNullable = { } } as const; -export const $CompositionWithAnyOfAndNullable = { +export const CompositionWithAnyOfAndNullableSchema = { type: 'object', properties: { propA: { @@ -872,7 +872,7 @@ export const $CompositionWithAnyOfAndNullable = { } } as const; -export const $CompositionBaseModel = { +export const CompositionBaseModelSchema = { type: 'object', properties: { firstName: { @@ -884,7 +884,7 @@ export const $CompositionBaseModel = { } } as const; -export const $CompositionExtendedModel = { +export const CompositionExtendedModelSchema = { type: 'object', allOf: [ { @@ -899,7 +899,7 @@ export const $CompositionExtendedModel = { required: ['firstName', 'lastname', 'age'] } as const; -export const $ModelWithProperties = { +export const ModelWithPropertiesSchema = { type: 'object', required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], properties: { @@ -946,7 +946,7 @@ export const $ModelWithProperties = { } } as const; -export const $ModelWithNestedProperties = { +export const ModelWithNestedPropertiesSchema = { type: 'object', required: ['first'], properties: { @@ -975,7 +975,7 @@ export const $ModelWithNestedProperties = { } } as const; -export const $ModelWithDuplicateProperties = { +export const ModelWithDuplicatePropertiesSchema = { type: 'object', properties: { prop: { @@ -984,7 +984,7 @@ export const $ModelWithDuplicateProperties = { } } as const; -export const $ModelWithOrderedProperties = { +export const ModelWithOrderedPropertiesSchema = { type: 'object', properties: { zebra: { @@ -999,7 +999,7 @@ export const $ModelWithOrderedProperties = { } } as const; -export const $ModelWithDuplicateImports = { +export const ModelWithDuplicateImportsSchema = { type: 'object', properties: { propA: { @@ -1014,7 +1014,7 @@ export const $ModelWithDuplicateImports = { } } as const; -export const $ModelThatExtends = { +export const ModelThatExtendsSchema = { type: 'object', allOf: [ { @@ -1034,7 +1034,7 @@ export const $ModelThatExtends = { ] } as const; -export const $ModelThatExtendsExtends = { +export const ModelThatExtendsExtendsSchema = { type: 'object', allOf: [ { @@ -1057,7 +1057,7 @@ export const $ModelThatExtendsExtends = { ] } as const; -export const $ModelWithPattern = { +export const ModelWithPatternSchema = { type: 'object', required: ['key', 'name'], properties: { @@ -1103,7 +1103,7 @@ bbb` } } as const; -export const $File = { +export const FileSchema = { required: ['mime'], type: 'object', properties: { @@ -1135,7 +1135,7 @@ export const $File = { } } as const; -export const $default = { +export const defaultSchema = { type: 'object', properties: { name: { @@ -1144,7 +1144,7 @@ export const $default = { } } as const; -export const $Pageable = { +export const PageableSchema = { type: 'object', properties: { page: { @@ -1167,21 +1167,21 @@ export const $Pageable = { } } as const; -export const $FreeFormObjectWithoutAdditionalProperties = { +export const FreeFormObjectWithoutAdditionalPropertiesSchema = { type: 'object' } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { +export const FreeFormObjectWithAdditionalPropertiesEqTrueSchema = { type: 'object', additionalProperties: true } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { +export const FreeFormObjectWithAdditionalPropertiesEqEmptyObjectSchema = { type: 'object', additionalProperties: {} } as const; -export const $ModelWithConst = { +export const ModelWithConstSchema = { type: 'object', properties: { String: { @@ -1200,7 +1200,7 @@ export const $ModelWithConst = { } } as const; -export const $ModelWithAdditionalPropertiesEqTrue = { +export const ModelWithAdditionalPropertiesEqTrueSchema = { type: 'object', properties: { prop: { @@ -1210,7 +1210,7 @@ export const $ModelWithAdditionalPropertiesEqTrue = { additionalProperties: true } as const; -export const $NestedAnyOfArraysNullable = { +export const NestedAnyOfArraysNullableSchema = { properties: { nullableArray: { anyOf: [ @@ -1236,7 +1236,7 @@ export const $NestedAnyOfArraysNullable = { type: 'object' } as const; -export const $CompositionWithOneOfAndProperties = { +export const CompositionWithOneOfAndPropertiesSchema = { type: 'object', oneOf: [ { @@ -1276,7 +1276,7 @@ export const $CompositionWithOneOfAndProperties = { } } as const; -export const $NullableObject = { +export const NullableObjectSchema = { type: ['object', 'null'], properties: { foo: { @@ -1286,11 +1286,11 @@ export const $NullableObject = { default: null } as const; -export const $CharactersInDescription = { +export const CharactersInDescriptionSchema = { type: 'string' } as const; -export const $ModelWithNullableObject = { +export const ModelWithNullableObjectSchema = { type: 'object', properties: { data: { @@ -1299,7 +1299,7 @@ export const $ModelWithNullableObject = { } } as const; -export const $ModelWithOneOfEnum = { +export const ModelWithOneOfEnumSchema = { oneOf: [ { type: 'object', @@ -1372,17 +1372,17 @@ export const $ModelWithOneOfEnum = { ] } as const; -export const $ModelWithNestedArrayEnumsDataFoo = { +export const ModelWithNestedArrayEnumsDataFooSchema = { enum: ['foo', 'bar'], type: 'string' } as const; -export const $ModelWithNestedArrayEnumsDataBar = { +export const ModelWithNestedArrayEnumsDataBarSchema = { enum: ['baz', 'qux'], type: 'string' } as const; -export const $ModelWithNestedArrayEnumsData = { +export const ModelWithNestedArrayEnumsDataSchema = { type: 'object', properties: { foo: { @@ -1400,7 +1400,7 @@ export const $ModelWithNestedArrayEnumsData = { } } as const; -export const $ModelWithNestedArrayEnums = { +export const ModelWithNestedArrayEnumsSchema = { type: 'object', properties: { array_strings: { @@ -1419,7 +1419,7 @@ export const $ModelWithNestedArrayEnums = { } } as const; -export const $ModelWithNestedCompositionEnums = { +export const ModelWithNestedCompositionEnumsSchema = { type: 'object', properties: { foo: { @@ -1432,7 +1432,7 @@ export const $ModelWithNestedCompositionEnums = { } } as const; -export const $ModelWithReadOnlyAndWriteOnly = { +export const ModelWithReadOnlyAndWriteOnlySchema = { type: 'object', required: ['foo', 'bar', 'baz'], properties: { @@ -1450,7 +1450,7 @@ export const $ModelWithReadOnlyAndWriteOnly = { } } as const; -export const $ModelWithConstantSizeArray = { +export const ModelWithConstantSizeArraySchema = { type: 'array', items: { type: 'number' @@ -1459,7 +1459,7 @@ export const $ModelWithConstantSizeArray = { maxItems: 2 } as const; -export const $ModelWithAnyOfConstantSizeArray = { +export const ModelWithAnyOfConstantSizeArraySchema = { type: 'array', items: { oneOf: [ @@ -1475,7 +1475,7 @@ export const $ModelWithAnyOfConstantSizeArray = { maxItems: 3 } as const; -export const $ModelWithPrefixItemsConstantSizeArray = { +export const ModelWithPrefixItemsConstantSizeArraySchema = { type: 'array', prefixItems: [ { @@ -1497,7 +1497,7 @@ export const $ModelWithPrefixItemsConstantSizeArray = { ] } as const; -export const $ModelWithAnyOfConstantSizeArrayNullable = { +export const ModelWithAnyOfConstantSizeArrayNullableSchema = { type: ['array'], items: { oneOf: [ @@ -1514,7 +1514,7 @@ export const $ModelWithAnyOfConstantSizeArrayNullable = { maxItems: 3 } as const; -export const $ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = { +export const ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsSchema = { type: 'array', items: { oneOf: [ @@ -1530,7 +1530,7 @@ export const $ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = { maxItems: 2 } as const; -export const $ModelWithAnyOfConstantSizeArrayAndIntersect = { +export const ModelWithAnyOfConstantSizeArrayAndIntersectSchema = { type: 'array', items: { allOf: [ @@ -1546,7 +1546,7 @@ export const $ModelWithAnyOfConstantSizeArrayAndIntersect = { maxItems: 2 } as const; -export const $ModelWithNumericEnumUnion = { +export const ModelWithNumericEnumUnionSchema = { type: 'object', properties: { value: { @@ -1556,7 +1556,7 @@ export const $ModelWithNumericEnumUnion = { } } as const; -export const $ModelWithBackticksInDescription = { +export const ModelWithBackticksInDescriptionSchema = { type: 'object', properties: { template: { @@ -1565,7 +1565,7 @@ export const $ModelWithBackticksInDescription = { } } as const; -export const $ModelWithOneOfAndProperties = { +export const ModelWithOneOfAndPropertiesSchema = { type: 'object', oneOf: [ { @@ -1591,31 +1591,31 @@ export const $ModelWithOneOfAndProperties = { } } as const; -export const $ParameterSimpleParameterUnused = { +export const ParameterSimpleParameterUnusedSchema = { type: 'string' } as const; -export const $PostServiceWithEmptyTagResponse = { +export const PostServiceWithEmptyTagResponseSchema = { type: 'string' } as const; -export const $PostServiceWithEmptyTagResponse2 = { +export const PostServiceWithEmptyTagResponse2Schema = { type: 'string' } as const; -export const $DeleteFooData = { +export const DeleteFooDataSchema = { type: 'string' } as const; -export const $DeleteFooData2 = { +export const DeleteFooData2Schema = { type: 'string' } as const; -export const $import = { +export const importSchema = { type: 'string' } as const; -export const $SchemaWithFormRestrictedKeys = { +export const SchemaWithFormRestrictedKeysSchema = { properties: { description: { type: 'string' @@ -1680,7 +1680,7 @@ export const $SchemaWithFormRestrictedKeys = { } } as const; -export const $io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { +export const io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptionsSchema = { properties: { preconditions: { allOf: [ @@ -1693,7 +1693,7 @@ export const $io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { type: 'object' } as const; -export const $io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { +export const io_k8s_apimachinery_pkg_apis_meta_v1_PreconditionsSchema = { properties: { resourceVersion: { type: 'string' @@ -1705,7 +1705,7 @@ export const $io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { type: 'object' } as const; -export const $AdditionalPropertiesUnknownIssue = { +export const AdditionalPropertiesUnknownIssueSchema = { type: 'object', properties: {}, additionalProperties: { @@ -1720,7 +1720,7 @@ export const $AdditionalPropertiesUnknownIssue = { } } as const; -export const $AdditionalPropertiesUnknownIssue2 = { +export const AdditionalPropertiesUnknownIssue2Schema = { type: 'object', additionalProperties: { anyOf: [ @@ -1734,7 +1734,7 @@ export const $AdditionalPropertiesUnknownIssue2 = { } } as const; -export const $AdditionalPropertiesUnknownIssue3 = { +export const AdditionalPropertiesUnknownIssue3Schema = { type: 'object', allOf: [ { @@ -1754,7 +1754,7 @@ export const $AdditionalPropertiesUnknownIssue3 = { ] } as const; -export const $AdditionalPropertiesIntegerIssue = { +export const AdditionalPropertiesIntegerIssueSchema = { type: 'object', required: ['value'], properties: { @@ -1767,7 +1767,7 @@ export const $AdditionalPropertiesIntegerIssue = { } } as const; -export const $OneOfAllOfIssue = { +export const OneOfAllOfIssueSchema = { oneOf: [ { allOf: [ @@ -1792,7 +1792,7 @@ export const $OneOfAllOfIssue = { ] } as const; -export const $Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { +export const Generic_Schema_Duplicate_Issue_1_System_Boolean_Schema = { type: 'object', properties: { item: { @@ -1810,7 +1810,7 @@ export const $Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { additionalProperties: false } as const; -export const $Generic_Schema_Duplicate_Issue_1_System_String_ = { +export const Generic_Schema_Duplicate_Issue_1_System_String_Schema = { type: 'object', properties: { item: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-json/schemas.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-json/schemas.gen.ts.snap index d5f71370e..206d85871 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-json/schemas.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-json/schemas.gen.ts.snap @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -export const $_400 = { +export const _400Schema = { description: 'Model with number-only name', type: 'string' } as const; -export const $camelCaseCommentWithBreaks = { +export const camelCaseCommentWithBreaksSchema = { description: `Testing multiline comments in string: First line Second line @@ -13,7 +13,7 @@ Fourth line`, type: 'integer' } as const; -export const $CommentWithBreaks = { +export const CommentWithBreaksSchema = { description: `Testing multiline comments in string: First line Second line @@ -21,67 +21,67 @@ Fourth line`, type: 'integer' } as const; -export const $CommentWithBackticks = { +export const CommentWithBackticksSchema = { description: 'Testing backticks in string: `backticks` and ```multiple backticks``` should work', type: 'integer' } as const; -export const $CommentWithBackticksAndQuotes = { +export const CommentWithBackticksAndQuotesSchema = { description: `Testing backticks and quotes in string: \`backticks\`, 'quotes', "double quotes" and \`\`\`multiple backticks\`\`\` should work`, type: 'integer' } as const; -export const $CommentWithSlashes = { +export const CommentWithSlashesSchema = { description: 'Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work', type: 'integer' } as const; -export const $CommentWithExpressionPlaceholders = { +export const CommentWithExpressionPlaceholdersSchema = { description: 'Testing expression placeholders in string: ${expression} should work', type: 'integer' } as const; -export const $CommentWithQuotes = { +export const CommentWithQuotesSchema = { description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, type: 'integer' } as const; -export const $CommentWithReservedCharacters = { +export const CommentWithReservedCharactersSchema = { description: 'Testing reserved characters in string: /* inline */ and /** inline **/ should work', type: 'integer' } as const; -export const $SimpleInteger = { +export const SimpleIntegerSchema = { description: 'This is a simple number', type: 'integer' } as const; -export const $SimpleBoolean = { +export const SimpleBooleanSchema = { description: 'This is a simple boolean', type: 'boolean' } as const; -export const $SimpleString = { +export const SimpleStringSchema = { description: 'This is a simple string', type: 'string' } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { +export const NonAsciiStringæøåÆØÅöôêÊ字符串Schema = { description: 'A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)', type: 'string' } as const; -export const $SimpleFile = { +export const SimpleFileSchema = { description: 'This is a simple file', type: 'file' } as const; -export const $SimpleReference = { +export const SimpleReferenceSchema = { description: 'This is a simple reference', '$ref': '#/components/schemas/ModelWithString' } as const; -export const $SimpleStringWithPattern = { +export const SimpleStringWithPatternSchema = { description: 'This is a simple string', type: 'string', nullable: true, @@ -89,40 +89,40 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$' } as const; -export const $EnumWithStrings = { +export const EnumWithStringsSchema = { description: 'This is a simple enum with strings', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'] } as const; -export const $EnumWithReplacedCharacters = { +export const EnumWithReplacedCharactersSchema = { enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], type: 'string' } as const; -export const $EnumWithNumbers = { +export const EnumWithNumbersSchema = { 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 = { +export const EnumFromDescriptionSchema = { description: 'Success=1,Warning=2,Error=3', type: 'number' } as const; -export const $EnumWithExtensions = { +export const EnumWithExtensionsSchema = { 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 $EnumWithXEnumNames = { +export const EnumWithXEnumNamesSchema = { enum: [0, 1, 2], 'x-enumNames': ['zero', 'one', 'two'] } as const; -export const $ArrayWithNumbers = { +export const ArrayWithNumbersSchema = { description: 'This is a simple array with numbers', type: 'array', items: { @@ -130,7 +130,7 @@ export const $ArrayWithNumbers = { } } as const; -export const $ArrayWithBooleans = { +export const ArrayWithBooleansSchema = { description: 'This is a simple array with booleans', type: 'array', items: { @@ -138,7 +138,7 @@ export const $ArrayWithBooleans = { } } as const; -export const $ArrayWithStrings = { +export const ArrayWithStringsSchema = { description: 'This is a simple array with strings', type: 'array', items: { @@ -147,7 +147,7 @@ export const $ArrayWithStrings = { default: ['test'] } as const; -export const $ArrayWithReferences = { +export const ArrayWithReferencesSchema = { description: 'This is a simple array with references', type: 'array', items: { @@ -155,7 +155,7 @@ export const $ArrayWithReferences = { } } as const; -export const $ArrayWithArray = { +export const ArrayWithArraySchema = { description: 'This is a simple array containing an array', type: 'array', items: { @@ -166,7 +166,7 @@ export const $ArrayWithArray = { } } as const; -export const $ArrayWithProperties = { +export const ArrayWithPropertiesSchema = { description: 'This is a simple array with properties', type: 'array', items: { @@ -182,7 +182,7 @@ export const $ArrayWithProperties = { } } as const; -export const $ArrayWithAnyOfProperties = { +export const ArrayWithAnyOfPropertiesSchema = { description: 'This is a simple array with any of properties', type: 'array', items: { @@ -208,7 +208,7 @@ export const $ArrayWithAnyOfProperties = { } } as const; -export const $AnyOfAnyAndNull = { +export const AnyOfAnyAndNullSchema = { type: 'object', properties: { data: { @@ -222,7 +222,7 @@ export const $AnyOfAnyAndNull = { } } as const; -export const $AnyOfArrays = { +export const AnyOfArraysSchema = { description: 'This is a simple array with any of properties', type: 'object', properties: { @@ -252,7 +252,7 @@ export const $AnyOfArrays = { } } as const; -export const $DictionaryWithString = { +export const DictionaryWithStringSchema = { description: 'This is a string dictionary', type: 'object', additionalProperties: { @@ -260,7 +260,7 @@ export const $DictionaryWithString = { } } as const; -export const $DictionaryWithPropertiesAndAdditionalProperties = { +export const DictionaryWithPropertiesAndAdditionalPropertiesSchema = { type: 'object', properties: { foo: { @@ -275,7 +275,7 @@ export const $DictionaryWithPropertiesAndAdditionalProperties = { } } as const; -export const $DictionaryWithReference = { +export const DictionaryWithReferenceSchema = { description: 'This is a string reference', type: 'object', additionalProperties: { @@ -283,7 +283,7 @@ export const $DictionaryWithReference = { } } as const; -export const $DictionaryWithArray = { +export const DictionaryWithArraySchema = { description: 'This is a complex dictionary', type: 'object', additionalProperties: { @@ -294,7 +294,7 @@ export const $DictionaryWithArray = { } } as const; -export const $DictionaryWithDictionary = { +export const DictionaryWithDictionarySchema = { description: 'This is a string dictionary', type: 'object', additionalProperties: { @@ -305,7 +305,7 @@ export const $DictionaryWithDictionary = { } } as const; -export const $DictionaryWithProperties = { +export const DictionaryWithPropertiesSchema = { description: 'This is a complex dictionary', type: 'object', additionalProperties: { @@ -321,7 +321,7 @@ export const $DictionaryWithProperties = { } } as const; -export const $ModelWithInteger = { +export const ModelWithIntegerSchema = { description: 'This is a model with one number property', type: 'object', properties: { @@ -332,7 +332,7 @@ export const $ModelWithInteger = { } } as const; -export const $ModelWithBoolean = { +export const ModelWithBooleanSchema = { description: 'This is a model with one boolean property', type: 'object', properties: { @@ -343,7 +343,7 @@ export const $ModelWithBoolean = { } } as const; -export const $ModelWithString = { +export const ModelWithStringSchema = { description: 'This is a model with one string property', type: 'object', properties: { @@ -354,7 +354,7 @@ export const $ModelWithString = { } } as const; -export const $ModelWithStringError = { +export const ModelWithStringErrorSchema = { description: 'This is a model with one string property', type: 'object', properties: { @@ -365,12 +365,12 @@ export const $ModelWithStringError = { } } as const; -export const $Model_From_Zendesk = { +export const Model_From_ZendeskSchema = { description: `\`Comment\` or \`VoiceComment\`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets)`, type: 'string' } as const; -export const $ModelWithNullableString = { +export const ModelWithNullableStringSchema = { description: 'This is a model with one string property', type: 'object', required: ['nullableRequiredProp1', 'nullableRequiredProp2'], @@ -400,7 +400,7 @@ export const $ModelWithNullableString = { } } as const; -export const $ModelWithEnum = { +export const ModelWithEnumSchema = { description: 'This is a model with one enum', type: 'object', properties: { @@ -420,7 +420,7 @@ export const $ModelWithEnum = { } } as const; -export const $ModelWithEnumWithHyphen = { +export const ModelWithEnumWithHyphenSchema = { description: 'This is a model with one enum with escaped name', type: 'object', properties: { @@ -433,7 +433,7 @@ export const $ModelWithEnumWithHyphen = { } } as const; -export const $ModelWithEnumFromDescription = { +export const ModelWithEnumFromDescriptionSchema = { description: 'This is a model with one enum', type: 'object', properties: { @@ -444,7 +444,7 @@ export const $ModelWithEnumFromDescription = { } } as const; -export const $ModelWithNestedEnums = { +export const ModelWithNestedEnumsSchema = { description: 'This is a model with nested enums', type: 'object', properties: { @@ -481,7 +481,7 @@ export const $ModelWithNestedEnums = { } } as const; -export const $ModelWithReference = { +export const ModelWithReferenceSchema = { description: 'This is a model with one property containing a reference', type: 'object', properties: { @@ -491,7 +491,7 @@ export const $ModelWithReference = { } } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly = { +export const ModelWithArrayReadOnlyAndWriteOnlySchema = { description: 'This is a model with one property containing an array', type: 'object', properties: { @@ -516,7 +516,7 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { } } as const; -export const $ModelWithArray = { +export const ModelWithArraySchema = { description: 'This is a model with one property containing an array', type: 'object', properties: { @@ -541,7 +541,7 @@ export const $ModelWithArray = { } } as const; -export const $ModelWithDictionary = { +export const ModelWithDictionarySchema = { description: 'This is a model with one property containing a dictionary', type: 'object', properties: { @@ -554,7 +554,7 @@ export const $ModelWithDictionary = { } } as const; -export const $DeprecatedModel = { +export const DeprecatedModelSchema = { deprecated: true, description: 'This is a deprecated model with a deprecated property', type: 'object', @@ -567,7 +567,7 @@ export const $DeprecatedModel = { } } as const; -export const $ModelWithCircularReference = { +export const ModelWithCircularReferenceSchema = { description: 'This is a model with one property containing a circular reference', type: 'object', properties: { @@ -577,7 +577,7 @@ export const $ModelWithCircularReference = { } } as const; -export const $CompositionWithOneOf = { +export const CompositionWithOneOfSchema = { description: "This is a model with one property with a 'one of' relationship", type: 'object', properties: { @@ -601,7 +601,7 @@ export const $CompositionWithOneOf = { } } as const; -export const $CompositionWithOneOfAnonymous = { +export const CompositionWithOneOfAnonymousSchema = { description: "This is a model with one property with a 'one of' relationship where the options are not $ref", type: 'object', properties: { @@ -630,7 +630,7 @@ export const $CompositionWithOneOfAnonymous = { } } as const; -export const $ModelCircle = { +export const ModelCircleSchema = { description: 'Circle', type: 'object', required: ['kind'], @@ -644,7 +644,7 @@ export const $ModelCircle = { } } as const; -export const $ModelSquare = { +export const ModelSquareSchema = { description: 'Square', type: 'object', required: ['kind'], @@ -658,7 +658,7 @@ export const $ModelSquare = { } } as const; -export const $CompositionWithOneOfDiscriminator = { +export const CompositionWithOneOfDiscriminatorSchema = { description: "This is a model with one property with a 'one of' relationship where the options are not $ref", type: 'object', oneOf: [ @@ -678,7 +678,7 @@ export const $CompositionWithOneOfDiscriminator = { } } as const; -export const $CompositionWithAnyOf = { +export const CompositionWithAnyOfSchema = { description: "This is a model with one property with a 'any of' relationship", type: 'object', properties: { @@ -702,7 +702,7 @@ export const $CompositionWithAnyOf = { } } as const; -export const $CompositionWithAnyOfAnonymous = { +export const CompositionWithAnyOfAnonymousSchema = { description: "This is a model with one property with a 'any of' relationship where the options are not $ref", type: 'object', properties: { @@ -731,7 +731,7 @@ export const $CompositionWithAnyOfAnonymous = { } } as const; -export const $CompositionWithNestedAnyAndTypeNull = { +export const CompositionWithNestedAnyAndTypeNullSchema = { description: "This is a model with nested 'any of' property with a type null", type: 'object', properties: { @@ -769,17 +769,17 @@ export const $CompositionWithNestedAnyAndTypeNull = { } } as const; -export const $_3e_num_1Период = { +export const _3e_num_1ПериодSchema = { enum: ['Bird', 'Dog'], type: 'string' } as const; -export const $ConstValue = { +export const ConstValueSchema = { type: 'string', const: 'ConstValue' } as const; -export const $CompositionWithNestedAnyOfAndNull = { +export const CompositionWithNestedAnyOfAndNullSchema = { description: "This is a model with one property with a 'any of' relationship where the options are not $ref", type: 'object', properties: { @@ -807,7 +807,7 @@ export const $CompositionWithNestedAnyOfAndNull = { } } as const; -export const $CompositionWithOneOfAndNullable = { +export const CompositionWithOneOfAndNullableSchema = { description: "This is a model with one property with a 'one of' relationship", type: 'object', properties: { @@ -837,7 +837,7 @@ export const $CompositionWithOneOfAndNullable = { } } as const; -export const $CompositionWithOneOfAndSimpleDictionary = { +export const CompositionWithOneOfAndSimpleDictionarySchema = { description: 'This is a model that contains a simple dictionary within composition', type: 'object', properties: { @@ -857,7 +857,7 @@ export const $CompositionWithOneOfAndSimpleDictionary = { } } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary = { +export const CompositionWithOneOfAndSimpleArrayDictionarySchema = { description: 'This is a model that contains a dictionary of simple arrays within composition', type: 'object', properties: { @@ -880,7 +880,7 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { } } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary = { +export const CompositionWithOneOfAndComplexArrayDictionarySchema = { description: 'This is a model that contains a dictionary of complex arrays (composited) within composition', type: 'object', properties: { @@ -910,7 +910,7 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { } } as const; -export const $CompositionWithAllOfAndNullable = { +export const CompositionWithAllOfAndNullableSchema = { description: "This is a model with one property with a 'all of' relationship", type: 'object', properties: { @@ -940,7 +940,7 @@ export const $CompositionWithAllOfAndNullable = { } } as const; -export const $CompositionWithAnyOfAndNullable = { +export const CompositionWithAnyOfAndNullableSchema = { description: "This is a model with one property with a 'any of' relationship", type: 'object', properties: { @@ -970,7 +970,7 @@ export const $CompositionWithAnyOfAndNullable = { } } as const; -export const $CompositionBaseModel = { +export const CompositionBaseModelSchema = { description: 'This is a base model with two simple optional properties', type: 'object', properties: { @@ -983,7 +983,7 @@ export const $CompositionBaseModel = { } } as const; -export const $CompositionExtendedModel = { +export const CompositionExtendedModelSchema = { description: 'This is a model that extends the base model', type: 'object', allOf: [ @@ -999,7 +999,7 @@ export const $CompositionExtendedModel = { required: ['firstName', 'lastname', 'age'] } as const; -export const $ModelWithProperties = { +export const ModelWithPropertiesSchema = { description: 'This is a model with one nested property', type: 'object', required: ['required', 'requiredAndReadOnly', 'requiredAndNullable'], @@ -1047,7 +1047,7 @@ export const $ModelWithProperties = { } } as const; -export const $ModelWithNestedProperties = { +export const ModelWithNestedPropertiesSchema = { description: 'This is a model with one nested property', type: 'object', required: ['first'], @@ -1077,7 +1077,7 @@ export const $ModelWithNestedProperties = { } } as const; -export const $ModelWithDuplicateProperties = { +export const ModelWithDuplicatePropertiesSchema = { description: 'This is a model with duplicated properties', type: 'object', properties: { @@ -1087,7 +1087,7 @@ export const $ModelWithDuplicateProperties = { } } as const; -export const $ModelWithOrderedProperties = { +export const ModelWithOrderedPropertiesSchema = { description: 'This is a model with ordered properties', type: 'object', properties: { @@ -1103,7 +1103,7 @@ export const $ModelWithOrderedProperties = { } } as const; -export const $ModelWithDuplicateImports = { +export const ModelWithDuplicateImportsSchema = { description: 'This is a model with duplicated imports', type: 'object', properties: { @@ -1119,7 +1119,7 @@ export const $ModelWithDuplicateImports = { } } as const; -export const $ModelThatExtends = { +export const ModelThatExtendsSchema = { description: 'This is a model that extends another model', type: 'object', allOf: [ @@ -1140,7 +1140,7 @@ export const $ModelThatExtends = { ] } as const; -export const $ModelThatExtendsExtends = { +export const ModelThatExtendsExtendsSchema = { description: 'This is a model that extends another model', type: 'object', allOf: [ @@ -1164,7 +1164,7 @@ export const $ModelThatExtendsExtends = { ] } as const; -export const $ModelWithPattern = { +export const ModelWithPatternSchema = { description: 'This is a model that contains a some patterns', type: 'object', required: ['key', 'name'], @@ -1211,7 +1211,7 @@ bbb` } } as const; -export const $File = { +export const FileSchema = { required: ['mime'], type: 'object', properties: { @@ -1248,7 +1248,7 @@ export const $File = { } } as const; -export const $default = { +export const defaultSchema = { type: 'object', properties: { name: { @@ -1257,7 +1257,7 @@ export const $default = { } } as const; -export const $Pageable = { +export const PageableSchema = { type: 'object', properties: { page: { @@ -1280,24 +1280,24 @@ export const $Pageable = { } } as const; -export const $FreeFormObjectWithoutAdditionalProperties = { +export const FreeFormObjectWithoutAdditionalPropertiesSchema = { description: 'This is a free-form object without additionalProperties.', type: 'object' } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { +export const FreeFormObjectWithAdditionalPropertiesEqTrueSchema = { description: 'This is a free-form object with additionalProperties: true.', type: 'object', additionalProperties: true } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { +export const FreeFormObjectWithAdditionalPropertiesEqEmptyObjectSchema = { description: 'This is a free-form object with additionalProperties: {}.', type: 'object', additionalProperties: {} } as const; -export const $ModelWithConst = { +export const ModelWithConstSchema = { type: 'object', properties: { String: { @@ -1316,7 +1316,7 @@ export const $ModelWithConst = { } } as const; -export const $ModelWithAdditionalPropertiesEqTrue = { +export const ModelWithAdditionalPropertiesEqTrueSchema = { description: 'This is a model with one property and additionalProperties: true', type: 'object', properties: { @@ -1328,7 +1328,7 @@ export const $ModelWithAdditionalPropertiesEqTrue = { additionalProperties: true } as const; -export const $NestedAnyOfArraysNullable = { +export const NestedAnyOfArraysNullableSchema = { properties: { nullableArray: { anyOf: [ @@ -1354,7 +1354,7 @@ export const $NestedAnyOfArraysNullable = { type: 'object' } as const; -export const $CompositionWithOneOfAndProperties = { +export const CompositionWithOneOfAndPropertiesSchema = { type: 'object', oneOf: [ { @@ -1394,7 +1394,7 @@ export const $CompositionWithOneOfAndProperties = { } } as const; -export const $NullableObject = { +export const NullableObjectSchema = { type: ['object', 'null'], description: 'An object that can be null', properties: { @@ -1405,12 +1405,12 @@ export const $NullableObject = { default: null } as const; -export const $CharactersInDescription = { +export const CharactersInDescriptionSchema = { type: 'string', description: 'Some % character' } as const; -export const $ModelWithNullableObject = { +export const ModelWithNullableObjectSchema = { type: 'object', properties: { data: { @@ -1419,7 +1419,7 @@ export const $ModelWithNullableObject = { } } as const; -export const $ModelWithOneOfEnum = { +export const ModelWithOneOfEnumSchema = { oneOf: [ { type: 'object', @@ -1492,17 +1492,17 @@ export const $ModelWithOneOfEnum = { ] } as const; -export const $ModelWithNestedArrayEnumsDataFoo = { +export const ModelWithNestedArrayEnumsDataFooSchema = { enum: ['foo', 'bar'], type: 'string' } as const; -export const $ModelWithNestedArrayEnumsDataBar = { +export const ModelWithNestedArrayEnumsDataBarSchema = { enum: ['baz', 'qux'], type: 'string' } as const; -export const $ModelWithNestedArrayEnumsData = { +export const ModelWithNestedArrayEnumsDataSchema = { type: 'object', properties: { foo: { @@ -1520,7 +1520,7 @@ export const $ModelWithNestedArrayEnumsData = { } } as const; -export const $ModelWithNestedArrayEnums = { +export const ModelWithNestedArrayEnumsSchema = { type: 'object', properties: { array_strings: { @@ -1539,7 +1539,7 @@ export const $ModelWithNestedArrayEnums = { } } as const; -export const $ModelWithNestedCompositionEnums = { +export const ModelWithNestedCompositionEnumsSchema = { type: 'object', properties: { foo: { @@ -1552,7 +1552,7 @@ export const $ModelWithNestedCompositionEnums = { } } as const; -export const $ModelWithReadOnlyAndWriteOnly = { +export const ModelWithReadOnlyAndWriteOnlySchema = { type: 'object', required: ['foo', 'bar', 'baz'], properties: { @@ -1570,7 +1570,7 @@ export const $ModelWithReadOnlyAndWriteOnly = { } } as const; -export const $ModelWithConstantSizeArray = { +export const ModelWithConstantSizeArraySchema = { type: 'array', items: { type: 'number' @@ -1579,7 +1579,7 @@ export const $ModelWithConstantSizeArray = { maxItems: 2 } as const; -export const $ModelWithAnyOfConstantSizeArray = { +export const ModelWithAnyOfConstantSizeArraySchema = { type: 'array', items: { oneOf: [ @@ -1595,7 +1595,7 @@ export const $ModelWithAnyOfConstantSizeArray = { maxItems: 3 } as const; -export const $ModelWithPrefixItemsConstantSizeArray = { +export const ModelWithPrefixItemsConstantSizeArraySchema = { type: 'array', prefixItems: [ { @@ -1617,7 +1617,7 @@ export const $ModelWithPrefixItemsConstantSizeArray = { ] } as const; -export const $ModelWithAnyOfConstantSizeArrayNullable = { +export const ModelWithAnyOfConstantSizeArrayNullableSchema = { type: ['array'], items: { oneOf: [ @@ -1634,7 +1634,7 @@ export const $ModelWithAnyOfConstantSizeArrayNullable = { maxItems: 3 } as const; -export const $ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = { +export const ModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsSchema = { type: 'array', items: { oneOf: [ @@ -1650,7 +1650,7 @@ export const $ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = { maxItems: 2 } as const; -export const $ModelWithAnyOfConstantSizeArrayAndIntersect = { +export const ModelWithAnyOfConstantSizeArrayAndIntersectSchema = { type: 'array', items: { allOf: [ @@ -1666,7 +1666,7 @@ export const $ModelWithAnyOfConstantSizeArrayAndIntersect = { maxItems: 2 } as const; -export const $ModelWithNumericEnumUnion = { +export const ModelWithNumericEnumUnionSchema = { type: 'object', properties: { value: { @@ -1677,7 +1677,7 @@ export const $ModelWithNumericEnumUnion = { } } as const; -export const $ModelWithBackticksInDescription = { +export const ModelWithBackticksInDescriptionSchema = { description: 'Some description with `back ticks`', type: 'object', properties: { @@ -1714,7 +1714,7 @@ export const $ModelWithBackticksInDescription = { } } as const; -export const $ModelWithOneOfAndProperties = { +export const ModelWithOneOfAndPropertiesSchema = { type: 'object', oneOf: [ { @@ -1740,37 +1740,37 @@ export const $ModelWithOneOfAndProperties = { } } as const; -export const $ParameterSimpleParameterUnused = { +export const ParameterSimpleParameterUnusedSchema = { description: 'Model used to test deduplication strategy (unused)', type: 'string' } as const; -export const $PostServiceWithEmptyTagResponse = { +export const PostServiceWithEmptyTagResponseSchema = { description: 'Model used to test deduplication strategy', type: 'string' } as const; -export const $PostServiceWithEmptyTagResponse2 = { +export const PostServiceWithEmptyTagResponse2Schema = { description: 'Model used to test deduplication strategy', type: 'string' } as const; -export const $DeleteFooData = { +export const DeleteFooDataSchema = { description: 'Model used to test deduplication strategy', type: 'string' } as const; -export const $DeleteFooData2 = { +export const DeleteFooData2Schema = { description: 'Model used to test deduplication strategy', type: 'string' } as const; -export const $import = { +export const importSchema = { description: 'Model with restricted keyword name', type: 'string' } as const; -export const $SchemaWithFormRestrictedKeys = { +export const SchemaWithFormRestrictedKeysSchema = { properties: { description: { type: 'string' @@ -1835,7 +1835,7 @@ export const $SchemaWithFormRestrictedKeys = { } } as const; -export const $io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { +export const io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptionsSchema = { description: 'This schema was giving PascalCase transformations a hard time', properties: { preconditions: { @@ -1850,7 +1850,7 @@ export const $io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { type: 'object' } as const; -export const $io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { +export const io_k8s_apimachinery_pkg_apis_meta_v1_PreconditionsSchema = { description: 'This schema was giving PascalCase transformations a hard time', properties: { resourceVersion: { @@ -1865,7 +1865,7 @@ export const $io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { type: 'object' } as const; -export const $AdditionalPropertiesUnknownIssue = { +export const AdditionalPropertiesUnknownIssueSchema = { type: 'object', properties: {}, additionalProperties: { @@ -1880,7 +1880,7 @@ export const $AdditionalPropertiesUnknownIssue = { } } as const; -export const $AdditionalPropertiesUnknownIssue2 = { +export const AdditionalPropertiesUnknownIssue2Schema = { type: 'object', additionalProperties: { anyOf: [ @@ -1894,7 +1894,7 @@ export const $AdditionalPropertiesUnknownIssue2 = { } } as const; -export const $AdditionalPropertiesUnknownIssue3 = { +export const AdditionalPropertiesUnknownIssue3Schema = { type: 'object', allOf: [ { @@ -1914,7 +1914,7 @@ export const $AdditionalPropertiesUnknownIssue3 = { ] } as const; -export const $AdditionalPropertiesIntegerIssue = { +export const AdditionalPropertiesIntegerIssueSchema = { type: 'object', required: ['value'], properties: { @@ -1927,7 +1927,7 @@ export const $AdditionalPropertiesIntegerIssue = { } } as const; -export const $OneOfAllOfIssue = { +export const OneOfAllOfIssueSchema = { oneOf: [ { allOf: [ @@ -1952,7 +1952,7 @@ export const $OneOfAllOfIssue = { ] } as const; -export const $Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { +export const Generic_Schema_Duplicate_Issue_1_System_Boolean_Schema = { type: 'object', properties: { item: { @@ -1970,7 +1970,7 @@ export const $Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { additionalProperties: false } as const; -export const $Generic_Schema_Duplicate_Issue_1_System_String_ = { +export const Generic_Schema_Duplicate_Issue_1_System_String_Schema = { type: 'object', properties: { item: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/index.ts.snap new file mode 100644 index 000000000..bb994a669 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/index.ts.snap @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './schemas.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/schemas.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/schemas.gen.ts.snap new file mode 100644 index 000000000..d5f71370e --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-schemas-name/schemas.gen.ts.snap @@ -0,0 +1,1990 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export const $_400 = { + description: 'Model with number-only name', + type: 'string' +} as const; + +export const $camelCaseCommentWithBreaks = { + description: `Testing multiline comments in string: First line +Second line + +Fourth line`, + type: 'integer' +} as const; + +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 $CommentWithBackticksAndQuotes = { + description: `Testing backticks and quotes in string: \`backticks\`, 'quotes', "double quotes" 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 $EnumWithXEnumNames = { + enum: [0, 1, 2], + 'x-enumNames': ['zero', 'one', 'two'] +} 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: { + '16x16': { + '$ref': '#/components/schemas/camelCaseCommentWithBreaks' + }, + 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: { + data: { + anyOf: [ + {}, + { + type: 'null' + } + ] + } + } +} 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 $DictionaryWithPropertiesAndAdditionalProperties = { + type: 'object', + properties: { + foo: { + type: 'number' + }, + bar: { + type: 'boolean' + } + }, + 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' + } + } +} 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' + } + } +} 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' + } + } +} as const; + +export const $ModelWithStringError = { + description: 'This is a model with one string property', + type: 'object', + properties: { + prop: { + description: 'This is a simple string property', + type: 'string' + } + } +} as const; + +export const $Model_From_Zendesk = { + description: `\`Comment\` or \`VoiceComment\`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets)`, + type: 'string' +} 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', + 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', 'ØÆÅ字符串'] + } + } +} 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', + enum: ['3.0'], + title: 'Foo-Bar-Baz-Qux', + default: '3.0' + } + } +} as const; + +export const $ModelWithEnumFromDescription = { + description: 'This is a model with one enum', + type: 'object', + properties: { + test: { + type: 'integer', + description: 'Success=1,Warning=2,Error=3' + } + } +} as const; + +export const $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', 'ØÆÅ字符串'] + } + } +} 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' + } + }, + propWithFile: { + type: 'array', + items: { + type: 'file' + } + }, + propWithNumber: { + type: 'array', + items: { + type: 'number' + } + } + } +} 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' + } + }, + propWithFile: { + type: 'array', + items: { + type: 'file' + } + }, + propWithNumber: { + type: 'array', + items: { + type: 'number' + } + } + } +} 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' + } + } + } +} as const; + +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' + } + } +} 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' + } + } +} 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' + } + ] + } + } +} 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' + } + } + }, + { + description: 'Anonymous string type', + type: 'string' + }, + { + description: 'Anonymous integer type', + type: 'integer' + } + ] + } + } +} 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' + } + } + }, + { + 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' + }, + { + items: { + anyOf: [ + { + '$ref': '#/components/schemas/ModelWithArray' + }, + { + type: 'null' + } + ] + }, + type: 'array' + } + ] + } + } +} as const; + +export const $_3e_num_1Период = { + 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/3e-num_1Период' + }, + { + '$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", + 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' + } + ] + } + } +} 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' + } + } + ] + } + } +} 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' + } + } + } + ] + } + } +} 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' + } + ] + } + } + } + ] + } + } +} 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' + } + } + }, + { + '$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' + } + } + }, + { + '$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 + } + } + } + } + } + } +} as const; + +export const $ModelWithDuplicateProperties = { + description: 'This is a model with duplicated properties', + type: 'object', + properties: { + prop: { + '$ref': '#/components/schemas/ModelWithString' + } + } +} as const; + +export const $ModelWithOrderedProperties = { + description: 'This is a model with ordered properties', + type: 'object', + properties: { + zebra: { + type: 'string' + }, + 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' + } + } + } + ] +} 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' + } + } + } + ] +} 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' + }, + 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; + +export const $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' + } + } +} as const; + +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' + } + } + } +} 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: [ + { + type: 'string' + }, + { + type: 'boolean' + } + ] + }, + type: 'array' + }, + { + type: 'null' + } + ] + } + }, + type: 'object' +} as const; + +export const $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æøåÆØÅöôêÊ字符串' + } + }, + 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', 'null'], + description: 'An object that can be null', + properties: { + foo: { + type: 'string' + } + }, + default: null +} as const; + +export const $CharactersInDescription = { + type: 'string', + description: 'Some % character' +} 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'] + } + } + }, + { + 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'] + } + } + } + ] +} 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 $ModelWithConstantSizeArray = { + type: 'array', + items: { + type: 'number' + }, + minItems: 2, + maxItems: 2 +} as const; + +export const $ModelWithAnyOfConstantSizeArray = { + type: 'array', + items: { + oneOf: [ + { + type: 'number' + }, + { + type: 'string' + } + ] + }, + minItems: 3, + maxItems: 3 +} as const; + +export const $ModelWithPrefixItemsConstantSizeArray = { + type: 'array', + prefixItems: [ + { + '$ref': '#/components/schemas/ModelWithInteger' + }, + { + oneOf: [ + { + type: 'number' + }, + { + type: 'string' + } + ] + }, + { + type: 'string' + } + ] +} as const; + +export const $ModelWithAnyOfConstantSizeArrayNullable = { + type: ['array'], + items: { + oneOf: [ + { + type: 'number', + nullable: true + }, + { + type: 'string' + } + ] + }, + minItems: 3, + maxItems: 3 +} as const; + +export const $ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = { + type: 'array', + items: { + oneOf: [ + { + type: 'number' + }, + { + '$ref': '#/components/schemas/import' + } + ] + }, + minItems: 2, + maxItems: 2 +} as const; + +export const $ModelWithAnyOfConstantSizeArrayAndIntersect = { + type: 'array', + items: { + allOf: [ + { + type: 'number' + }, + { + type: 'string' + } + ] + }, + minItems: 2, + maxItems: 2 +} as const; + +export const $ModelWithNumericEnumUnion = { + type: 'object', + properties: { + value: { + type: 'number', + description: 'Период', + enum: [-10, -1, 0, 1, 3, 6, 12] + } + } +} as const; + +export const $ModelWithBackticksInDescription = { + description: 'Some description with `back ticks`', + type: 'object', + properties: { + template: { + type: 'string', + description: `The template \`that\` should be used for parsing and importing the contents of the CSV file. + +

There is one placeholder currently supported:

Example of a correct JSON template:

+
+[
+  {
+    "resourceType": "Asset",
+    "identifier": {
+      "name": "\${1}",
+      "domain": {
+        "name": "\${2}",
+        "community": {
+          "name": "Some Community"
+        }
+      }
+    },
+    "attributes" : {
+      "00000000-0000-0000-0000-000000003115" : [ {
+        "value" : "\${3}" 
+      } ],
+      "00000000-0000-0000-0000-000000000222" : [ {
+        "value" : "\${4}"
+      } ]
+    }
+  }
+]
+
` + } + } +} as const; + +export const $ModelWithOneOfAndProperties = { + type: 'object', + oneOf: [ + { + '$ref': '#/components/parameters/SimpleParameter' + }, + { + '$ref': '#/components/schemas/NonAsciiStringæøåÆØÅöôêÊ字符串' + } + ], + required: ['baz', 'qux'], + properties: { + baz: { + type: 'integer', + format: 'uint16', + minimum: 0, + nullable: true + }, + qux: { + type: 'integer', + format: 'uint8', + minimum: 0 + } + } +} as const; + +export const $ParameterSimpleParameterUnused = { + description: 'Model used to test deduplication strategy (unused)', + type: 'string' +} as const; + +export const $PostServiceWithEmptyTagResponse = { + description: 'Model used to test deduplication strategy', + type: 'string' +} as const; + +export const $PostServiceWithEmptyTagResponse2 = { + description: 'Model used to test deduplication strategy', + type: 'string' +} as const; + +export const $DeleteFooData = { + description: 'Model used to test deduplication strategy', + type: 'string' +} as const; + +export const $DeleteFooData2 = { + description: 'Model used to test deduplication strategy', + type: 'string' +} as const; + +export const $import = { + description: 'Model with restricted keyword name', + type: 'string' +} as const; + +export const $SchemaWithFormRestrictedKeys = { + properties: { + description: { + type: 'string' + }, + 'x-enum-descriptions': { + type: 'string' + }, + 'x-enum-varnames': { + type: 'string' + }, + 'x-enumNames': { + type: 'string' + }, + title: { + type: 'string' + }, + object: { + type: 'object', + properties: { + description: { + type: 'string' + }, + 'x-enum-descriptions': { + type: 'string' + }, + 'x-enum-varnames': { + type: 'string' + }, + 'x-enumNames': { + type: 'string' + }, + title: { + type: 'string' + } + } + }, + array: { + type: 'array', + items: [ + { + type: 'object', + properties: { + description: { + type: 'string' + }, + 'x-enum-descriptions': { + type: 'string' + }, + 'x-enum-varnames': { + type: 'string' + }, + 'x-enumNames': { + type: 'string' + }, + title: { + type: 'string' + } + } + } + ] + } + } +} as const; + +export const $io_k8s_apimachinery_pkg_apis_meta_v1_DeleteOptions = { + description: 'This schema was giving PascalCase transformations a hard time', + properties: { + preconditions: { + allOf: [ + { + '$ref': '#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions' + } + ], + description: 'Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.' + } + }, + type: 'object' +} as const; + +export const $io_k8s_apimachinery_pkg_apis_meta_v1_Preconditions = { + description: 'This schema was giving PascalCase transformations a hard time', + properties: { + resourceVersion: { + description: 'Specifies the target ResourceVersion', + type: 'string' + }, + uid: { + description: 'Specifies the target UID.', + type: 'string' + } + }, + type: 'object' +} as const; + +export const $AdditionalPropertiesUnknownIssue = { + type: 'object', + properties: {}, + additionalProperties: { + anyOf: [ + { + type: 'string' + }, + { + type: 'number' + } + ] + } +} as const; + +export const $AdditionalPropertiesUnknownIssue2 = { + type: 'object', + additionalProperties: { + anyOf: [ + { + type: 'string' + }, + { + type: 'number' + } + ] + } +} as const; + +export const $AdditionalPropertiesUnknownIssue3 = { + type: 'object', + allOf: [ + { + type: 'string' + }, + { + type: 'object', + required: ['entries'], + properties: { + entries: { + additionalProperties: { + '$ref': '#/components/schemas/AdditionalPropertiesUnknownIssue' + } + } + } + } + ] +} as const; + +export const $AdditionalPropertiesIntegerIssue = { + type: 'object', + required: ['value'], + properties: { + value: { + type: 'integer' + } + }, + additionalProperties: { + type: 'integer' + } +} as const; + +export const $OneOfAllOfIssue = { + oneOf: [ + { + allOf: [ + { + oneOf: [ + { + '$ref': '#/components/schemas/ConstValue' + }, + { + '$ref': '#/components/schemas/Generic.Schema.Duplicate.Issue`1[System.Boolean]' + } + ] + }, + { + '$ref': '#/components/schemas/3e-num_1Период' + } + ] + }, + { + '$ref': '#/components/schemas/Generic.Schema.Duplicate.Issue`1[System.String]' + } + ] +} as const; + +export const $Generic_Schema_Duplicate_Issue_1_System_Boolean_ = { + type: 'object', + properties: { + item: { + type: 'boolean' + }, + error: { + type: 'string', + nullable: true + }, + hasError: { + type: 'boolean', + readOnly: true + } + }, + additionalProperties: false +} as const; + +export const $Generic_Schema_Duplicate_Issue_1_System_String_ = { + type: 'object', + properties: { + item: { + type: 'string', + nullable: true + }, + error: { + type: 'string', + nullable: true + }, + hasError: { + type: 'boolean', + readOnly: true + } + }, + additionalProperties: false +} as const; \ No newline at end of file diff --git a/packages/openapi-ts/test/index.spec.ts b/packages/openapi-ts/test/index.spec.ts index e6121661e..cc2e77bdb 100644 --- a/packages/openapi-ts/test/index.spec.ts +++ b/packages/openapi-ts/test/index.spec.ts @@ -360,6 +360,19 @@ describe('OpenAPI v3', () => { description: 'generate JSON Schemas', name: 'v3-schemas-json', }, + { + config: createConfig({ + exportCore: false, + schemas: { + name: (name) => `$${name}`, + type: 'json', + }, + services: false, + types: false, + }), + description: 'generate JSON Schemas with custom names', + name: 'v3-schemas-name', + }, { config: createConfig({ exportCore: false,