From 732d556d90c20f3f8170c7b6c17ccd6481558807 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 5 Apr 2024 06:19:22 +0100 Subject: [PATCH 1/3] chore(schemas): use TypeScript Compiler API to create schemas --- packages/openapi-ts/package.json | 3 + packages/openapi-ts/rollup.config.ts | 2 +- packages/openapi-ts/src/utils/handlebars.ts | 2 +- .../src/utils/write/__tests__/schemas.spec.ts | 2 +- .../openapi-ts/src/utils/write/schemas.ts | 107 ++++++++- .../test/generated/v2/schemas.ts.snap | 107 +++++++++ .../test/generated/v3/schemas.ts.snap | 208 ++++++++++++++++++ .../test/generated/v3_angular/schemas.ts.snap | 208 ++++++++++++++++++ .../test/generated/v3_date/schemas.ts.snap | 2 + .../v3_enums_typescript/schemas.ts.snap | 208 ++++++++++++++++++ .../generated/v3_experimental/schemas.ts.snap | 208 ++++++++++++++++++ 11 files changed, 1049 insertions(+), 8 deletions(-) diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index 8cdb1efb2..a08328ab5 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -59,6 +59,9 @@ "engines": { "node": "^18.0.0 || >=20.0.0" }, + "peerDependencies": { + "typescript": "^5.x" + }, "dependencies": { "@apidevtools/json-schema-ref-parser": "11.5.4", "c12": "1.10.0", diff --git a/packages/openapi-ts/rollup.config.ts b/packages/openapi-ts/rollup.config.ts index 47a63d6c7..7e4ca77e5 100644 --- a/packages/openapi-ts/rollup.config.ts +++ b/packages/openapi-ts/rollup.config.ts @@ -70,7 +70,7 @@ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)). function createConfig(isProduction: boolean) { return defineConfig({ - external: [...Object.keys(pkg.dependencies)], + external: [...Object.keys(pkg.dependencies), ...Object.keys(pkg.peerDependencies)], input: path.resolve(__dirname, 'src/node/index.ts'), output: { file: path.resolve(__dirname, 'dist/node/index.js'), diff --git a/packages/openapi-ts/src/utils/handlebars.ts b/packages/openapi-ts/src/utils/handlebars.ts index c9ec10b41..025035408 100644 --- a/packages/openapi-ts/src/utils/handlebars.ts +++ b/packages/openapi-ts/src/utils/handlebars.ts @@ -164,7 +164,7 @@ const dataParameters = (config: Config, parameters: OperationParameter[]) => { return output.join(', '); }; -const modelIsRequired = (config: Config, model: Model) => { +export const modelIsRequired = (config: Config, model: Model) => { if (config.useOptions) { return model.isRequired ? '' : '?'; } diff --git a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts index 7e3eb4e1f..28370bea7 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts @@ -59,6 +59,6 @@ describe('writeClientSchemas', () => { write: true, }); - expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/schemas.ts'), 'schema'); + expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/schemas.ts'), expect.stringContaining('schema')); }); }); diff --git a/packages/openapi-ts/src/utils/write/schemas.ts b/packages/openapi-ts/src/utils/write/schemas.ts index 99d05adf1..aab36994e 100644 --- a/packages/openapi-ts/src/utils/write/schemas.ts +++ b/packages/openapi-ts/src/utils/write/schemas.ts @@ -1,10 +1,106 @@ import { writeFileSync } from 'node:fs'; import path from 'node:path'; +import ts from 'typescript'; + +import type { Model } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; +import { enumValue } from '../enum'; import type { Templates } from '../handlebars'; +const enumSchema = (config: Config, model: Model) => { + let properties = [ts.factory.createPropertyAssignment('type', ts.factory.createStringLiteral('Enum'))]; + + if (model.enum.length) { + const property = ts.factory.createPropertyAssignment( + 'enum', + ts.factory.createArrayLiteralExpression( + model.enum.map(enumerator => ts.factory.createIdentifier(enumValue(enumerator.value)!)) + ) + ); + properties = [...properties, property]; + } + + if (model.default !== undefined) { + const value = ts.factory.createIdentifier(String(model.default)); + const property = ts.factory.createPropertyAssignment('default', value); + properties = [...properties, property]; + } + + if (model.isReadOnly) { + const property = ts.factory.createPropertyAssignment('isReadOnly', ts.factory.createStringLiteral('true')); + properties = [...properties, property]; + } + if (model.isRequired) { + const property = ts.factory.createPropertyAssignment('isRequired', ts.factory.createStringLiteral('true')); + properties = [...properties, property]; + } + if (model.isNullable) { + const property = ts.factory.createPropertyAssignment('isNullable', ts.factory.createStringLiteral('true')); + properties = [...properties, property]; + } + + return ts.factory.createObjectLiteralExpression(properties); +}; + +const exportSchema = (config: Config, model: Model) => { + const file = ts.createSourceFile('', '', ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS); + const printer = ts.createPrinter({ + newLine: ts.NewLineKind.LineFeed, + }); + let jsonSchema = ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment('firstKey', ts.factory.createStringLiteral('string expression')), + ts.factory.createPropertyAssignment('secondKey', ts.factory.createNumericLiteral(0)), + ]); + + let schema = ''; + switch (model.export) { + case 'all-of': + case 'any-of': + case 'one-of': + // {{>schemaComposition}} + schema = 'COMP'; + break; + case 'array': + // {{>schemaArray}} + schema = 'ARR'; + break; + case 'dictionary': + // {{>schemaDictionary}} + schema = 'DICT'; + break; + case 'enum': + jsonSchema = enumSchema(config, model); + break; + case 'interface': + // {{>schemaInterface}} + schema = 'INTERFACE'; + break; + default: + // {{>schemaGeneric}} + schema = 'GENERIC'; + break; + } + + const statement = ts.factory.createVariableStatement( + [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], + ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier(`$${model.name}_WIP`), + undefined, + undefined, + ts.factory.createAsExpression(jsonSchema, ts.factory.createTypeReferenceNode('const')) + ), + ], + ts.NodeFlags.Const + ) + ); + + return printer.printNode(ts.EmitHint.Unspecified, statement, file); +}; + /** * Generate Schemas using the Handlebar template and write to disk. * @param client Client containing models, schemas, and services @@ -22,15 +118,16 @@ export const writeClientSchemas = async ( return; } - // Generate file with all schemas - const results: string[] = []; + let results: string[] = []; + for (const model of client.models) { + const resultNew = exportSchema(config, model); const result = templates.exports.schema({ $config: config, ...model, }); - results.push(result); + results = [...results, resultNew, result]; } - const file = path.resolve(outputPath, 'schemas.ts'); - await writeFileSync(file, results.join('\n\n')); + + await writeFileSync(path.resolve(outputPath, 'schemas.ts'), results.join('\n\n')); }; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap index 77ac1586b..29e25eefc 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $CommentWithBreaks_WIP = GENERIC as const; + export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -6,61 +8,85 @@ Second line Fourth line`, } as const; +export const $CommentWithBackticks_WIP = GENERIC as const; + export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; +export const $CommentWithSlashes_WIP = GENERIC as const; + export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; +export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; + export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; +export const $CommentWithQuotes_WIP = GENERIC as const; + export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; +export const $CommentWithReservedCharacters_WIP = GENERIC as const; + export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; +export const $SimpleInteger_WIP = GENERIC as const; + export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; +export const $SimpleBoolean_WIP = GENERIC as const; + export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; +export const $SimpleString_WIP = GENERIC as const; + export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; +export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; + export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; +export const $SimpleFile_WIP = GENERIC as const; + export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; +export const $SimpleReference_WIP = GENERIC as const; + export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; +export const $SimpleStringWithPattern_WIP = GENERIC as const; + export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -68,26 +94,45 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; +export const $EnumWithStrings_WIP = { + type: 'Enum', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; +export const $EnumWithNumbers_WIP = { + type: 'Enum', + 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; + export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; +export const $EnumWithExtensions_WIP = { + type: 'Enum', + enum: [200, 400, 500], +} as const; + export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; +export const $ArrayWithNumbers_WIP = ARR as const; + export const $ArrayWithNumbers = { type: 'array', contains: { @@ -95,6 +140,8 @@ export const $ArrayWithNumbers = { }, } as const; +export const $ArrayWithBooleans_WIP = ARR as const; + export const $ArrayWithBooleans = { type: 'array', contains: { @@ -102,6 +149,8 @@ export const $ArrayWithBooleans = { }, } as const; +export const $ArrayWithStrings_WIP = ARR as const; + export const $ArrayWithStrings = { type: 'array', contains: { @@ -109,6 +158,8 @@ export const $ArrayWithStrings = { }, } as const; +export const $ArrayWithReferences_WIP = ARR as const; + export const $ArrayWithReferences = { type: 'array', contains: { @@ -116,6 +167,8 @@ export const $ArrayWithReferences = { }, } as const; +export const $ArrayWithArray_WIP = ARR as const; + export const $ArrayWithArray = { type: 'array', contains: { @@ -126,6 +179,8 @@ export const $ArrayWithArray = { }, } as const; +export const $ArrayWithProperties_WIP = ARR as const; + export const $ArrayWithProperties = { type: 'array', contains: { @@ -140,6 +195,8 @@ export const $ArrayWithProperties = { }, } as const; +export const $DictionaryWithString_WIP = DICT as const; + export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -147,6 +204,8 @@ export const $DictionaryWithString = { }, } as const; +export const $DictionaryWithReference_WIP = DICT as const; + export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -154,6 +213,8 @@ export const $DictionaryWithReference = { }, } as const; +export const $DictionaryWithArray_WIP = DICT as const; + export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -164,6 +225,8 @@ export const $DictionaryWithArray = { }, } as const; +export const $DictionaryWithDictionary_WIP = DICT as const; + export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -174,6 +237,8 @@ export const $DictionaryWithDictionary = { }, } as const; +export const $DictionaryWithProperties_WIP = DICT as const; + export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -188,11 +253,15 @@ export const $DictionaryWithProperties = { }, } as const; +export const $Date_WIP = GENERIC as const; + export const $Date = { type: 'string', description: `This is a type-only model that defines Date as a string`, } as const; +export const $ModelWithInteger_WIP = INTERFACE as const; + export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -203,6 +272,8 @@ export const $ModelWithInteger = { }, } as const; +export const $ModelWithBoolean_WIP = INTERFACE as const; + export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -213,6 +284,8 @@ export const $ModelWithBoolean = { }, } as const; +export const $ModelWithString_WIP = INTERFACE as const; + export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -223,6 +296,8 @@ export const $ModelWithString = { }, } as const; +export const $ModelWithNullableString_WIP = INTERFACE as const; + export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -240,6 +315,8 @@ export const $ModelWithNullableString = { }, } as const; +export const $ModelWithEnum_WIP = INTERFACE as const; + export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -258,6 +335,8 @@ export const $ModelWithEnum = { }, } as const; +export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; + export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -268,6 +347,8 @@ export const $ModelWithEnumFromDescription = { }, } as const; +export const $ModelWithNestedEnums_WIP = INTERFACE as const; + export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -302,6 +383,8 @@ export const $ModelWithNestedEnums = { }, } as const; +export const $ModelWithReference_WIP = INTERFACE as const; + export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -311,6 +394,8 @@ export const $ModelWithReference = { }, } as const; +export const $ModelWithArray_WIP = INTERFACE as const; + export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -335,6 +420,8 @@ export const $ModelWithArray = { }, } as const; +export const $ModelWithDictionary_WIP = INTERFACE as const; + export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -347,6 +434,8 @@ export const $ModelWithDictionary = { }, } as const; +export const $ModelWithCircularReference_WIP = INTERFACE as const; + export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -356,6 +445,8 @@ export const $ModelWithCircularReference = { }, } as const; +export const $ModelWithProperties_WIP = INTERFACE as const; + export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -400,6 +491,8 @@ export const $ModelWithProperties = { }, } as const; +export const $ModelWithNestedProperties_WIP = INTERFACE as const; + export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -423,6 +516,8 @@ export const $ModelWithNestedProperties = { }, } as const; +export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; + export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -432,6 +527,8 @@ export const $ModelWithDuplicateProperties = { }, } as const; +export const $ModelWithOrderedProperties_WIP = INTERFACE as const; + export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -447,6 +544,8 @@ export const $ModelWithOrderedProperties = { }, } as const; +export const $ModelWithDuplicateImports_WIP = INTERFACE as const; + export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -462,6 +561,8 @@ export const $ModelWithDuplicateImports = { }, } as const; +export const $ModelThatExtends_WIP = COMP as const; + export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -482,6 +583,8 @@ export const $ModelThatExtends = { ], } as const; +export const $ModelThatExtendsExtends_WIP = COMP as const; + export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -505,6 +608,8 @@ export const $ModelThatExtendsExtends = { ], } as const; +export const $_default_WIP = INTERFACE as const; + export const $_default = { properties: { name: { @@ -513,6 +618,8 @@ export const $_default = { }, } as const; +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap index e402b1ef7..0fea2e0b6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $CommentWithBreaks_WIP = GENERIC as const; + export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -6,61 +8,85 @@ Second line Fourth line`, } as const; +export const $CommentWithBackticks_WIP = GENERIC as const; + export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; +export const $CommentWithSlashes_WIP = GENERIC as const; + export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; +export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; + export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; +export const $CommentWithQuotes_WIP = GENERIC as const; + export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; +export const $CommentWithReservedCharacters_WIP = GENERIC as const; + export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; +export const $SimpleInteger_WIP = GENERIC as const; + export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; +export const $SimpleBoolean_WIP = GENERIC as const; + export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; +export const $SimpleString_WIP = GENERIC as const; + export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; +export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; + export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; +export const $SimpleFile_WIP = GENERIC as const; + export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; +export const $SimpleReference_WIP = GENERIC as const; + export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; +export const $SimpleStringWithPattern_WIP = GENERIC as const; + export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -69,32 +95,57 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; +export const $EnumWithStrings_WIP = { + type: 'Enum', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; +export const $EnumWithReplacedCharacters_WIP = { + type: 'Enum', + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], +} as const; + export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; +export const $EnumWithNumbers_WIP = { + type: 'Enum', + 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; + export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; +export const $EnumWithExtensions_WIP = { + type: 'Enum', + enum: [200, 400, 500], +} as const; + export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; +export const $ArrayWithNumbers_WIP = ARR as const; + export const $ArrayWithNumbers = { type: 'array', contains: { @@ -102,6 +153,8 @@ export const $ArrayWithNumbers = { }, } as const; +export const $ArrayWithBooleans_WIP = ARR as const; + export const $ArrayWithBooleans = { type: 'array', contains: { @@ -109,6 +162,8 @@ export const $ArrayWithBooleans = { }, } as const; +export const $ArrayWithStrings_WIP = ARR as const; + export const $ArrayWithStrings = { type: 'array', contains: { @@ -117,6 +172,8 @@ export const $ArrayWithStrings = { default: ['test'], } as const; +export const $ArrayWithReferences_WIP = ARR as const; + export const $ArrayWithReferences = { type: 'array', contains: { @@ -124,6 +181,8 @@ export const $ArrayWithReferences = { }, } as const; +export const $ArrayWithArray_WIP = ARR as const; + export const $ArrayWithArray = { type: 'array', contains: { @@ -134,6 +193,8 @@ export const $ArrayWithArray = { }, } as const; +export const $ArrayWithProperties_WIP = ARR as const; + export const $ArrayWithProperties = { type: 'array', contains: { @@ -148,6 +209,8 @@ export const $ArrayWithProperties = { }, } as const; +export const $ArrayWithAnyOfProperties_WIP = ARR as const; + export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -172,6 +235,8 @@ export const $ArrayWithAnyOfProperties = { }, } as const; +export const $AnyOfAnyAndNull_WIP = INTERFACE as const; + export const $AnyOfAnyAndNull = { properties: { data: { @@ -188,6 +253,8 @@ export const $AnyOfAnyAndNull = { }, } as const; +export const $AnyOfArrays_WIP = INTERFACE as const; + export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -216,6 +283,8 @@ export const $AnyOfArrays = { }, } as const; +export const $DictionaryWithString_WIP = DICT as const; + export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -223,6 +292,8 @@ export const $DictionaryWithString = { }, } as const; +export const $DictionaryWithReference_WIP = DICT as const; + export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -230,6 +301,8 @@ export const $DictionaryWithReference = { }, } as const; +export const $DictionaryWithArray_WIP = DICT as const; + export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -240,6 +313,8 @@ export const $DictionaryWithArray = { }, } as const; +export const $DictionaryWithDictionary_WIP = DICT as const; + export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -250,6 +325,8 @@ export const $DictionaryWithDictionary = { }, } as const; +export const $DictionaryWithProperties_WIP = DICT as const; + export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -264,6 +341,8 @@ export const $DictionaryWithProperties = { }, } as const; +export const $ModelWithInteger_WIP = INTERFACE as const; + export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -274,6 +353,8 @@ export const $ModelWithInteger = { }, } as const; +export const $ModelWithBoolean_WIP = INTERFACE as const; + export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -284,6 +365,8 @@ export const $ModelWithBoolean = { }, } as const; +export const $ModelWithString_WIP = INTERFACE as const; + export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -294,6 +377,8 @@ export const $ModelWithString = { }, } as const; +export const $ModelWithNullableString_WIP = INTERFACE as const; + export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -326,6 +411,8 @@ export const $ModelWithNullableString = { }, } as const; +export const $ModelWithEnum_WIP = INTERFACE as const; + export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -344,6 +431,8 @@ export const $ModelWithEnum = { }, } as const; +export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; + export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -355,6 +444,8 @@ export const $ModelWithEnumWithHyphen = { }, } as const; +export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; + export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -365,6 +456,8 @@ export const $ModelWithEnumFromDescription = { }, } as const; +export const $ModelWithNestedEnums_WIP = INTERFACE as const; + export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -403,6 +496,8 @@ export const $ModelWithNestedEnums = { }, } as const; +export const $ModelWithReference_WIP = INTERFACE as const; + export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -412,6 +507,8 @@ export const $ModelWithReference = { }, } as const; +export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -436,6 +533,8 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; +export const $ModelWithArray_WIP = INTERFACE as const; + export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -460,6 +559,8 @@ export const $ModelWithArray = { }, } as const; +export const $ModelWithDictionary_WIP = INTERFACE as const; + export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -472,6 +573,8 @@ export const $ModelWithDictionary = { }, } as const; +export const $DeprecatedModel_WIP = INTERFACE as const; + export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -482,6 +585,8 @@ export const $DeprecatedModel = { }, } as const; +export const $ModelWithCircularReference_WIP = INTERFACE as const; + export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -491,6 +596,8 @@ export const $ModelWithCircularReference = { }, } as const; +export const $CompositionWithOneOf_WIP = INTERFACE as const; + export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -514,6 +621,8 @@ export const $CompositionWithOneOf = { }, } as const; +export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -541,6 +650,8 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; +export const $ModelCircle_WIP = INTERFACE as const; + export const $ModelCircle = { description: `Circle`, properties: { @@ -554,6 +665,8 @@ export const $ModelCircle = { }, } as const; +export const $ModelSquare_WIP = INTERFACE as const; + export const $ModelSquare = { description: `Square`, properties: { @@ -567,6 +680,8 @@ export const $ModelSquare = { }, } as const; +export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; + export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -580,6 +695,8 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; +export const $CompositionWithAnyOf_WIP = INTERFACE as const; + export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -603,6 +720,8 @@ export const $CompositionWithAnyOf = { }, } as const; +export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -630,6 +749,8 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; +export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -669,15 +790,24 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; +export const $Enum1_WIP = { + type: 'Enum', + enum: ['Bird', 'Dog'], +} as const; + export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; +export const $ConstValue_WIP = GENERIC as const; + export const $ConstValue = { type: '"ConstValue"', } as const; +export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -706,6 +836,8 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; +export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -734,6 +866,8 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; +export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -754,6 +888,8 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; +export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -777,6 +913,8 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; +export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -808,6 +946,8 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; +export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -836,6 +976,8 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; +export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -864,6 +1006,8 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; +export const $CompositionBaseModel_WIP = INTERFACE as const; + export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -876,6 +1020,8 @@ export const $CompositionBaseModel = { }, } as const; +export const $CompositionExtendedModel_WIP = COMP as const; + export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -902,6 +1048,8 @@ export const $CompositionExtendedModel = { ], } as const; +export const $ModelWithProperties_WIP = INTERFACE as const; + export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -951,6 +1099,8 @@ export const $ModelWithProperties = { }, } as const; +export const $ModelWithNestedProperties_WIP = INTERFACE as const; + export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -977,6 +1127,8 @@ export const $ModelWithNestedProperties = { }, } as const; +export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; + export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -986,6 +1138,8 @@ export const $ModelWithDuplicateProperties = { }, } as const; +export const $ModelWithOrderedProperties_WIP = INTERFACE as const; + export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1001,6 +1155,8 @@ export const $ModelWithOrderedProperties = { }, } as const; +export const $ModelWithDuplicateImports_WIP = INTERFACE as const; + export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1016,6 +1172,8 @@ export const $ModelWithDuplicateImports = { }, } as const; +export const $ModelThatExtends_WIP = COMP as const; + export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1036,6 +1194,8 @@ export const $ModelThatExtends = { ], } as const; +export const $ModelThatExtendsExtends_WIP = COMP as const; + export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1059,6 +1219,8 @@ export const $ModelThatExtendsExtends = { ], } as const; +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1105,6 +1267,8 @@ export const $ModelWithPattern = { }, } as const; +export const $File_WIP = INTERFACE as const; + export const $File = { properties: { id: { @@ -1136,6 +1300,8 @@ export const $File = { }, } as const; +export const $_default_WIP = INTERFACE as const; + export const $_default = { properties: { name: { @@ -1144,6 +1310,8 @@ export const $_default = { }, } as const; +export const $Pageable_WIP = INTERFACE as const; + export const $Pageable = { properties: { page: { @@ -1166,6 +1334,8 @@ export const $Pageable = { }, } as const; +export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; + export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1173,6 +1343,8 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1180,6 +1352,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1187,6 +1361,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; +export const $ModelWithConst_WIP = INTERFACE as const; + export const $ModelWithConst = { properties: { String: { @@ -1204,6 +1380,8 @@ export const $ModelWithConst = { }, } as const; +export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; + export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1214,6 +1392,8 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; +export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; + export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1241,6 +1421,8 @@ export const $NestedAnyOfArraysNullable = { }, } as const; +export const $CompositionWithOneOfAndProperties_WIP = COMP as const; + export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1289,6 +1471,8 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; +export const $NullableObject_WIP = INTERFACE as const; + export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1300,6 +1484,8 @@ export const $NullableObject = { isNullable: true, } as const; +export const $ModelWithNullableObject_WIP = INTERFACE as const; + export const $ModelWithNullableObject = { properties: { data: { @@ -1308,6 +1494,8 @@ export const $ModelWithNullableObject = { }, } as const; +export const $ModelWithOneOfEnum_WIP = COMP as const; + export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1380,16 +1568,28 @@ export const $ModelWithOneOfEnum = { ], } as const; +export const $ModelWithNestedArrayEnumsDataFoo_WIP = { + type: 'Enum', + enum: ['foo', 'bar'], +} as const; + export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; +export const $ModelWithNestedArrayEnumsDataBar_WIP = { + type: 'Enum', + enum: ['baz', 'qux'], +} as const; + export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; +export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1407,6 +1607,8 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; +export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1426,6 +1628,8 @@ export const $ModelWithNestedArrayEnums = { }, } as const; +export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; + export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1439,6 +1643,8 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; +export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1457,6 +1663,8 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; +export const $SimpleParameter_WIP = GENERIC as const; + export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap index e402b1ef7..0fea2e0b6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $CommentWithBreaks_WIP = GENERIC as const; + export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -6,61 +8,85 @@ Second line Fourth line`, } as const; +export const $CommentWithBackticks_WIP = GENERIC as const; + export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; +export const $CommentWithSlashes_WIP = GENERIC as const; + export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; +export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; + export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; +export const $CommentWithQuotes_WIP = GENERIC as const; + export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; +export const $CommentWithReservedCharacters_WIP = GENERIC as const; + export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; +export const $SimpleInteger_WIP = GENERIC as const; + export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; +export const $SimpleBoolean_WIP = GENERIC as const; + export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; +export const $SimpleString_WIP = GENERIC as const; + export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; +export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; + export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; +export const $SimpleFile_WIP = GENERIC as const; + export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; +export const $SimpleReference_WIP = GENERIC as const; + export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; +export const $SimpleStringWithPattern_WIP = GENERIC as const; + export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -69,32 +95,57 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; +export const $EnumWithStrings_WIP = { + type: 'Enum', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; +export const $EnumWithReplacedCharacters_WIP = { + type: 'Enum', + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], +} as const; + export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; +export const $EnumWithNumbers_WIP = { + type: 'Enum', + 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; + export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; +export const $EnumWithExtensions_WIP = { + type: 'Enum', + enum: [200, 400, 500], +} as const; + export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; +export const $ArrayWithNumbers_WIP = ARR as const; + export const $ArrayWithNumbers = { type: 'array', contains: { @@ -102,6 +153,8 @@ export const $ArrayWithNumbers = { }, } as const; +export const $ArrayWithBooleans_WIP = ARR as const; + export const $ArrayWithBooleans = { type: 'array', contains: { @@ -109,6 +162,8 @@ export const $ArrayWithBooleans = { }, } as const; +export const $ArrayWithStrings_WIP = ARR as const; + export const $ArrayWithStrings = { type: 'array', contains: { @@ -117,6 +172,8 @@ export const $ArrayWithStrings = { default: ['test'], } as const; +export const $ArrayWithReferences_WIP = ARR as const; + export const $ArrayWithReferences = { type: 'array', contains: { @@ -124,6 +181,8 @@ export const $ArrayWithReferences = { }, } as const; +export const $ArrayWithArray_WIP = ARR as const; + export const $ArrayWithArray = { type: 'array', contains: { @@ -134,6 +193,8 @@ export const $ArrayWithArray = { }, } as const; +export const $ArrayWithProperties_WIP = ARR as const; + export const $ArrayWithProperties = { type: 'array', contains: { @@ -148,6 +209,8 @@ export const $ArrayWithProperties = { }, } as const; +export const $ArrayWithAnyOfProperties_WIP = ARR as const; + export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -172,6 +235,8 @@ export const $ArrayWithAnyOfProperties = { }, } as const; +export const $AnyOfAnyAndNull_WIP = INTERFACE as const; + export const $AnyOfAnyAndNull = { properties: { data: { @@ -188,6 +253,8 @@ export const $AnyOfAnyAndNull = { }, } as const; +export const $AnyOfArrays_WIP = INTERFACE as const; + export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -216,6 +283,8 @@ export const $AnyOfArrays = { }, } as const; +export const $DictionaryWithString_WIP = DICT as const; + export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -223,6 +292,8 @@ export const $DictionaryWithString = { }, } as const; +export const $DictionaryWithReference_WIP = DICT as const; + export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -230,6 +301,8 @@ export const $DictionaryWithReference = { }, } as const; +export const $DictionaryWithArray_WIP = DICT as const; + export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -240,6 +313,8 @@ export const $DictionaryWithArray = { }, } as const; +export const $DictionaryWithDictionary_WIP = DICT as const; + export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -250,6 +325,8 @@ export const $DictionaryWithDictionary = { }, } as const; +export const $DictionaryWithProperties_WIP = DICT as const; + export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -264,6 +341,8 @@ export const $DictionaryWithProperties = { }, } as const; +export const $ModelWithInteger_WIP = INTERFACE as const; + export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -274,6 +353,8 @@ export const $ModelWithInteger = { }, } as const; +export const $ModelWithBoolean_WIP = INTERFACE as const; + export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -284,6 +365,8 @@ export const $ModelWithBoolean = { }, } as const; +export const $ModelWithString_WIP = INTERFACE as const; + export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -294,6 +377,8 @@ export const $ModelWithString = { }, } as const; +export const $ModelWithNullableString_WIP = INTERFACE as const; + export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -326,6 +411,8 @@ export const $ModelWithNullableString = { }, } as const; +export const $ModelWithEnum_WIP = INTERFACE as const; + export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -344,6 +431,8 @@ export const $ModelWithEnum = { }, } as const; +export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; + export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -355,6 +444,8 @@ export const $ModelWithEnumWithHyphen = { }, } as const; +export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; + export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -365,6 +456,8 @@ export const $ModelWithEnumFromDescription = { }, } as const; +export const $ModelWithNestedEnums_WIP = INTERFACE as const; + export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -403,6 +496,8 @@ export const $ModelWithNestedEnums = { }, } as const; +export const $ModelWithReference_WIP = INTERFACE as const; + export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -412,6 +507,8 @@ export const $ModelWithReference = { }, } as const; +export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -436,6 +533,8 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; +export const $ModelWithArray_WIP = INTERFACE as const; + export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -460,6 +559,8 @@ export const $ModelWithArray = { }, } as const; +export const $ModelWithDictionary_WIP = INTERFACE as const; + export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -472,6 +573,8 @@ export const $ModelWithDictionary = { }, } as const; +export const $DeprecatedModel_WIP = INTERFACE as const; + export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -482,6 +585,8 @@ export const $DeprecatedModel = { }, } as const; +export const $ModelWithCircularReference_WIP = INTERFACE as const; + export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -491,6 +596,8 @@ export const $ModelWithCircularReference = { }, } as const; +export const $CompositionWithOneOf_WIP = INTERFACE as const; + export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -514,6 +621,8 @@ export const $CompositionWithOneOf = { }, } as const; +export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -541,6 +650,8 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; +export const $ModelCircle_WIP = INTERFACE as const; + export const $ModelCircle = { description: `Circle`, properties: { @@ -554,6 +665,8 @@ export const $ModelCircle = { }, } as const; +export const $ModelSquare_WIP = INTERFACE as const; + export const $ModelSquare = { description: `Square`, properties: { @@ -567,6 +680,8 @@ export const $ModelSquare = { }, } as const; +export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; + export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -580,6 +695,8 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; +export const $CompositionWithAnyOf_WIP = INTERFACE as const; + export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -603,6 +720,8 @@ export const $CompositionWithAnyOf = { }, } as const; +export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -630,6 +749,8 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; +export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -669,15 +790,24 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; +export const $Enum1_WIP = { + type: 'Enum', + enum: ['Bird', 'Dog'], +} as const; + export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; +export const $ConstValue_WIP = GENERIC as const; + export const $ConstValue = { type: '"ConstValue"', } as const; +export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -706,6 +836,8 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; +export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -734,6 +866,8 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; +export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -754,6 +888,8 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; +export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -777,6 +913,8 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; +export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -808,6 +946,8 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; +export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -836,6 +976,8 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; +export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -864,6 +1006,8 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; +export const $CompositionBaseModel_WIP = INTERFACE as const; + export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -876,6 +1020,8 @@ export const $CompositionBaseModel = { }, } as const; +export const $CompositionExtendedModel_WIP = COMP as const; + export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -902,6 +1048,8 @@ export const $CompositionExtendedModel = { ], } as const; +export const $ModelWithProperties_WIP = INTERFACE as const; + export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -951,6 +1099,8 @@ export const $ModelWithProperties = { }, } as const; +export const $ModelWithNestedProperties_WIP = INTERFACE as const; + export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -977,6 +1127,8 @@ export const $ModelWithNestedProperties = { }, } as const; +export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; + export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -986,6 +1138,8 @@ export const $ModelWithDuplicateProperties = { }, } as const; +export const $ModelWithOrderedProperties_WIP = INTERFACE as const; + export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1001,6 +1155,8 @@ export const $ModelWithOrderedProperties = { }, } as const; +export const $ModelWithDuplicateImports_WIP = INTERFACE as const; + export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1016,6 +1172,8 @@ export const $ModelWithDuplicateImports = { }, } as const; +export const $ModelThatExtends_WIP = COMP as const; + export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1036,6 +1194,8 @@ export const $ModelThatExtends = { ], } as const; +export const $ModelThatExtendsExtends_WIP = COMP as const; + export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1059,6 +1219,8 @@ export const $ModelThatExtendsExtends = { ], } as const; +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1105,6 +1267,8 @@ export const $ModelWithPattern = { }, } as const; +export const $File_WIP = INTERFACE as const; + export const $File = { properties: { id: { @@ -1136,6 +1300,8 @@ export const $File = { }, } as const; +export const $_default_WIP = INTERFACE as const; + export const $_default = { properties: { name: { @@ -1144,6 +1310,8 @@ export const $_default = { }, } as const; +export const $Pageable_WIP = INTERFACE as const; + export const $Pageable = { properties: { page: { @@ -1166,6 +1334,8 @@ export const $Pageable = { }, } as const; +export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; + export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1173,6 +1343,8 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1180,6 +1352,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1187,6 +1361,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; +export const $ModelWithConst_WIP = INTERFACE as const; + export const $ModelWithConst = { properties: { String: { @@ -1204,6 +1380,8 @@ export const $ModelWithConst = { }, } as const; +export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; + export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1214,6 +1392,8 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; +export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; + export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1241,6 +1421,8 @@ export const $NestedAnyOfArraysNullable = { }, } as const; +export const $CompositionWithOneOfAndProperties_WIP = COMP as const; + export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1289,6 +1471,8 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; +export const $NullableObject_WIP = INTERFACE as const; + export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1300,6 +1484,8 @@ export const $NullableObject = { isNullable: true, } as const; +export const $ModelWithNullableObject_WIP = INTERFACE as const; + export const $ModelWithNullableObject = { properties: { data: { @@ -1308,6 +1494,8 @@ export const $ModelWithNullableObject = { }, } as const; +export const $ModelWithOneOfEnum_WIP = COMP as const; + export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1380,16 +1568,28 @@ export const $ModelWithOneOfEnum = { ], } as const; +export const $ModelWithNestedArrayEnumsDataFoo_WIP = { + type: 'Enum', + enum: ['foo', 'bar'], +} as const; + export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; +export const $ModelWithNestedArrayEnumsDataBar_WIP = { + type: 'Enum', + enum: ['baz', 'qux'], +} as const; + export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; +export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1407,6 +1607,8 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; +export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1426,6 +1628,8 @@ export const $ModelWithNestedArrayEnums = { }, } as const; +export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; + export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1439,6 +1643,8 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; +export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1457,6 +1663,8 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; +export const $SimpleParameter_WIP = GENERIC as const; + export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap index be54e210f..e8b2c0d07 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap index e402b1ef7..0fea2e0b6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $CommentWithBreaks_WIP = GENERIC as const; + export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -6,61 +8,85 @@ Second line Fourth line`, } as const; +export const $CommentWithBackticks_WIP = GENERIC as const; + export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; +export const $CommentWithSlashes_WIP = GENERIC as const; + export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; +export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; + export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; +export const $CommentWithQuotes_WIP = GENERIC as const; + export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; +export const $CommentWithReservedCharacters_WIP = GENERIC as const; + export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; +export const $SimpleInteger_WIP = GENERIC as const; + export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; +export const $SimpleBoolean_WIP = GENERIC as const; + export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; +export const $SimpleString_WIP = GENERIC as const; + export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; +export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; + export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; +export const $SimpleFile_WIP = GENERIC as const; + export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; +export const $SimpleReference_WIP = GENERIC as const; + export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; +export const $SimpleStringWithPattern_WIP = GENERIC as const; + export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -69,32 +95,57 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; +export const $EnumWithStrings_WIP = { + type: 'Enum', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; +export const $EnumWithReplacedCharacters_WIP = { + type: 'Enum', + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], +} as const; + export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; +export const $EnumWithNumbers_WIP = { + type: 'Enum', + 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; + export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; +export const $EnumWithExtensions_WIP = { + type: 'Enum', + enum: [200, 400, 500], +} as const; + export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; +export const $ArrayWithNumbers_WIP = ARR as const; + export const $ArrayWithNumbers = { type: 'array', contains: { @@ -102,6 +153,8 @@ export const $ArrayWithNumbers = { }, } as const; +export const $ArrayWithBooleans_WIP = ARR as const; + export const $ArrayWithBooleans = { type: 'array', contains: { @@ -109,6 +162,8 @@ export const $ArrayWithBooleans = { }, } as const; +export const $ArrayWithStrings_WIP = ARR as const; + export const $ArrayWithStrings = { type: 'array', contains: { @@ -117,6 +172,8 @@ export const $ArrayWithStrings = { default: ['test'], } as const; +export const $ArrayWithReferences_WIP = ARR as const; + export const $ArrayWithReferences = { type: 'array', contains: { @@ -124,6 +181,8 @@ export const $ArrayWithReferences = { }, } as const; +export const $ArrayWithArray_WIP = ARR as const; + export const $ArrayWithArray = { type: 'array', contains: { @@ -134,6 +193,8 @@ export const $ArrayWithArray = { }, } as const; +export const $ArrayWithProperties_WIP = ARR as const; + export const $ArrayWithProperties = { type: 'array', contains: { @@ -148,6 +209,8 @@ export const $ArrayWithProperties = { }, } as const; +export const $ArrayWithAnyOfProperties_WIP = ARR as const; + export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -172,6 +235,8 @@ export const $ArrayWithAnyOfProperties = { }, } as const; +export const $AnyOfAnyAndNull_WIP = INTERFACE as const; + export const $AnyOfAnyAndNull = { properties: { data: { @@ -188,6 +253,8 @@ export const $AnyOfAnyAndNull = { }, } as const; +export const $AnyOfArrays_WIP = INTERFACE as const; + export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -216,6 +283,8 @@ export const $AnyOfArrays = { }, } as const; +export const $DictionaryWithString_WIP = DICT as const; + export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -223,6 +292,8 @@ export const $DictionaryWithString = { }, } as const; +export const $DictionaryWithReference_WIP = DICT as const; + export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -230,6 +301,8 @@ export const $DictionaryWithReference = { }, } as const; +export const $DictionaryWithArray_WIP = DICT as const; + export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -240,6 +313,8 @@ export const $DictionaryWithArray = { }, } as const; +export const $DictionaryWithDictionary_WIP = DICT as const; + export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -250,6 +325,8 @@ export const $DictionaryWithDictionary = { }, } as const; +export const $DictionaryWithProperties_WIP = DICT as const; + export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -264,6 +341,8 @@ export const $DictionaryWithProperties = { }, } as const; +export const $ModelWithInteger_WIP = INTERFACE as const; + export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -274,6 +353,8 @@ export const $ModelWithInteger = { }, } as const; +export const $ModelWithBoolean_WIP = INTERFACE as const; + export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -284,6 +365,8 @@ export const $ModelWithBoolean = { }, } as const; +export const $ModelWithString_WIP = INTERFACE as const; + export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -294,6 +377,8 @@ export const $ModelWithString = { }, } as const; +export const $ModelWithNullableString_WIP = INTERFACE as const; + export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -326,6 +411,8 @@ export const $ModelWithNullableString = { }, } as const; +export const $ModelWithEnum_WIP = INTERFACE as const; + export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -344,6 +431,8 @@ export const $ModelWithEnum = { }, } as const; +export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; + export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -355,6 +444,8 @@ export const $ModelWithEnumWithHyphen = { }, } as const; +export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; + export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -365,6 +456,8 @@ export const $ModelWithEnumFromDescription = { }, } as const; +export const $ModelWithNestedEnums_WIP = INTERFACE as const; + export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -403,6 +496,8 @@ export const $ModelWithNestedEnums = { }, } as const; +export const $ModelWithReference_WIP = INTERFACE as const; + export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -412,6 +507,8 @@ export const $ModelWithReference = { }, } as const; +export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -436,6 +533,8 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; +export const $ModelWithArray_WIP = INTERFACE as const; + export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -460,6 +559,8 @@ export const $ModelWithArray = { }, } as const; +export const $ModelWithDictionary_WIP = INTERFACE as const; + export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -472,6 +573,8 @@ export const $ModelWithDictionary = { }, } as const; +export const $DeprecatedModel_WIP = INTERFACE as const; + export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -482,6 +585,8 @@ export const $DeprecatedModel = { }, } as const; +export const $ModelWithCircularReference_WIP = INTERFACE as const; + export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -491,6 +596,8 @@ export const $ModelWithCircularReference = { }, } as const; +export const $CompositionWithOneOf_WIP = INTERFACE as const; + export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -514,6 +621,8 @@ export const $CompositionWithOneOf = { }, } as const; +export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -541,6 +650,8 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; +export const $ModelCircle_WIP = INTERFACE as const; + export const $ModelCircle = { description: `Circle`, properties: { @@ -554,6 +665,8 @@ export const $ModelCircle = { }, } as const; +export const $ModelSquare_WIP = INTERFACE as const; + export const $ModelSquare = { description: `Square`, properties: { @@ -567,6 +680,8 @@ export const $ModelSquare = { }, } as const; +export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; + export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -580,6 +695,8 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; +export const $CompositionWithAnyOf_WIP = INTERFACE as const; + export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -603,6 +720,8 @@ export const $CompositionWithAnyOf = { }, } as const; +export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -630,6 +749,8 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; +export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -669,15 +790,24 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; +export const $Enum1_WIP = { + type: 'Enum', + enum: ['Bird', 'Dog'], +} as const; + export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; +export const $ConstValue_WIP = GENERIC as const; + export const $ConstValue = { type: '"ConstValue"', } as const; +export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -706,6 +836,8 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; +export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -734,6 +866,8 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; +export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -754,6 +888,8 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; +export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -777,6 +913,8 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; +export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -808,6 +946,8 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; +export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -836,6 +976,8 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; +export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -864,6 +1006,8 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; +export const $CompositionBaseModel_WIP = INTERFACE as const; + export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -876,6 +1020,8 @@ export const $CompositionBaseModel = { }, } as const; +export const $CompositionExtendedModel_WIP = COMP as const; + export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -902,6 +1048,8 @@ export const $CompositionExtendedModel = { ], } as const; +export const $ModelWithProperties_WIP = INTERFACE as const; + export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -951,6 +1099,8 @@ export const $ModelWithProperties = { }, } as const; +export const $ModelWithNestedProperties_WIP = INTERFACE as const; + export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -977,6 +1127,8 @@ export const $ModelWithNestedProperties = { }, } as const; +export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; + export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -986,6 +1138,8 @@ export const $ModelWithDuplicateProperties = { }, } as const; +export const $ModelWithOrderedProperties_WIP = INTERFACE as const; + export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1001,6 +1155,8 @@ export const $ModelWithOrderedProperties = { }, } as const; +export const $ModelWithDuplicateImports_WIP = INTERFACE as const; + export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1016,6 +1172,8 @@ export const $ModelWithDuplicateImports = { }, } as const; +export const $ModelThatExtends_WIP = COMP as const; + export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1036,6 +1194,8 @@ export const $ModelThatExtends = { ], } as const; +export const $ModelThatExtendsExtends_WIP = COMP as const; + export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1059,6 +1219,8 @@ export const $ModelThatExtendsExtends = { ], } as const; +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1105,6 +1267,8 @@ export const $ModelWithPattern = { }, } as const; +export const $File_WIP = INTERFACE as const; + export const $File = { properties: { id: { @@ -1136,6 +1300,8 @@ export const $File = { }, } as const; +export const $_default_WIP = INTERFACE as const; + export const $_default = { properties: { name: { @@ -1144,6 +1310,8 @@ export const $_default = { }, } as const; +export const $Pageable_WIP = INTERFACE as const; + export const $Pageable = { properties: { page: { @@ -1166,6 +1334,8 @@ export const $Pageable = { }, } as const; +export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; + export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1173,6 +1343,8 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1180,6 +1352,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1187,6 +1361,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; +export const $ModelWithConst_WIP = INTERFACE as const; + export const $ModelWithConst = { properties: { String: { @@ -1204,6 +1380,8 @@ export const $ModelWithConst = { }, } as const; +export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; + export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1214,6 +1392,8 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; +export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; + export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1241,6 +1421,8 @@ export const $NestedAnyOfArraysNullable = { }, } as const; +export const $CompositionWithOneOfAndProperties_WIP = COMP as const; + export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1289,6 +1471,8 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; +export const $NullableObject_WIP = INTERFACE as const; + export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1300,6 +1484,8 @@ export const $NullableObject = { isNullable: true, } as const; +export const $ModelWithNullableObject_WIP = INTERFACE as const; + export const $ModelWithNullableObject = { properties: { data: { @@ -1308,6 +1494,8 @@ export const $ModelWithNullableObject = { }, } as const; +export const $ModelWithOneOfEnum_WIP = COMP as const; + export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1380,16 +1568,28 @@ export const $ModelWithOneOfEnum = { ], } as const; +export const $ModelWithNestedArrayEnumsDataFoo_WIP = { + type: 'Enum', + enum: ['foo', 'bar'], +} as const; + export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; +export const $ModelWithNestedArrayEnumsDataBar_WIP = { + type: 'Enum', + enum: ['baz', 'qux'], +} as const; + export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; +export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1407,6 +1607,8 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; +export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1426,6 +1628,8 @@ export const $ModelWithNestedArrayEnums = { }, } as const; +export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; + export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1439,6 +1643,8 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; +export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1457,6 +1663,8 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; +export const $SimpleParameter_WIP = GENERIC as const; + export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap index e402b1ef7..0fea2e0b6 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap @@ -1,3 +1,5 @@ +export const $CommentWithBreaks_WIP = GENERIC as const; + export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -6,61 +8,85 @@ Second line Fourth line`, } as const; +export const $CommentWithBackticks_WIP = GENERIC as const; + export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; +export const $CommentWithSlashes_WIP = GENERIC as const; + export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; +export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; + export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; +export const $CommentWithQuotes_WIP = GENERIC as const; + export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; +export const $CommentWithReservedCharacters_WIP = GENERIC as const; + export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; +export const $SimpleInteger_WIP = GENERIC as const; + export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; +export const $SimpleBoolean_WIP = GENERIC as const; + export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; +export const $SimpleString_WIP = GENERIC as const; + export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; +export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; + export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; +export const $SimpleFile_WIP = GENERIC as const; + export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; +export const $SimpleReference_WIP = GENERIC as const; + export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; +export const $SimpleStringWithPattern_WIP = GENERIC as const; + export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -69,32 +95,57 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; +export const $EnumWithStrings_WIP = { + type: 'Enum', + enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], +} as const; + export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; +export const $EnumWithReplacedCharacters_WIP = { + type: 'Enum', + enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], +} as const; + export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; +export const $EnumWithNumbers_WIP = { + type: 'Enum', + 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; + export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; +export const $EnumWithExtensions_WIP = { + type: 'Enum', + enum: [200, 400, 500], +} as const; + export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; +export const $ArrayWithNumbers_WIP = ARR as const; + export const $ArrayWithNumbers = { type: 'array', contains: { @@ -102,6 +153,8 @@ export const $ArrayWithNumbers = { }, } as const; +export const $ArrayWithBooleans_WIP = ARR as const; + export const $ArrayWithBooleans = { type: 'array', contains: { @@ -109,6 +162,8 @@ export const $ArrayWithBooleans = { }, } as const; +export const $ArrayWithStrings_WIP = ARR as const; + export const $ArrayWithStrings = { type: 'array', contains: { @@ -117,6 +172,8 @@ export const $ArrayWithStrings = { default: ['test'], } as const; +export const $ArrayWithReferences_WIP = ARR as const; + export const $ArrayWithReferences = { type: 'array', contains: { @@ -124,6 +181,8 @@ export const $ArrayWithReferences = { }, } as const; +export const $ArrayWithArray_WIP = ARR as const; + export const $ArrayWithArray = { type: 'array', contains: { @@ -134,6 +193,8 @@ export const $ArrayWithArray = { }, } as const; +export const $ArrayWithProperties_WIP = ARR as const; + export const $ArrayWithProperties = { type: 'array', contains: { @@ -148,6 +209,8 @@ export const $ArrayWithProperties = { }, } as const; +export const $ArrayWithAnyOfProperties_WIP = ARR as const; + export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -172,6 +235,8 @@ export const $ArrayWithAnyOfProperties = { }, } as const; +export const $AnyOfAnyAndNull_WIP = INTERFACE as const; + export const $AnyOfAnyAndNull = { properties: { data: { @@ -188,6 +253,8 @@ export const $AnyOfAnyAndNull = { }, } as const; +export const $AnyOfArrays_WIP = INTERFACE as const; + export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -216,6 +283,8 @@ export const $AnyOfArrays = { }, } as const; +export const $DictionaryWithString_WIP = DICT as const; + export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -223,6 +292,8 @@ export const $DictionaryWithString = { }, } as const; +export const $DictionaryWithReference_WIP = DICT as const; + export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -230,6 +301,8 @@ export const $DictionaryWithReference = { }, } as const; +export const $DictionaryWithArray_WIP = DICT as const; + export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -240,6 +313,8 @@ export const $DictionaryWithArray = { }, } as const; +export const $DictionaryWithDictionary_WIP = DICT as const; + export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -250,6 +325,8 @@ export const $DictionaryWithDictionary = { }, } as const; +export const $DictionaryWithProperties_WIP = DICT as const; + export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -264,6 +341,8 @@ export const $DictionaryWithProperties = { }, } as const; +export const $ModelWithInteger_WIP = INTERFACE as const; + export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -274,6 +353,8 @@ export const $ModelWithInteger = { }, } as const; +export const $ModelWithBoolean_WIP = INTERFACE as const; + export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -284,6 +365,8 @@ export const $ModelWithBoolean = { }, } as const; +export const $ModelWithString_WIP = INTERFACE as const; + export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -294,6 +377,8 @@ export const $ModelWithString = { }, } as const; +export const $ModelWithNullableString_WIP = INTERFACE as const; + export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -326,6 +411,8 @@ export const $ModelWithNullableString = { }, } as const; +export const $ModelWithEnum_WIP = INTERFACE as const; + export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -344,6 +431,8 @@ export const $ModelWithEnum = { }, } as const; +export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; + export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -355,6 +444,8 @@ export const $ModelWithEnumWithHyphen = { }, } as const; +export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; + export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -365,6 +456,8 @@ export const $ModelWithEnumFromDescription = { }, } as const; +export const $ModelWithNestedEnums_WIP = INTERFACE as const; + export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -403,6 +496,8 @@ export const $ModelWithNestedEnums = { }, } as const; +export const $ModelWithReference_WIP = INTERFACE as const; + export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -412,6 +507,8 @@ export const $ModelWithReference = { }, } as const; +export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -436,6 +533,8 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; +export const $ModelWithArray_WIP = INTERFACE as const; + export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -460,6 +559,8 @@ export const $ModelWithArray = { }, } as const; +export const $ModelWithDictionary_WIP = INTERFACE as const; + export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -472,6 +573,8 @@ export const $ModelWithDictionary = { }, } as const; +export const $DeprecatedModel_WIP = INTERFACE as const; + export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -482,6 +585,8 @@ export const $DeprecatedModel = { }, } as const; +export const $ModelWithCircularReference_WIP = INTERFACE as const; + export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -491,6 +596,8 @@ export const $ModelWithCircularReference = { }, } as const; +export const $CompositionWithOneOf_WIP = INTERFACE as const; + export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -514,6 +621,8 @@ export const $CompositionWithOneOf = { }, } as const; +export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -541,6 +650,8 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; +export const $ModelCircle_WIP = INTERFACE as const; + export const $ModelCircle = { description: `Circle`, properties: { @@ -554,6 +665,8 @@ export const $ModelCircle = { }, } as const; +export const $ModelSquare_WIP = INTERFACE as const; + export const $ModelSquare = { description: `Square`, properties: { @@ -567,6 +680,8 @@ export const $ModelSquare = { }, } as const; +export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; + export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -580,6 +695,8 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; +export const $CompositionWithAnyOf_WIP = INTERFACE as const; + export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -603,6 +720,8 @@ export const $CompositionWithAnyOf = { }, } as const; +export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -630,6 +749,8 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; +export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -669,15 +790,24 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; +export const $Enum1_WIP = { + type: 'Enum', + enum: ['Bird', 'Dog'], +} as const; + export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; +export const $ConstValue_WIP = GENERIC as const; + export const $ConstValue = { type: '"ConstValue"', } as const; +export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; + export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -706,6 +836,8 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; +export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -734,6 +866,8 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; +export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -754,6 +888,8 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; +export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -777,6 +913,8 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; +export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; + export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -808,6 +946,8 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; +export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -836,6 +976,8 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; +export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; + export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -864,6 +1006,8 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; +export const $CompositionBaseModel_WIP = INTERFACE as const; + export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -876,6 +1020,8 @@ export const $CompositionBaseModel = { }, } as const; +export const $CompositionExtendedModel_WIP = COMP as const; + export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -902,6 +1048,8 @@ export const $CompositionExtendedModel = { ], } as const; +export const $ModelWithProperties_WIP = INTERFACE as const; + export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -951,6 +1099,8 @@ export const $ModelWithProperties = { }, } as const; +export const $ModelWithNestedProperties_WIP = INTERFACE as const; + export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -977,6 +1127,8 @@ export const $ModelWithNestedProperties = { }, } as const; +export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; + export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -986,6 +1138,8 @@ export const $ModelWithDuplicateProperties = { }, } as const; +export const $ModelWithOrderedProperties_WIP = INTERFACE as const; + export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1001,6 +1155,8 @@ export const $ModelWithOrderedProperties = { }, } as const; +export const $ModelWithDuplicateImports_WIP = INTERFACE as const; + export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1016,6 +1172,8 @@ export const $ModelWithDuplicateImports = { }, } as const; +export const $ModelThatExtends_WIP = COMP as const; + export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1036,6 +1194,8 @@ export const $ModelThatExtends = { ], } as const; +export const $ModelThatExtendsExtends_WIP = COMP as const; + export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1059,6 +1219,8 @@ export const $ModelThatExtendsExtends = { ], } as const; +export const $ModelWithPattern_WIP = INTERFACE as const; + export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1105,6 +1267,8 @@ export const $ModelWithPattern = { }, } as const; +export const $File_WIP = INTERFACE as const; + export const $File = { properties: { id: { @@ -1136,6 +1300,8 @@ export const $File = { }, } as const; +export const $_default_WIP = INTERFACE as const; + export const $_default = { properties: { name: { @@ -1144,6 +1310,8 @@ export const $_default = { }, } as const; +export const $Pageable_WIP = INTERFACE as const; + export const $Pageable = { properties: { page: { @@ -1166,6 +1334,8 @@ export const $Pageable = { }, } as const; +export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; + export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1173,6 +1343,8 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1180,6 +1352,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; +export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; + export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1187,6 +1361,8 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; +export const $ModelWithConst_WIP = INTERFACE as const; + export const $ModelWithConst = { properties: { String: { @@ -1204,6 +1380,8 @@ export const $ModelWithConst = { }, } as const; +export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; + export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1214,6 +1392,8 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; +export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; + export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1241,6 +1421,8 @@ export const $NestedAnyOfArraysNullable = { }, } as const; +export const $CompositionWithOneOfAndProperties_WIP = COMP as const; + export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1289,6 +1471,8 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; +export const $NullableObject_WIP = INTERFACE as const; + export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1300,6 +1484,8 @@ export const $NullableObject = { isNullable: true, } as const; +export const $ModelWithNullableObject_WIP = INTERFACE as const; + export const $ModelWithNullableObject = { properties: { data: { @@ -1308,6 +1494,8 @@ export const $ModelWithNullableObject = { }, } as const; +export const $ModelWithOneOfEnum_WIP = COMP as const; + export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1380,16 +1568,28 @@ export const $ModelWithOneOfEnum = { ], } as const; +export const $ModelWithNestedArrayEnumsDataFoo_WIP = { + type: 'Enum', + enum: ['foo', 'bar'], +} as const; + export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; +export const $ModelWithNestedArrayEnumsDataBar_WIP = { + type: 'Enum', + enum: ['baz', 'qux'], +} as const; + export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; +export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1407,6 +1607,8 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; +export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; + export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1426,6 +1628,8 @@ export const $ModelWithNestedArrayEnums = { }, } as const; +export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; + export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1439,6 +1643,8 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; +export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; + export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1457,6 +1663,8 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; +export const $SimpleParameter_WIP = GENERIC as const; + export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, From e2d3aa0271c70b5dfd387c6c17f5052fe36d7a5b Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 5 Apr 2024 06:20:49 +0100 Subject: [PATCH 2/3] chore(schemas): use TypeScript Compiler API to create schemas --- packages/openapi-ts/package.json | 3 - packages/openapi-ts/src/compiler/utils.ts | 2 +- .../openapi-ts/src/utils/write/schemas.ts | 117 +++++++++++++----- .../openapi-ts/src/utils/write/services.ts | 18 +-- 4 files changed, 97 insertions(+), 43 deletions(-) diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index 10147365e..724fe543d 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -59,9 +59,6 @@ "engines": { "node": "^18.0.0 || >=20.0.0" }, - "peerDependencies": { - "typescript": "^5.x" - }, "dependencies": { "@apidevtools/json-schema-ref-parser": "11.5.4", "c12": "1.10.0", diff --git a/packages/openapi-ts/src/compiler/utils.ts b/packages/openapi-ts/src/compiler/utils.ts index 973081869..eb01528e2 100644 --- a/packages/openapi-ts/src/compiler/utils.ts +++ b/packages/openapi-ts/src/compiler/utils.ts @@ -15,7 +15,7 @@ const blankSourceFile = ts.createSourceFile('', '', CONFIG.scriptTarget, undefin * @param node - the node to print. * @returns string */ -export function toString(node: ts.Node): string { +export function tsNodeToString(node: ts.Node): string { const r = printer.printNode(ts.EmitHint.Unspecified, node, blankSourceFile); return decodeURIComponent(r); } diff --git a/packages/openapi-ts/src/utils/write/schemas.ts b/packages/openapi-ts/src/utils/write/schemas.ts index aab36994e..c731e1845 100644 --- a/packages/openapi-ts/src/utils/write/schemas.ts +++ b/packages/openapi-ts/src/utils/write/schemas.ts @@ -3,52 +3,102 @@ import path from 'node:path'; import ts from 'typescript'; +import { tsNodeToString } from '../../compiler/utils'; import type { Model } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { enumValue } from '../enum'; import type { Templates } from '../handlebars'; -const enumSchema = (config: Config, model: Model) => { - let properties = [ts.factory.createPropertyAssignment('type', ts.factory.createStringLiteral('Enum'))]; +const stringToInitializer = (value: string | string[]) => { + const initializer = Array.isArray(value) + ? ts.factory.createArrayLiteralExpression(value.map(v => ts.factory.createIdentifier(v))) + : ts.factory.createIdentifier(value); + return initializer; +}; - if (model.enum.length) { - const property = ts.factory.createPropertyAssignment( - 'enum', - ts.factory.createArrayLiteralExpression( - model.enum.map(enumerator => ts.factory.createIdentifier(enumValue(enumerator.value)!)) - ) - ); - properties = [...properties, property]; +const addObjectProperty = ( + properties: ts.PropertyAssignment[], + name: string, + value: string | string[] | ts.ObjectLiteralExpression +) => { + const initializer = !Array.isArray(value) && typeof value === 'object' ? value : stringToInitializer(value); + const property = ts.factory.createPropertyAssignment(name, initializer); + return [...properties, property]; +}; + +const addPropDefault = (model: Model, properties: ts.PropertyAssignment[]) => { + if (model.default === undefined) { + return properties; } + return addObjectProperty(properties, 'default', String(model.default)); +}; - if (model.default !== undefined) { - const value = ts.factory.createIdentifier(String(model.default)); - const property = ts.factory.createPropertyAssignment('default', value); - properties = [...properties, property]; +const addPropIsNullable = (model: Model, properties: ts.PropertyAssignment[]) => { + if (!model.isNullable) { + return properties; } + return addObjectProperty(properties, 'isNullable', 'true'); +}; + +const addPropIsReadOnly = (model: Model, properties: ts.PropertyAssignment[]) => { + if (!model.isReadOnly) { + return properties; + } + return addObjectProperty(properties, 'isReadOnly', 'true'); +}; - if (model.isReadOnly) { - const property = ts.factory.createPropertyAssignment('isReadOnly', ts.factory.createStringLiteral('true')); - properties = [...properties, property]; +const addPropIsRequired = (model: Model, properties: ts.PropertyAssignment[]) => { + if (!model.isRequired) { + return properties; } - if (model.isRequired) { - const property = ts.factory.createPropertyAssignment('isRequired', ts.factory.createStringLiteral('true')); - properties = [...properties, property]; + return addObjectProperty(properties, 'isRequired', 'true'); +}; + +const dictSchema = (config: Config, model: Model) => { + let properties = [ts.factory.createPropertyAssignment('type', ts.factory.createStringLiteral('dictionary'))]; + + if (model.link) { + // properties = addObjectProperty(properties, 'contains', exportSchema(config, model.link)); + properties = addObjectProperty(properties, 'contains', modelToJsonSchema(config, model.link)); + } else { + properties = addObjectProperty( + properties, + 'contains', + `{ + type: '${model.base}', + }` + ); } - if (model.isNullable) { - const property = ts.factory.createPropertyAssignment('isNullable', ts.factory.createStringLiteral('true')); - properties = [...properties, property]; + + properties = addPropDefault(model, properties); + properties = addPropIsNullable(model, properties); + properties = addPropIsReadOnly(model, properties); + properties = addPropIsRequired(model, properties); + + return ts.factory.createObjectLiteralExpression(properties); +}; + +const enumSchema = (config: Config, model: Model) => { + let properties = [ts.factory.createPropertyAssignment('type', ts.factory.createStringLiteral('Enum'))]; + + if (model.enum.length) { + properties = addObjectProperty( + properties, + 'enum', + model.enum.map(enumerator => enumValue(enumerator.value)!) + ); } + properties = addPropDefault(model, properties); + properties = addPropIsNullable(model, properties); + properties = addPropIsReadOnly(model, properties); + properties = addPropIsRequired(model, properties); + return ts.factory.createObjectLiteralExpression(properties); }; -const exportSchema = (config: Config, model: Model) => { - const file = ts.createSourceFile('', '', ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS); - const printer = ts.createPrinter({ - newLine: ts.NewLineKind.LineFeed, - }); +const modelToJsonSchema = (config: Config, model: Model) => { let jsonSchema = ts.factory.createObjectLiteralExpression([ ts.factory.createPropertyAssignment('firstKey', ts.factory.createStringLiteral('string expression')), ts.factory.createPropertyAssignment('secondKey', ts.factory.createNumericLiteral(0)), @@ -67,8 +117,7 @@ const exportSchema = (config: Config, model: Model) => { schema = 'ARR'; break; case 'dictionary': - // {{>schemaDictionary}} - schema = 'DICT'; + jsonSchema = dictSchema(config, model); break; case 'enum': jsonSchema = enumSchema(config, model); @@ -83,6 +132,11 @@ const exportSchema = (config: Config, model: Model) => { break; } + return jsonSchema; +}; + +const exportSchema = (config: Config, model: Model) => { + const jsonSchema = modelToJsonSchema(config, model); const statement = ts.factory.createVariableStatement( [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList( @@ -97,8 +151,7 @@ const exportSchema = (config: Config, model: Model) => { ts.NodeFlags.Const ) ); - - return printer.printNode(ts.EmitHint.Unspecified, statement, file); + return tsNodeToString(statement); }; /** diff --git a/packages/openapi-ts/src/utils/write/services.ts b/packages/openapi-ts/src/utils/write/services.ts index f10f22db4..ced062624 100644 --- a/packages/openapi-ts/src/utils/write/services.ts +++ b/packages/openapi-ts/src/utils/write/services.ts @@ -2,7 +2,7 @@ import { writeFileSync } from 'node:fs'; import path from 'node:path'; import compiler from '../../compiler'; -import { toString } from '../../compiler/utils'; +import { tsNodeToString } from '../../compiler/utils'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { operationDataType, type Templates } from '../handlebars'; @@ -43,22 +43,26 @@ export const writeClientServices = async ( // Import required packages and core files. const coreImports: string[] = []; if (config.client === 'angular') { - coreImports.push(toString(compiler.import.named('Injectable', '@angular/core'))); + coreImports.push(tsNodeToString(compiler.import.named('Injectable', '@angular/core'))); if (config.name === undefined) { - coreImports.push(toString(compiler.import.named('HttpClient', '@angular/common/http'))); + coreImports.push(tsNodeToString(compiler.import.named('HttpClient', '@angular/common/http'))); } - coreImports.push(toString(compiler.import.named({ isTypeOnly: true, name: 'Observable' }, 'rxjs'))); + coreImports.push(tsNodeToString(compiler.import.named({ isTypeOnly: true, name: 'Observable' }, 'rxjs'))); } else { coreImports.push( - toString(compiler.import.named({ isTypeOnly: true, name: 'CancelablePromise' }, './core/CancelablePromise')) + tsNodeToString( + compiler.import.named({ isTypeOnly: true, name: 'CancelablePromise' }, './core/CancelablePromise') + ) ); } if (config.serviceResponse === 'response') { - coreImports.push(toString(compiler.import.named({ isTypeOnly: true, name: 'ApiResult' }, './core/ApiResult'))); + coreImports.push( + tsNodeToString(compiler.import.named({ isTypeOnly: true, name: 'ApiResult' }, './core/ApiResult')) + ); } if (config.name) { coreImports.push( - toString( + tsNodeToString( compiler.import.named( { isTypeOnly: config.client !== 'angular', name: 'BaseHttpRequest' }, './core/BaseHttpRequest' From f1bc6113654068e99cb539c1b32ae68ee1b5fdd8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 5 Apr 2024 08:06:49 +0100 Subject: [PATCH 3/3] chore(schemas): use TypeScript Compiler API to create schemas --- .changeset/brave-mails-warn.md | 5 + .../openapi-ts/src/templates/exportSchema.hbs | 1 - .../src/templates/partials/schema.hbs | 17 -- .../src/templates/partials/schemaArray.hbs | 22 -- .../templates/partials/schemaComposition.hbs | 19 -- .../templates/partials/schemaDictionary.hbs | 22 -- .../src/templates/partials/schemaEnum.hbs | 18 -- .../src/templates/partials/schemaGeneric.hbs | 62 ------ .../templates/partials/schemaInterface.hbs | 26 --- .../src/utils/__tests__/handlebars.spec.ts | 1 - packages/openapi-ts/src/utils/handlebars.ts | 24 +- .../src/utils/write/__tests__/mocks.ts | 1 - .../src/utils/write/__tests__/schemas.spec.ts | 2 +- .../openapi-ts/src/utils/write/schemas.ts | 203 +++++++++++------ .../test/generated/v2/schemas.ts.snap | 107 --------- .../test/generated/v3/schemas.ts.snap | 208 ------------------ .../test/generated/v3_angular/schemas.ts.snap | 208 ------------------ .../test/generated/v3_date/schemas.ts.snap | 2 - .../v3_enums_typescript/schemas.ts.snap | 208 ------------------ .../generated/v3_experimental/schemas.ts.snap | 208 ------------------ .../test/generated/v3_models/index.ts.snap | 2 +- .../test/generated/v3_node/index.ts.snap | 4 +- 22 files changed, 143 insertions(+), 1227 deletions(-) create mode 100644 .changeset/brave-mails-warn.md delete mode 100644 packages/openapi-ts/src/templates/exportSchema.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schema.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaArray.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaComposition.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaDictionary.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaEnum.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaGeneric.hbs delete mode 100644 packages/openapi-ts/src/templates/partials/schemaInterface.hbs diff --git a/.changeset/brave-mails-warn.md b/.changeset/brave-mails-warn.md new file mode 100644 index 000000000..e78b2b402 --- /dev/null +++ b/.changeset/brave-mails-warn.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": patch +--- + +fix(api): use TypeScript Compiler API to create schemas diff --git a/packages/openapi-ts/src/templates/exportSchema.hbs b/packages/openapi-ts/src/templates/exportSchema.hbs deleted file mode 100644 index 004908bcf..000000000 --- a/packages/openapi-ts/src/templates/exportSchema.hbs +++ /dev/null @@ -1 +0,0 @@ -export const ${{{name}}} = {{>schema}} as const; diff --git a/packages/openapi-ts/src/templates/partials/schema.hbs b/packages/openapi-ts/src/templates/partials/schema.hbs deleted file mode 100644 index 14b9156b0..000000000 --- a/packages/openapi-ts/src/templates/partials/schema.hbs +++ /dev/null @@ -1,17 +0,0 @@ -{{#equals export 'interface'}} -{{>schemaInterface}} -{{else equals export 'enum'}} -{{>schemaEnum}} -{{else equals export 'array'}} -{{>schemaArray}} -{{else equals export 'dictionary'}} -{{>schemaDictionary}} -{{else equals export 'any-of'}} -{{>schemaComposition}} -{{else equals export 'all-of'}} -{{>schemaComposition}} -{{else equals export 'one-of'}} -{{>schemaComposition}} -{{else}} -{{>schemaGeneric}} -{{/equals}} diff --git a/packages/openapi-ts/src/templates/partials/schemaArray.hbs b/packages/openapi-ts/src/templates/partials/schemaArray.hbs deleted file mode 100644 index f49c04bb0..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaArray.hbs +++ /dev/null @@ -1,22 +0,0 @@ -{ - type: 'array', -{{#if link}} - contains: {{>schema link}}, -{{else}} - contains: { - type: '{{{base}}}', - }, -{{/if}} -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/openapi-ts/src/templates/partials/schemaComposition.hbs b/packages/openapi-ts/src/templates/partials/schemaComposition.hbs deleted file mode 100644 index c11f6bb2b..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaComposition.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{ - type: '{{export}}', -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} - contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}], -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/openapi-ts/src/templates/partials/schemaDictionary.hbs b/packages/openapi-ts/src/templates/partials/schemaDictionary.hbs deleted file mode 100644 index 41a7441dd..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaDictionary.hbs +++ /dev/null @@ -1,22 +0,0 @@ -{ - type: 'dictionary', -{{#if link}} - contains: {{>schema link}}, -{{else}} - contains: { - type: '{{{base}}}', - }, -{{/if}} -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/openapi-ts/src/templates/partials/schemaEnum.hbs b/packages/openapi-ts/src/templates/partials/schemaEnum.hbs deleted file mode 100644 index 0ad81c5c6..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaEnum.hbs +++ /dev/null @@ -1,18 +0,0 @@ -{ - type: 'Enum', -{{#if enum}} - enum: [{{#each enum}}{{{enumValue value}}},{{/each}}], -{{/if}} -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/openapi-ts/src/templates/partials/schemaGeneric.hbs b/packages/openapi-ts/src/templates/partials/schemaGeneric.hbs deleted file mode 100644 index a9d32ba98..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaGeneric.hbs +++ /dev/null @@ -1,62 +0,0 @@ -{ -{{#if type}} - type: '{{{type}}}', -{{/if}} -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -{{#if format}} - format: '{{{format}}}', -{{/if}} -{{#ifNotNullNotUndefined maximum}} - maximum: {{{maximum}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined exclusiveMaximum}} - exclusiveMaximum: {{{exclusiveMaximum}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined minimum}} - minimum: {{{minimum}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined exclusiveMinimum}} - exclusiveMinimum: {{{exclusiveMinimum}}}, -{{/ifNotNullNotUndefined}} -{{#if multipleOf}} - multipleOf: {{{multipleOf}}}, -{{/if}} -{{#ifNotNullNotUndefined maxLength}} - maxLength: {{{maxLength}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined minLength}} - minLength: {{{minLength}}}, -{{/ifNotNullNotUndefined}} -{{#if pattern}} - pattern: '{{{escapeNewline pattern}}}', -{{/if}} -{{#ifNotNullNotUndefined maxItems}} - maxItems: {{{maxItems}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined minItems}} - minItems: {{{minItems}}}, -{{/ifNotNullNotUndefined}} -{{#if uniqueItems}} - uniqueItems: {{{uniqueItems}}}, -{{/if}} -{{#ifNotNullNotUndefined maxProperties}} - maxProperties: {{{maxProperties}}}, -{{/ifNotNullNotUndefined}} -{{#ifNotNullNotUndefined minProperties}} - minProperties: {{{minProperties}}}, -{{/ifNotNullNotUndefined}} -} diff --git a/packages/openapi-ts/src/templates/partials/schemaInterface.hbs b/packages/openapi-ts/src/templates/partials/schemaInterface.hbs deleted file mode 100644 index fc9216fad..000000000 --- a/packages/openapi-ts/src/templates/partials/schemaInterface.hbs +++ /dev/null @@ -1,26 +0,0 @@ -{ -{{#if description}} - description: `{{{escapeDescription description}}}`, -{{/if}} - properties: { -{{#if properties}} - {{#each properties}} - {{#notEquals name "[key: string]"}} - {{{name}}}: {{>schema}}, - {{/notEquals}} - {{/each}} -{{/if}} - }, -{{#notEquals default undefined}} - default: {{{default}}}, -{{/notEquals}} -{{#if isReadOnly}} - isReadOnly: {{{isReadOnly}}}, -{{/if}} -{{#if isRequired}} - isRequired: {{{isRequired}}}, -{{/if}} -{{#if isNullable}} - isNullable: {{{isNullable}}}, -{{/if}} -} diff --git a/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts b/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts index e23088a35..4b7e34261 100644 --- a/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts +++ b/packages/openapi-ts/src/utils/__tests__/handlebars.spec.ts @@ -90,7 +90,6 @@ describe('registerHandlebarTemplates', () => { } ); expect(templates.exports.model).toBeDefined(); - expect(templates.exports.schema).toBeDefined(); expect(templates.exports.service).toBeDefined(); expect(templates.core.settings).toBeDefined(); expect(templates.core.apiError).toBeDefined(); diff --git a/packages/openapi-ts/src/utils/handlebars.ts b/packages/openapi-ts/src/utils/handlebars.ts index 526aa03fd..19df4e83f 100644 --- a/packages/openapi-ts/src/utils/handlebars.ts +++ b/packages/openapi-ts/src/utils/handlebars.ts @@ -49,7 +49,6 @@ import xhrGetResponseHeader from '../templates/core/xhr/getResponseHeader.hbs'; import xhrRequest from '../templates/core/xhr/request.hbs'; import xhrSendRequest from '../templates/core/xhr/sendRequest.hbs'; import templateExportModel from '../templates/exportModel.hbs'; -import templateExportSchema from '../templates/exportSchema.hbs'; import templateExportService from '../templates/exportService.hbs'; import partialBase from '../templates/partials/base.hbs'; import partialExportComposition from '../templates/partials/exportComposition.hbs'; @@ -62,13 +61,6 @@ import partialOperationParameters from '../templates/partials/operationParameter import partialOperationResult from '../templates/partials/operationResult.hbs'; import partialOperationTypes from '../templates/partials/operationTypes.hbs'; import partialRequestConfig from '../templates/partials/requestConfig.hbs'; -import partialSchema from '../templates/partials/schema.hbs'; -import partialSchemaArray from '../templates/partials/schemaArray.hbs'; -import partialSchemaComposition from '../templates/partials/schemaComposition.hbs'; -import partialSchemaDictionary from '../templates/partials/schemaDictionary.hbs'; -import partialSchemaEnum from '../templates/partials/schemaEnum.hbs'; -import partialSchemaGeneric from '../templates/partials/schemaGeneric.hbs'; -import partialSchemaInterface from '../templates/partials/schemaInterface.hbs'; import partialType from '../templates/partials/type.hbs'; import partialTypeArray from '../templates/partials/typeArray.hbs'; import partialTypeDictionary from '../templates/partials/typeDictionary.hbs'; @@ -94,6 +86,8 @@ const escapeComment = (value: string) => export const escapeDescription = (value: string) => value.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\${/g, '\\${'); +export const escapeNewline = (value: string) => value.replace(/\n/g, '\\n'); + const dataDestructure = (config: Config, operation: Operation) => { if (config.name) { if (config.useOptions) { @@ -264,10 +258,7 @@ export const registerHandlebarHelpers = (config: Config, client: Client): void = Handlebars.registerHelper('escapeComment', escapeComment); Handlebars.registerHelper('escapeDescription', escapeDescription); - - Handlebars.registerHelper('escapeNewline', function (value: string) { - return value.replace(/\n/g, '\\n'); - }); + Handlebars.registerHelper('escapeNewline', escapeNewline); Handlebars.registerHelper('exactArray', function (this: unknown, model: Model, options: Handlebars.HelperOptions) { if (model.export === 'array' && model.maxItems && model.minItems && model.maxItems === model.minItems) { @@ -368,7 +359,6 @@ export interface Templates { }; exports: { model: Handlebars.TemplateDelegate; - schema: Handlebars.TemplateDelegate; service: Handlebars.TemplateDelegate; }; } @@ -396,7 +386,6 @@ export const registerHandlebarTemplates = (config: Config, client: Client): Temp }, exports: { model: Handlebars.template(templateExportModel), - schema: Handlebars.template(templateExportSchema), service: Handlebars.template(templateExportService), }, }; @@ -413,13 +402,6 @@ export const registerHandlebarTemplates = (config: Config, client: Client): Temp Handlebars.registerPartial('operationResult', Handlebars.template(partialOperationResult)); Handlebars.registerPartial('operationTypes', Handlebars.template(partialOperationTypes)); Handlebars.registerPartial('requestConfig', Handlebars.template(partialRequestConfig)); - Handlebars.registerPartial('schema', Handlebars.template(partialSchema)); - Handlebars.registerPartial('schemaArray', Handlebars.template(partialSchemaArray)); - Handlebars.registerPartial('schemaComposition', Handlebars.template(partialSchemaComposition)); - Handlebars.registerPartial('schemaDictionary', Handlebars.template(partialSchemaDictionary)); - Handlebars.registerPartial('schemaEnum', Handlebars.template(partialSchemaEnum)); - Handlebars.registerPartial('schemaGeneric', Handlebars.template(partialSchemaGeneric)); - Handlebars.registerPartial('schemaInterface', Handlebars.template(partialSchemaInterface)); Handlebars.registerPartial('type', Handlebars.template(partialType)); Handlebars.registerPartial('typeArray', Handlebars.template(partialTypeArray)); Handlebars.registerPartial('typeDictionary', Handlebars.template(partialTypeDictionary)); diff --git a/packages/openapi-ts/src/utils/write/__tests__/mocks.ts b/packages/openapi-ts/src/utils/write/__tests__/mocks.ts index 5f8ecdc49..cb3bb47b1 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/mocks.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/mocks.ts @@ -17,7 +17,6 @@ export const mockTemplates: Templates = { }, exports: { model: vi.fn().mockReturnValue('model'), - schema: vi.fn().mockReturnValue('schema'), service: vi.fn().mockReturnValue('service'), }, }; diff --git a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts index 28370bea7..27567d117 100644 --- a/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts +++ b/packages/openapi-ts/src/utils/write/__tests__/schemas.spec.ts @@ -59,6 +59,6 @@ describe('writeClientSchemas', () => { write: true, }); - expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/schemas.ts'), expect.stringContaining('schema')); + expect(writeFileSync).toHaveBeenCalledWith(path.resolve('/', '/schemas.ts'), expect.anything()); }); }); diff --git a/packages/openapi-ts/src/utils/write/schemas.ts b/packages/openapi-ts/src/utils/write/schemas.ts index 7a93ef717..c463146b5 100644 --- a/packages/openapi-ts/src/utils/write/schemas.ts +++ b/packages/openapi-ts/src/utils/write/schemas.ts @@ -8,7 +8,7 @@ import type { Model } from '../../openApi'; import type { Client } from '../../types/client'; import type { Config } from '../../types/config'; import { enumValue } from '../enum'; -import { escapeDescription, type Templates } from '../handlebars'; +import { escapeDescription, escapeNewline, type Templates } from '../handlebars'; const valueToIdentifier = (value: string | ts.ObjectLiteralExpression) => { if (typeof value !== 'string') { @@ -35,23 +35,16 @@ const arraySchema = (config: Config, model: Model) => { if (model.link) { properties = addObjectProperty(properties, 'contains', modelToJsonSchema(config, model.link)); } else { - properties = addObjectProperty( - properties, - 'contains', - `{ - type: '${model.base}', - }` - ); + let props: ts.PropertyAssignment[] = []; + props = addObjectProperty(props, 'type', `'${model.base}'`); + const obj = ts.factory.createObjectLiteralExpression(props, true); + properties = addObjectProperty(properties, 'contains', obj); } if (model.default !== undefined) { properties = addObjectProperty(properties, 'default', String(model.default)); } - if (model.isNullable) { - properties = addObjectProperty(properties, 'isNullable', 'true'); - } - if (model.isReadOnly) { properties = addObjectProperty(properties, 'isReadOnly', 'true'); } @@ -60,7 +53,11 @@ const arraySchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'isRequired', 'true'); } - return ts.factory.createObjectLiteralExpression(properties); + if (model.isNullable) { + properties = addObjectProperty(properties, 'isNullable', 'true'); + } + + return ts.factory.createObjectLiteralExpression(properties, true); }; const compositionSchema = (config: Config, model: Model) => { @@ -70,22 +67,16 @@ const compositionSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'description', `\`${escapeDescription(model.description)}\``); } - if (model.properties.length) { - properties = addObjectProperty( - properties, - 'contains', - model.properties.map(property => modelToJsonSchema(config, property)) - ); - } + properties = addObjectProperty( + properties, + 'contains', + model.properties.map(property => modelToJsonSchema(config, property)) + ); if (model.default !== undefined) { properties = addObjectProperty(properties, 'default', String(model.default)); } - if (model.isNullable) { - properties = addObjectProperty(properties, 'isNullable', 'true'); - } - if (model.isReadOnly) { properties = addObjectProperty(properties, 'isReadOnly', 'true'); } @@ -94,7 +85,11 @@ const compositionSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'isRequired', 'true'); } - return ts.factory.createObjectLiteralExpression(properties); + if (model.isNullable) { + properties = addObjectProperty(properties, 'isNullable', 'true'); + } + + return ts.factory.createObjectLiteralExpression(properties, true); }; const dictSchema = (config: Config, model: Model) => { @@ -103,23 +98,16 @@ const dictSchema = (config: Config, model: Model) => { if (model.link) { properties = addObjectProperty(properties, 'contains', modelToJsonSchema(config, model.link)); } else { - properties = addObjectProperty( - properties, - 'contains', - `{ - type: '${model.base}', - }` - ); + let props: ts.PropertyAssignment[] = []; + props = addObjectProperty(props, 'type', `'${model.base}'`); + const obj = ts.factory.createObjectLiteralExpression(props, true); + properties = addObjectProperty(properties, 'contains', obj); } if (model.default !== undefined) { properties = addObjectProperty(properties, 'default', String(model.default)); } - if (model.isNullable) { - properties = addObjectProperty(properties, 'isNullable', 'true'); - } - if (model.isReadOnly) { properties = addObjectProperty(properties, 'isReadOnly', 'true'); } @@ -128,7 +116,11 @@ const dictSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'isRequired', 'true'); } - return ts.factory.createObjectLiteralExpression(properties); + if (model.isNullable) { + properties = addObjectProperty(properties, 'isNullable', 'true'); + } + + return ts.factory.createObjectLiteralExpression(properties, true); }; const enumSchema = (config: Config, model: Model) => { @@ -146,10 +138,36 @@ const enumSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'default', String(model.default)); } + if (model.isReadOnly) { + properties = addObjectProperty(properties, 'isReadOnly', 'true'); + } + + if (model.isRequired) { + properties = addObjectProperty(properties, 'isRequired', 'true'); + } + if (model.isNullable) { properties = addObjectProperty(properties, 'isNullable', 'true'); } + return ts.factory.createObjectLiteralExpression(properties, true); +}; + +const genericSchema = (config: Config, model: Model) => { + let properties: ts.PropertyAssignment[] = []; + + if (model.type) { + properties = addObjectProperty(properties, 'type', `'${model.type}'`); + } + + if (model.description) { + properties = addObjectProperty(properties, 'description', `\`${escapeDescription(model.description)}\``); + } + + if (model.default !== undefined) { + properties = addObjectProperty(properties, 'default', String(model.default)); + } + if (model.isReadOnly) { properties = addObjectProperty(properties, 'isReadOnly', 'true'); } @@ -158,7 +176,67 @@ const enumSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'isRequired', 'true'); } - return ts.factory.createObjectLiteralExpression(properties); + if (model.isNullable) { + properties = addObjectProperty(properties, 'isNullable', 'true'); + } + + if (model.format) { + properties = addObjectProperty(properties, 'format', `'${model.format}'`); + } + + if (model.maximum !== undefined && model.maximum !== null) { + properties = addObjectProperty(properties, 'maximum', String(model.maximum)); + } + + if (model.exclusiveMaximum !== undefined && model.exclusiveMaximum !== null) { + properties = addObjectProperty(properties, 'exclusiveMaximum', String(model.exclusiveMaximum)); + } + + if (model.minimum !== undefined && model.minimum !== null) { + properties = addObjectProperty(properties, 'minimum', String(model.minimum)); + } + + if (model.exclusiveMinimum !== undefined && model.exclusiveMinimum !== null) { + properties = addObjectProperty(properties, 'exclusiveMinimum', String(model.exclusiveMinimum)); + } + + if (model.multipleOf !== undefined && model.multipleOf !== null) { + properties = addObjectProperty(properties, 'multipleOf', String(model.multipleOf)); + } + + if (model.maxLength !== undefined && model.maxLength !== null) { + properties = addObjectProperty(properties, 'maxLength', String(model.maxLength)); + } + + if (model.minLength !== undefined && model.minLength !== null) { + properties = addObjectProperty(properties, 'minLength', String(model.minLength)); + } + + if (model.pattern) { + properties = addObjectProperty(properties, 'pattern', `'${escapeNewline(model.pattern)}'`); + } + + if (model.maxItems !== undefined && model.maxItems !== null) { + properties = addObjectProperty(properties, 'maxItems', String(model.maxItems)); + } + + if (model.minItems !== undefined && model.minItems !== null) { + properties = addObjectProperty(properties, 'minItems', String(model.minItems)); + } + + if (model.uniqueItems !== undefined && model.uniqueItems !== null) { + properties = addObjectProperty(properties, 'uniqueItems', String(model.uniqueItems)); + } + + if (model.maxProperties !== undefined && model.maxProperties !== null) { + properties = addObjectProperty(properties, 'maxProperties', String(model.maxProperties)); + } + + if (model.minProperties !== undefined && model.minProperties !== null) { + properties = addObjectProperty(properties, 'minProperties', String(model.minProperties)); + } + + return ts.factory.createObjectLiteralExpression(properties, true); }; const interfaceSchema = (config: Config, model: Model) => { @@ -174,17 +252,13 @@ const interfaceSchema = (config: Config, model: Model) => { .forEach(property => { props = addObjectProperty(props, property.name, modelToJsonSchema(config, property)); }); - const obj = ts.factory.createObjectLiteralExpression(props); + const obj = ts.factory.createObjectLiteralExpression(props, true); properties = addObjectProperty(properties, 'properties', obj); if (model.default !== undefined) { properties = addObjectProperty(properties, 'default', String(model.default)); } - if (model.isNullable) { - properties = addObjectProperty(properties, 'isNullable', 'true'); - } - if (model.isReadOnly) { properties = addObjectProperty(properties, 'isReadOnly', 'true'); } @@ -193,41 +267,30 @@ const interfaceSchema = (config: Config, model: Model) => { properties = addObjectProperty(properties, 'isRequired', 'true'); } - return ts.factory.createObjectLiteralExpression(properties); + if (model.isNullable) { + properties = addObjectProperty(properties, 'isNullable', 'true'); + } + + return ts.factory.createObjectLiteralExpression(properties, true); }; const modelToJsonSchema = (config: Config, model: Model) => { - let jsonSchema = ts.factory.createObjectLiteralExpression([ - ts.factory.createPropertyAssignment('firstKey', ts.factory.createStringLiteral('string expression')), - ts.factory.createPropertyAssignment('secondKey', ts.factory.createNumericLiteral(0)), - ]); - - let schema = ''; switch (model.export) { case 'all-of': case 'any-of': case 'one-of': - jsonSchema = compositionSchema(config, model); - break; + return compositionSchema(config, model); case 'array': - jsonSchema = arraySchema(config, model); - break; + return arraySchema(config, model); case 'dictionary': - jsonSchema = dictSchema(config, model); - break; + return dictSchema(config, model); case 'enum': - jsonSchema = enumSchema(config, model); - break; + return enumSchema(config, model); case 'interface': - jsonSchema = interfaceSchema(config, model); - break; + return interfaceSchema(config, model); default: - // {{>schemaGeneric}} - schema = 'GENERIC'; - break; + return genericSchema(config, model); } - - return jsonSchema; }; const exportSchema = (config: Config, model: Model) => { @@ -237,7 +300,7 @@ const exportSchema = (config: Config, model: Model) => { ts.factory.createVariableDeclarationList( [ ts.factory.createVariableDeclaration( - ts.factory.createIdentifier(`$${model.name}_WIP`), + ts.factory.createIdentifier(`$${model.name}`), undefined, undefined, ts.factory.createAsExpression(jsonSchema, ts.factory.createTypeReferenceNode('const')) @@ -269,12 +332,8 @@ export const writeClientSchemas = async ( let results: string[] = []; for (const model of client.models) { - const resultNew = exportSchema(config, model); - const result = templates.exports.schema({ - $config: config, - ...model, - }); - results = [...results, resultNew, result]; + const result = exportSchema(config, model); + results = [...results, result]; } await writeFileSync(path.resolve(outputPath, 'schemas.ts'), results.join('\n\n')); diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap index 29e25eefc..77ac1586b 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v2/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $CommentWithBreaks_WIP = GENERIC as const; - export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -8,85 +6,61 @@ Second line Fourth line`, } as const; -export const $CommentWithBackticks_WIP = GENERIC as const; - export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; -export const $CommentWithSlashes_WIP = GENERIC as const; - export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; -export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; - export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; -export const $CommentWithQuotes_WIP = GENERIC as const; - export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; -export const $CommentWithReservedCharacters_WIP = GENERIC as const; - export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; -export const $SimpleInteger_WIP = GENERIC as const; - export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; -export const $SimpleBoolean_WIP = GENERIC as const; - export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; -export const $SimpleString_WIP = GENERIC as const; - export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; - export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; -export const $SimpleFile_WIP = GENERIC as const; - export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; -export const $SimpleReference_WIP = GENERIC as const; - export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; -export const $SimpleStringWithPattern_WIP = GENERIC as const; - export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -94,45 +68,26 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; -export const $EnumWithStrings_WIP = { - type: 'Enum', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], -} as const; - export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; -export const $EnumWithNumbers_WIP = { - type: 'Enum', - 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; - export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; -export const $EnumWithExtensions_WIP = { - type: 'Enum', - enum: [200, 400, 500], -} as const; - export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; -export const $ArrayWithNumbers_WIP = ARR as const; - export const $ArrayWithNumbers = { type: 'array', contains: { @@ -140,8 +95,6 @@ export const $ArrayWithNumbers = { }, } as const; -export const $ArrayWithBooleans_WIP = ARR as const; - export const $ArrayWithBooleans = { type: 'array', contains: { @@ -149,8 +102,6 @@ export const $ArrayWithBooleans = { }, } as const; -export const $ArrayWithStrings_WIP = ARR as const; - export const $ArrayWithStrings = { type: 'array', contains: { @@ -158,8 +109,6 @@ export const $ArrayWithStrings = { }, } as const; -export const $ArrayWithReferences_WIP = ARR as const; - export const $ArrayWithReferences = { type: 'array', contains: { @@ -167,8 +116,6 @@ export const $ArrayWithReferences = { }, } as const; -export const $ArrayWithArray_WIP = ARR as const; - export const $ArrayWithArray = { type: 'array', contains: { @@ -179,8 +126,6 @@ export const $ArrayWithArray = { }, } as const; -export const $ArrayWithProperties_WIP = ARR as const; - export const $ArrayWithProperties = { type: 'array', contains: { @@ -195,8 +140,6 @@ export const $ArrayWithProperties = { }, } as const; -export const $DictionaryWithString_WIP = DICT as const; - export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -204,8 +147,6 @@ export const $DictionaryWithString = { }, } as const; -export const $DictionaryWithReference_WIP = DICT as const; - export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -213,8 +154,6 @@ export const $DictionaryWithReference = { }, } as const; -export const $DictionaryWithArray_WIP = DICT as const; - export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -225,8 +164,6 @@ export const $DictionaryWithArray = { }, } as const; -export const $DictionaryWithDictionary_WIP = DICT as const; - export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -237,8 +174,6 @@ export const $DictionaryWithDictionary = { }, } as const; -export const $DictionaryWithProperties_WIP = DICT as const; - export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -253,15 +188,11 @@ export const $DictionaryWithProperties = { }, } as const; -export const $Date_WIP = GENERIC as const; - export const $Date = { type: 'string', description: `This is a type-only model that defines Date as a string`, } as const; -export const $ModelWithInteger_WIP = INTERFACE as const; - export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -272,8 +203,6 @@ export const $ModelWithInteger = { }, } as const; -export const $ModelWithBoolean_WIP = INTERFACE as const; - export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -284,8 +213,6 @@ export const $ModelWithBoolean = { }, } as const; -export const $ModelWithString_WIP = INTERFACE as const; - export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -296,8 +223,6 @@ export const $ModelWithString = { }, } as const; -export const $ModelWithNullableString_WIP = INTERFACE as const; - export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -315,8 +240,6 @@ export const $ModelWithNullableString = { }, } as const; -export const $ModelWithEnum_WIP = INTERFACE as const; - export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -335,8 +258,6 @@ export const $ModelWithEnum = { }, } as const; -export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; - export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -347,8 +268,6 @@ export const $ModelWithEnumFromDescription = { }, } as const; -export const $ModelWithNestedEnums_WIP = INTERFACE as const; - export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -383,8 +302,6 @@ export const $ModelWithNestedEnums = { }, } as const; -export const $ModelWithReference_WIP = INTERFACE as const; - export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -394,8 +311,6 @@ export const $ModelWithReference = { }, } as const; -export const $ModelWithArray_WIP = INTERFACE as const; - export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -420,8 +335,6 @@ export const $ModelWithArray = { }, } as const; -export const $ModelWithDictionary_WIP = INTERFACE as const; - export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -434,8 +347,6 @@ export const $ModelWithDictionary = { }, } as const; -export const $ModelWithCircularReference_WIP = INTERFACE as const; - export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -445,8 +356,6 @@ export const $ModelWithCircularReference = { }, } as const; -export const $ModelWithProperties_WIP = INTERFACE as const; - export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -491,8 +400,6 @@ export const $ModelWithProperties = { }, } as const; -export const $ModelWithNestedProperties_WIP = INTERFACE as const; - export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -516,8 +423,6 @@ export const $ModelWithNestedProperties = { }, } as const; -export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; - export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -527,8 +432,6 @@ export const $ModelWithDuplicateProperties = { }, } as const; -export const $ModelWithOrderedProperties_WIP = INTERFACE as const; - export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -544,8 +447,6 @@ export const $ModelWithOrderedProperties = { }, } as const; -export const $ModelWithDuplicateImports_WIP = INTERFACE as const; - export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -561,8 +462,6 @@ export const $ModelWithDuplicateImports = { }, } as const; -export const $ModelThatExtends_WIP = COMP as const; - export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -583,8 +482,6 @@ export const $ModelThatExtends = { ], } as const; -export const $ModelThatExtendsExtends_WIP = COMP as const; - export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -608,8 +505,6 @@ export const $ModelThatExtendsExtends = { ], } as const; -export const $_default_WIP = INTERFACE as const; - export const $_default = { properties: { name: { @@ -618,8 +513,6 @@ export const $_default = { }, } as const; -export const $ModelWithPattern_WIP = INTERFACE as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap index 0fea2e0b6..e402b1ef7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $CommentWithBreaks_WIP = GENERIC as const; - export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -8,85 +6,61 @@ Second line Fourth line`, } as const; -export const $CommentWithBackticks_WIP = GENERIC as const; - export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; -export const $CommentWithSlashes_WIP = GENERIC as const; - export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; -export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; - export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; -export const $CommentWithQuotes_WIP = GENERIC as const; - export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; -export const $CommentWithReservedCharacters_WIP = GENERIC as const; - export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; -export const $SimpleInteger_WIP = GENERIC as const; - export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; -export const $SimpleBoolean_WIP = GENERIC as const; - export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; -export const $SimpleString_WIP = GENERIC as const; - export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; - export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; -export const $SimpleFile_WIP = GENERIC as const; - export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; -export const $SimpleReference_WIP = GENERIC as const; - export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; -export const $SimpleStringWithPattern_WIP = GENERIC as const; - export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -95,57 +69,32 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; -export const $EnumWithStrings_WIP = { - type: 'Enum', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], -} as const; - export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; -export const $EnumWithReplacedCharacters_WIP = { - type: 'Enum', - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], -} as const; - export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; -export const $EnumWithNumbers_WIP = { - type: 'Enum', - 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; - export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; -export const $EnumWithExtensions_WIP = { - type: 'Enum', - enum: [200, 400, 500], -} as const; - export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; -export const $ArrayWithNumbers_WIP = ARR as const; - export const $ArrayWithNumbers = { type: 'array', contains: { @@ -153,8 +102,6 @@ export const $ArrayWithNumbers = { }, } as const; -export const $ArrayWithBooleans_WIP = ARR as const; - export const $ArrayWithBooleans = { type: 'array', contains: { @@ -162,8 +109,6 @@ export const $ArrayWithBooleans = { }, } as const; -export const $ArrayWithStrings_WIP = ARR as const; - export const $ArrayWithStrings = { type: 'array', contains: { @@ -172,8 +117,6 @@ export const $ArrayWithStrings = { default: ['test'], } as const; -export const $ArrayWithReferences_WIP = ARR as const; - export const $ArrayWithReferences = { type: 'array', contains: { @@ -181,8 +124,6 @@ export const $ArrayWithReferences = { }, } as const; -export const $ArrayWithArray_WIP = ARR as const; - export const $ArrayWithArray = { type: 'array', contains: { @@ -193,8 +134,6 @@ export const $ArrayWithArray = { }, } as const; -export const $ArrayWithProperties_WIP = ARR as const; - export const $ArrayWithProperties = { type: 'array', contains: { @@ -209,8 +148,6 @@ export const $ArrayWithProperties = { }, } as const; -export const $ArrayWithAnyOfProperties_WIP = ARR as const; - export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -235,8 +172,6 @@ export const $ArrayWithAnyOfProperties = { }, } as const; -export const $AnyOfAnyAndNull_WIP = INTERFACE as const; - export const $AnyOfAnyAndNull = { properties: { data: { @@ -253,8 +188,6 @@ export const $AnyOfAnyAndNull = { }, } as const; -export const $AnyOfArrays_WIP = INTERFACE as const; - export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -283,8 +216,6 @@ export const $AnyOfArrays = { }, } as const; -export const $DictionaryWithString_WIP = DICT as const; - export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -292,8 +223,6 @@ export const $DictionaryWithString = { }, } as const; -export const $DictionaryWithReference_WIP = DICT as const; - export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -301,8 +230,6 @@ export const $DictionaryWithReference = { }, } as const; -export const $DictionaryWithArray_WIP = DICT as const; - export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -313,8 +240,6 @@ export const $DictionaryWithArray = { }, } as const; -export const $DictionaryWithDictionary_WIP = DICT as const; - export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -325,8 +250,6 @@ export const $DictionaryWithDictionary = { }, } as const; -export const $DictionaryWithProperties_WIP = DICT as const; - export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -341,8 +264,6 @@ export const $DictionaryWithProperties = { }, } as const; -export const $ModelWithInteger_WIP = INTERFACE as const; - export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -353,8 +274,6 @@ export const $ModelWithInteger = { }, } as const; -export const $ModelWithBoolean_WIP = INTERFACE as const; - export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -365,8 +284,6 @@ export const $ModelWithBoolean = { }, } as const; -export const $ModelWithString_WIP = INTERFACE as const; - export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -377,8 +294,6 @@ export const $ModelWithString = { }, } as const; -export const $ModelWithNullableString_WIP = INTERFACE as const; - export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -411,8 +326,6 @@ export const $ModelWithNullableString = { }, } as const; -export const $ModelWithEnum_WIP = INTERFACE as const; - export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -431,8 +344,6 @@ export const $ModelWithEnum = { }, } as const; -export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; - export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -444,8 +355,6 @@ export const $ModelWithEnumWithHyphen = { }, } as const; -export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; - export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -456,8 +365,6 @@ export const $ModelWithEnumFromDescription = { }, } as const; -export const $ModelWithNestedEnums_WIP = INTERFACE as const; - export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -496,8 +403,6 @@ export const $ModelWithNestedEnums = { }, } as const; -export const $ModelWithReference_WIP = INTERFACE as const; - export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -507,8 +412,6 @@ export const $ModelWithReference = { }, } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -533,8 +436,6 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; -export const $ModelWithArray_WIP = INTERFACE as const; - export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -559,8 +460,6 @@ export const $ModelWithArray = { }, } as const; -export const $ModelWithDictionary_WIP = INTERFACE as const; - export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -573,8 +472,6 @@ export const $ModelWithDictionary = { }, } as const; -export const $DeprecatedModel_WIP = INTERFACE as const; - export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -585,8 +482,6 @@ export const $DeprecatedModel = { }, } as const; -export const $ModelWithCircularReference_WIP = INTERFACE as const; - export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -596,8 +491,6 @@ export const $ModelWithCircularReference = { }, } as const; -export const $CompositionWithOneOf_WIP = INTERFACE as const; - export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -621,8 +514,6 @@ export const $CompositionWithOneOf = { }, } as const; -export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -650,8 +541,6 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; -export const $ModelCircle_WIP = INTERFACE as const; - export const $ModelCircle = { description: `Circle`, properties: { @@ -665,8 +554,6 @@ export const $ModelCircle = { }, } as const; -export const $ModelSquare_WIP = INTERFACE as const; - export const $ModelSquare = { description: `Square`, properties: { @@ -680,8 +567,6 @@ export const $ModelSquare = { }, } as const; -export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; - export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -695,8 +580,6 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; -export const $CompositionWithAnyOf_WIP = INTERFACE as const; - export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -720,8 +603,6 @@ export const $CompositionWithAnyOf = { }, } as const; -export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -749,8 +630,6 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; -export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -790,24 +669,15 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; -export const $Enum1_WIP = { - type: 'Enum', - enum: ['Bird', 'Dog'], -} as const; - export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; -export const $ConstValue_WIP = GENERIC as const; - export const $ConstValue = { type: '"ConstValue"', } as const; -export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -836,8 +706,6 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; -export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -866,8 +734,6 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; -export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -888,8 +754,6 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -913,8 +777,6 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -946,8 +808,6 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; -export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -976,8 +836,6 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; -export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -1006,8 +864,6 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; -export const $CompositionBaseModel_WIP = INTERFACE as const; - export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -1020,8 +876,6 @@ export const $CompositionBaseModel = { }, } as const; -export const $CompositionExtendedModel_WIP = COMP as const; - export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -1048,8 +902,6 @@ export const $CompositionExtendedModel = { ], } as const; -export const $ModelWithProperties_WIP = INTERFACE as const; - export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -1099,8 +951,6 @@ export const $ModelWithProperties = { }, } as const; -export const $ModelWithNestedProperties_WIP = INTERFACE as const; - export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -1127,8 +977,6 @@ export const $ModelWithNestedProperties = { }, } as const; -export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; - export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -1138,8 +986,6 @@ export const $ModelWithDuplicateProperties = { }, } as const; -export const $ModelWithOrderedProperties_WIP = INTERFACE as const; - export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1155,8 +1001,6 @@ export const $ModelWithOrderedProperties = { }, } as const; -export const $ModelWithDuplicateImports_WIP = INTERFACE as const; - export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1172,8 +1016,6 @@ export const $ModelWithDuplicateImports = { }, } as const; -export const $ModelThatExtends_WIP = COMP as const; - export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1194,8 +1036,6 @@ export const $ModelThatExtends = { ], } as const; -export const $ModelThatExtendsExtends_WIP = COMP as const; - export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1219,8 +1059,6 @@ export const $ModelThatExtendsExtends = { ], } as const; -export const $ModelWithPattern_WIP = INTERFACE as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1267,8 +1105,6 @@ export const $ModelWithPattern = { }, } as const; -export const $File_WIP = INTERFACE as const; - export const $File = { properties: { id: { @@ -1300,8 +1136,6 @@ export const $File = { }, } as const; -export const $_default_WIP = INTERFACE as const; - export const $_default = { properties: { name: { @@ -1310,8 +1144,6 @@ export const $_default = { }, } as const; -export const $Pageable_WIP = INTERFACE as const; - export const $Pageable = { properties: { page: { @@ -1334,8 +1166,6 @@ export const $Pageable = { }, } as const; -export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; - export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1343,8 +1173,6 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1352,8 +1180,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1361,8 +1187,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; -export const $ModelWithConst_WIP = INTERFACE as const; - export const $ModelWithConst = { properties: { String: { @@ -1380,8 +1204,6 @@ export const $ModelWithConst = { }, } as const; -export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; - export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1392,8 +1214,6 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; -export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; - export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1421,8 +1241,6 @@ export const $NestedAnyOfArraysNullable = { }, } as const; -export const $CompositionWithOneOfAndProperties_WIP = COMP as const; - export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1471,8 +1289,6 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; -export const $NullableObject_WIP = INTERFACE as const; - export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1484,8 +1300,6 @@ export const $NullableObject = { isNullable: true, } as const; -export const $ModelWithNullableObject_WIP = INTERFACE as const; - export const $ModelWithNullableObject = { properties: { data: { @@ -1494,8 +1308,6 @@ export const $ModelWithNullableObject = { }, } as const; -export const $ModelWithOneOfEnum_WIP = COMP as const; - export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1568,28 +1380,16 @@ export const $ModelWithOneOfEnum = { ], } as const; -export const $ModelWithNestedArrayEnumsDataFoo_WIP = { - type: 'Enum', - enum: ['foo', 'bar'], -} as const; - export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; -export const $ModelWithNestedArrayEnumsDataBar_WIP = { - type: 'Enum', - enum: ['baz', 'qux'], -} as const; - export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; -export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1607,8 +1407,6 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; -export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1628,8 +1426,6 @@ export const $ModelWithNestedArrayEnums = { }, } as const; -export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; - export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1643,8 +1439,6 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; -export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1663,8 +1457,6 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; -export const $SimpleParameter_WIP = GENERIC as const; - export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap index 0fea2e0b6..e402b1ef7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_angular/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $CommentWithBreaks_WIP = GENERIC as const; - export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -8,85 +6,61 @@ Second line Fourth line`, } as const; -export const $CommentWithBackticks_WIP = GENERIC as const; - export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; -export const $CommentWithSlashes_WIP = GENERIC as const; - export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; -export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; - export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; -export const $CommentWithQuotes_WIP = GENERIC as const; - export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; -export const $CommentWithReservedCharacters_WIP = GENERIC as const; - export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; -export const $SimpleInteger_WIP = GENERIC as const; - export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; -export const $SimpleBoolean_WIP = GENERIC as const; - export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; -export const $SimpleString_WIP = GENERIC as const; - export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; - export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; -export const $SimpleFile_WIP = GENERIC as const; - export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; -export const $SimpleReference_WIP = GENERIC as const; - export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; -export const $SimpleStringWithPattern_WIP = GENERIC as const; - export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -95,57 +69,32 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; -export const $EnumWithStrings_WIP = { - type: 'Enum', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], -} as const; - export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; -export const $EnumWithReplacedCharacters_WIP = { - type: 'Enum', - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], -} as const; - export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; -export const $EnumWithNumbers_WIP = { - type: 'Enum', - 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; - export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; -export const $EnumWithExtensions_WIP = { - type: 'Enum', - enum: [200, 400, 500], -} as const; - export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; -export const $ArrayWithNumbers_WIP = ARR as const; - export const $ArrayWithNumbers = { type: 'array', contains: { @@ -153,8 +102,6 @@ export const $ArrayWithNumbers = { }, } as const; -export const $ArrayWithBooleans_WIP = ARR as const; - export const $ArrayWithBooleans = { type: 'array', contains: { @@ -162,8 +109,6 @@ export const $ArrayWithBooleans = { }, } as const; -export const $ArrayWithStrings_WIP = ARR as const; - export const $ArrayWithStrings = { type: 'array', contains: { @@ -172,8 +117,6 @@ export const $ArrayWithStrings = { default: ['test'], } as const; -export const $ArrayWithReferences_WIP = ARR as const; - export const $ArrayWithReferences = { type: 'array', contains: { @@ -181,8 +124,6 @@ export const $ArrayWithReferences = { }, } as const; -export const $ArrayWithArray_WIP = ARR as const; - export const $ArrayWithArray = { type: 'array', contains: { @@ -193,8 +134,6 @@ export const $ArrayWithArray = { }, } as const; -export const $ArrayWithProperties_WIP = ARR as const; - export const $ArrayWithProperties = { type: 'array', contains: { @@ -209,8 +148,6 @@ export const $ArrayWithProperties = { }, } as const; -export const $ArrayWithAnyOfProperties_WIP = ARR as const; - export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -235,8 +172,6 @@ export const $ArrayWithAnyOfProperties = { }, } as const; -export const $AnyOfAnyAndNull_WIP = INTERFACE as const; - export const $AnyOfAnyAndNull = { properties: { data: { @@ -253,8 +188,6 @@ export const $AnyOfAnyAndNull = { }, } as const; -export const $AnyOfArrays_WIP = INTERFACE as const; - export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -283,8 +216,6 @@ export const $AnyOfArrays = { }, } as const; -export const $DictionaryWithString_WIP = DICT as const; - export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -292,8 +223,6 @@ export const $DictionaryWithString = { }, } as const; -export const $DictionaryWithReference_WIP = DICT as const; - export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -301,8 +230,6 @@ export const $DictionaryWithReference = { }, } as const; -export const $DictionaryWithArray_WIP = DICT as const; - export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -313,8 +240,6 @@ export const $DictionaryWithArray = { }, } as const; -export const $DictionaryWithDictionary_WIP = DICT as const; - export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -325,8 +250,6 @@ export const $DictionaryWithDictionary = { }, } as const; -export const $DictionaryWithProperties_WIP = DICT as const; - export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -341,8 +264,6 @@ export const $DictionaryWithProperties = { }, } as const; -export const $ModelWithInteger_WIP = INTERFACE as const; - export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -353,8 +274,6 @@ export const $ModelWithInteger = { }, } as const; -export const $ModelWithBoolean_WIP = INTERFACE as const; - export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -365,8 +284,6 @@ export const $ModelWithBoolean = { }, } as const; -export const $ModelWithString_WIP = INTERFACE as const; - export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -377,8 +294,6 @@ export const $ModelWithString = { }, } as const; -export const $ModelWithNullableString_WIP = INTERFACE as const; - export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -411,8 +326,6 @@ export const $ModelWithNullableString = { }, } as const; -export const $ModelWithEnum_WIP = INTERFACE as const; - export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -431,8 +344,6 @@ export const $ModelWithEnum = { }, } as const; -export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; - export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -444,8 +355,6 @@ export const $ModelWithEnumWithHyphen = { }, } as const; -export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; - export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -456,8 +365,6 @@ export const $ModelWithEnumFromDescription = { }, } as const; -export const $ModelWithNestedEnums_WIP = INTERFACE as const; - export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -496,8 +403,6 @@ export const $ModelWithNestedEnums = { }, } as const; -export const $ModelWithReference_WIP = INTERFACE as const; - export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -507,8 +412,6 @@ export const $ModelWithReference = { }, } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -533,8 +436,6 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; -export const $ModelWithArray_WIP = INTERFACE as const; - export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -559,8 +460,6 @@ export const $ModelWithArray = { }, } as const; -export const $ModelWithDictionary_WIP = INTERFACE as const; - export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -573,8 +472,6 @@ export const $ModelWithDictionary = { }, } as const; -export const $DeprecatedModel_WIP = INTERFACE as const; - export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -585,8 +482,6 @@ export const $DeprecatedModel = { }, } as const; -export const $ModelWithCircularReference_WIP = INTERFACE as const; - export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -596,8 +491,6 @@ export const $ModelWithCircularReference = { }, } as const; -export const $CompositionWithOneOf_WIP = INTERFACE as const; - export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -621,8 +514,6 @@ export const $CompositionWithOneOf = { }, } as const; -export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -650,8 +541,6 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; -export const $ModelCircle_WIP = INTERFACE as const; - export const $ModelCircle = { description: `Circle`, properties: { @@ -665,8 +554,6 @@ export const $ModelCircle = { }, } as const; -export const $ModelSquare_WIP = INTERFACE as const; - export const $ModelSquare = { description: `Square`, properties: { @@ -680,8 +567,6 @@ export const $ModelSquare = { }, } as const; -export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; - export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -695,8 +580,6 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; -export const $CompositionWithAnyOf_WIP = INTERFACE as const; - export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -720,8 +603,6 @@ export const $CompositionWithAnyOf = { }, } as const; -export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -749,8 +630,6 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; -export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -790,24 +669,15 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; -export const $Enum1_WIP = { - type: 'Enum', - enum: ['Bird', 'Dog'], -} as const; - export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; -export const $ConstValue_WIP = GENERIC as const; - export const $ConstValue = { type: '"ConstValue"', } as const; -export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -836,8 +706,6 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; -export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -866,8 +734,6 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; -export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -888,8 +754,6 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -913,8 +777,6 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -946,8 +808,6 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; -export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -976,8 +836,6 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; -export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -1006,8 +864,6 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; -export const $CompositionBaseModel_WIP = INTERFACE as const; - export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -1020,8 +876,6 @@ export const $CompositionBaseModel = { }, } as const; -export const $CompositionExtendedModel_WIP = COMP as const; - export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -1048,8 +902,6 @@ export const $CompositionExtendedModel = { ], } as const; -export const $ModelWithProperties_WIP = INTERFACE as const; - export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -1099,8 +951,6 @@ export const $ModelWithProperties = { }, } as const; -export const $ModelWithNestedProperties_WIP = INTERFACE as const; - export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -1127,8 +977,6 @@ export const $ModelWithNestedProperties = { }, } as const; -export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; - export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -1138,8 +986,6 @@ export const $ModelWithDuplicateProperties = { }, } as const; -export const $ModelWithOrderedProperties_WIP = INTERFACE as const; - export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1155,8 +1001,6 @@ export const $ModelWithOrderedProperties = { }, } as const; -export const $ModelWithDuplicateImports_WIP = INTERFACE as const; - export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1172,8 +1016,6 @@ export const $ModelWithDuplicateImports = { }, } as const; -export const $ModelThatExtends_WIP = COMP as const; - export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1194,8 +1036,6 @@ export const $ModelThatExtends = { ], } as const; -export const $ModelThatExtendsExtends_WIP = COMP as const; - export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1219,8 +1059,6 @@ export const $ModelThatExtendsExtends = { ], } as const; -export const $ModelWithPattern_WIP = INTERFACE as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1267,8 +1105,6 @@ export const $ModelWithPattern = { }, } as const; -export const $File_WIP = INTERFACE as const; - export const $File = { properties: { id: { @@ -1300,8 +1136,6 @@ export const $File = { }, } as const; -export const $_default_WIP = INTERFACE as const; - export const $_default = { properties: { name: { @@ -1310,8 +1144,6 @@ export const $_default = { }, } as const; -export const $Pageable_WIP = INTERFACE as const; - export const $Pageable = { properties: { page: { @@ -1334,8 +1166,6 @@ export const $Pageable = { }, } as const; -export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; - export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1343,8 +1173,6 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1352,8 +1180,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1361,8 +1187,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; -export const $ModelWithConst_WIP = INTERFACE as const; - export const $ModelWithConst = { properties: { String: { @@ -1380,8 +1204,6 @@ export const $ModelWithConst = { }, } as const; -export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; - export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1392,8 +1214,6 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; -export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; - export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1421,8 +1241,6 @@ export const $NestedAnyOfArraysNullable = { }, } as const; -export const $CompositionWithOneOfAndProperties_WIP = COMP as const; - export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1471,8 +1289,6 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; -export const $NullableObject_WIP = INTERFACE as const; - export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1484,8 +1300,6 @@ export const $NullableObject = { isNullable: true, } as const; -export const $ModelWithNullableObject_WIP = INTERFACE as const; - export const $ModelWithNullableObject = { properties: { data: { @@ -1494,8 +1308,6 @@ export const $ModelWithNullableObject = { }, } as const; -export const $ModelWithOneOfEnum_WIP = COMP as const; - export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1568,28 +1380,16 @@ export const $ModelWithOneOfEnum = { ], } as const; -export const $ModelWithNestedArrayEnumsDataFoo_WIP = { - type: 'Enum', - enum: ['foo', 'bar'], -} as const; - export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; -export const $ModelWithNestedArrayEnumsDataBar_WIP = { - type: 'Enum', - enum: ['baz', 'qux'], -} as const; - export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; -export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1607,8 +1407,6 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; -export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1628,8 +1426,6 @@ export const $ModelWithNestedArrayEnums = { }, } as const; -export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; - export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1643,8 +1439,6 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; -export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1663,8 +1457,6 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; -export const $SimpleParameter_WIP = GENERIC as const; - export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap index 126a1e44f..be54e210f 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_date/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $ModelWithPattern_WIP = { firstKey: 'string expression', secondKey: 0 } as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap index 0fea2e0b6..e402b1ef7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_enums_typescript/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $CommentWithBreaks_WIP = GENERIC as const; - export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -8,85 +6,61 @@ Second line Fourth line`, } as const; -export const $CommentWithBackticks_WIP = GENERIC as const; - export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; -export const $CommentWithSlashes_WIP = GENERIC as const; - export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; -export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; - export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; -export const $CommentWithQuotes_WIP = GENERIC as const; - export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; -export const $CommentWithReservedCharacters_WIP = GENERIC as const; - export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; -export const $SimpleInteger_WIP = GENERIC as const; - export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; -export const $SimpleBoolean_WIP = GENERIC as const; - export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; -export const $SimpleString_WIP = GENERIC as const; - export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; - export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; -export const $SimpleFile_WIP = GENERIC as const; - export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; -export const $SimpleReference_WIP = GENERIC as const; - export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; -export const $SimpleStringWithPattern_WIP = GENERIC as const; - export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -95,57 +69,32 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; -export const $EnumWithStrings_WIP = { - type: 'Enum', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], -} as const; - export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; -export const $EnumWithReplacedCharacters_WIP = { - type: 'Enum', - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], -} as const; - export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; -export const $EnumWithNumbers_WIP = { - type: 'Enum', - 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; - export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; -export const $EnumWithExtensions_WIP = { - type: 'Enum', - enum: [200, 400, 500], -} as const; - export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; -export const $ArrayWithNumbers_WIP = ARR as const; - export const $ArrayWithNumbers = { type: 'array', contains: { @@ -153,8 +102,6 @@ export const $ArrayWithNumbers = { }, } as const; -export const $ArrayWithBooleans_WIP = ARR as const; - export const $ArrayWithBooleans = { type: 'array', contains: { @@ -162,8 +109,6 @@ export const $ArrayWithBooleans = { }, } as const; -export const $ArrayWithStrings_WIP = ARR as const; - export const $ArrayWithStrings = { type: 'array', contains: { @@ -172,8 +117,6 @@ export const $ArrayWithStrings = { default: ['test'], } as const; -export const $ArrayWithReferences_WIP = ARR as const; - export const $ArrayWithReferences = { type: 'array', contains: { @@ -181,8 +124,6 @@ export const $ArrayWithReferences = { }, } as const; -export const $ArrayWithArray_WIP = ARR as const; - export const $ArrayWithArray = { type: 'array', contains: { @@ -193,8 +134,6 @@ export const $ArrayWithArray = { }, } as const; -export const $ArrayWithProperties_WIP = ARR as const; - export const $ArrayWithProperties = { type: 'array', contains: { @@ -209,8 +148,6 @@ export const $ArrayWithProperties = { }, } as const; -export const $ArrayWithAnyOfProperties_WIP = ARR as const; - export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -235,8 +172,6 @@ export const $ArrayWithAnyOfProperties = { }, } as const; -export const $AnyOfAnyAndNull_WIP = INTERFACE as const; - export const $AnyOfAnyAndNull = { properties: { data: { @@ -253,8 +188,6 @@ export const $AnyOfAnyAndNull = { }, } as const; -export const $AnyOfArrays_WIP = INTERFACE as const; - export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -283,8 +216,6 @@ export const $AnyOfArrays = { }, } as const; -export const $DictionaryWithString_WIP = DICT as const; - export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -292,8 +223,6 @@ export const $DictionaryWithString = { }, } as const; -export const $DictionaryWithReference_WIP = DICT as const; - export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -301,8 +230,6 @@ export const $DictionaryWithReference = { }, } as const; -export const $DictionaryWithArray_WIP = DICT as const; - export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -313,8 +240,6 @@ export const $DictionaryWithArray = { }, } as const; -export const $DictionaryWithDictionary_WIP = DICT as const; - export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -325,8 +250,6 @@ export const $DictionaryWithDictionary = { }, } as const; -export const $DictionaryWithProperties_WIP = DICT as const; - export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -341,8 +264,6 @@ export const $DictionaryWithProperties = { }, } as const; -export const $ModelWithInteger_WIP = INTERFACE as const; - export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -353,8 +274,6 @@ export const $ModelWithInteger = { }, } as const; -export const $ModelWithBoolean_WIP = INTERFACE as const; - export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -365,8 +284,6 @@ export const $ModelWithBoolean = { }, } as const; -export const $ModelWithString_WIP = INTERFACE as const; - export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -377,8 +294,6 @@ export const $ModelWithString = { }, } as const; -export const $ModelWithNullableString_WIP = INTERFACE as const; - export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -411,8 +326,6 @@ export const $ModelWithNullableString = { }, } as const; -export const $ModelWithEnum_WIP = INTERFACE as const; - export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -431,8 +344,6 @@ export const $ModelWithEnum = { }, } as const; -export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; - export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -444,8 +355,6 @@ export const $ModelWithEnumWithHyphen = { }, } as const; -export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; - export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -456,8 +365,6 @@ export const $ModelWithEnumFromDescription = { }, } as const; -export const $ModelWithNestedEnums_WIP = INTERFACE as const; - export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -496,8 +403,6 @@ export const $ModelWithNestedEnums = { }, } as const; -export const $ModelWithReference_WIP = INTERFACE as const; - export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -507,8 +412,6 @@ export const $ModelWithReference = { }, } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -533,8 +436,6 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; -export const $ModelWithArray_WIP = INTERFACE as const; - export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -559,8 +460,6 @@ export const $ModelWithArray = { }, } as const; -export const $ModelWithDictionary_WIP = INTERFACE as const; - export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -573,8 +472,6 @@ export const $ModelWithDictionary = { }, } as const; -export const $DeprecatedModel_WIP = INTERFACE as const; - export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -585,8 +482,6 @@ export const $DeprecatedModel = { }, } as const; -export const $ModelWithCircularReference_WIP = INTERFACE as const; - export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -596,8 +491,6 @@ export const $ModelWithCircularReference = { }, } as const; -export const $CompositionWithOneOf_WIP = INTERFACE as const; - export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -621,8 +514,6 @@ export const $CompositionWithOneOf = { }, } as const; -export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -650,8 +541,6 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; -export const $ModelCircle_WIP = INTERFACE as const; - export const $ModelCircle = { description: `Circle`, properties: { @@ -665,8 +554,6 @@ export const $ModelCircle = { }, } as const; -export const $ModelSquare_WIP = INTERFACE as const; - export const $ModelSquare = { description: `Square`, properties: { @@ -680,8 +567,6 @@ export const $ModelSquare = { }, } as const; -export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; - export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -695,8 +580,6 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; -export const $CompositionWithAnyOf_WIP = INTERFACE as const; - export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -720,8 +603,6 @@ export const $CompositionWithAnyOf = { }, } as const; -export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -749,8 +630,6 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; -export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -790,24 +669,15 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; -export const $Enum1_WIP = { - type: 'Enum', - enum: ['Bird', 'Dog'], -} as const; - export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; -export const $ConstValue_WIP = GENERIC as const; - export const $ConstValue = { type: '"ConstValue"', } as const; -export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -836,8 +706,6 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; -export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -866,8 +734,6 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; -export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -888,8 +754,6 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -913,8 +777,6 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -946,8 +808,6 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; -export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -976,8 +836,6 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; -export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -1006,8 +864,6 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; -export const $CompositionBaseModel_WIP = INTERFACE as const; - export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -1020,8 +876,6 @@ export const $CompositionBaseModel = { }, } as const; -export const $CompositionExtendedModel_WIP = COMP as const; - export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -1048,8 +902,6 @@ export const $CompositionExtendedModel = { ], } as const; -export const $ModelWithProperties_WIP = INTERFACE as const; - export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -1099,8 +951,6 @@ export const $ModelWithProperties = { }, } as const; -export const $ModelWithNestedProperties_WIP = INTERFACE as const; - export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -1127,8 +977,6 @@ export const $ModelWithNestedProperties = { }, } as const; -export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; - export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -1138,8 +986,6 @@ export const $ModelWithDuplicateProperties = { }, } as const; -export const $ModelWithOrderedProperties_WIP = INTERFACE as const; - export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1155,8 +1001,6 @@ export const $ModelWithOrderedProperties = { }, } as const; -export const $ModelWithDuplicateImports_WIP = INTERFACE as const; - export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1172,8 +1016,6 @@ export const $ModelWithDuplicateImports = { }, } as const; -export const $ModelThatExtends_WIP = COMP as const; - export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1194,8 +1036,6 @@ export const $ModelThatExtends = { ], } as const; -export const $ModelThatExtendsExtends_WIP = COMP as const; - export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1219,8 +1059,6 @@ export const $ModelThatExtendsExtends = { ], } as const; -export const $ModelWithPattern_WIP = INTERFACE as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1267,8 +1105,6 @@ export const $ModelWithPattern = { }, } as const; -export const $File_WIP = INTERFACE as const; - export const $File = { properties: { id: { @@ -1300,8 +1136,6 @@ export const $File = { }, } as const; -export const $_default_WIP = INTERFACE as const; - export const $_default = { properties: { name: { @@ -1310,8 +1144,6 @@ export const $_default = { }, } as const; -export const $Pageable_WIP = INTERFACE as const; - export const $Pageable = { properties: { page: { @@ -1334,8 +1166,6 @@ export const $Pageable = { }, } as const; -export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; - export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1343,8 +1173,6 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1352,8 +1180,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1361,8 +1187,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; -export const $ModelWithConst_WIP = INTERFACE as const; - export const $ModelWithConst = { properties: { String: { @@ -1380,8 +1204,6 @@ export const $ModelWithConst = { }, } as const; -export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; - export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1392,8 +1214,6 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; -export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; - export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1421,8 +1241,6 @@ export const $NestedAnyOfArraysNullable = { }, } as const; -export const $CompositionWithOneOfAndProperties_WIP = COMP as const; - export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1471,8 +1289,6 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; -export const $NullableObject_WIP = INTERFACE as const; - export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1484,8 +1300,6 @@ export const $NullableObject = { isNullable: true, } as const; -export const $ModelWithNullableObject_WIP = INTERFACE as const; - export const $ModelWithNullableObject = { properties: { data: { @@ -1494,8 +1308,6 @@ export const $ModelWithNullableObject = { }, } as const; -export const $ModelWithOneOfEnum_WIP = COMP as const; - export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1568,28 +1380,16 @@ export const $ModelWithOneOfEnum = { ], } as const; -export const $ModelWithNestedArrayEnumsDataFoo_WIP = { - type: 'Enum', - enum: ['foo', 'bar'], -} as const; - export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; -export const $ModelWithNestedArrayEnumsDataBar_WIP = { - type: 'Enum', - enum: ['baz', 'qux'], -} as const; - export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; -export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1607,8 +1407,6 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; -export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1628,8 +1426,6 @@ export const $ModelWithNestedArrayEnums = { }, } as const; -export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; - export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1643,8 +1439,6 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; -export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1663,8 +1457,6 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; -export const $SimpleParameter_WIP = GENERIC as const; - export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap index 0fea2e0b6..e402b1ef7 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_experimental/schemas.ts.snap @@ -1,5 +1,3 @@ -export const $CommentWithBreaks_WIP = GENERIC as const; - export const $CommentWithBreaks = { type: 'number', description: `Testing multiline comments in string: First line @@ -8,85 +6,61 @@ Second line Fourth line`, } as const; -export const $CommentWithBackticks_WIP = GENERIC as const; - export const $CommentWithBackticks = { type: 'number', description: `Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work`, } as const; -export const $CommentWithSlashes_WIP = GENERIC as const; - export const $CommentWithSlashes = { type: 'number', description: `Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work`, } as const; -export const $CommentWithExpressionPlaceholders_WIP = GENERIC as const; - export const $CommentWithExpressionPlaceholders = { type: 'number', description: `Testing expression placeholders in string: \${expression} should work`, } as const; -export const $CommentWithQuotes_WIP = GENERIC as const; - export const $CommentWithQuotes = { type: 'number', description: `Testing quotes in string: 'single quote''' and "double quotes""" should work`, } as const; -export const $CommentWithReservedCharacters_WIP = GENERIC as const; - export const $CommentWithReservedCharacters = { type: 'number', description: `Testing reserved characters in string: /* inline */ and /** inline **/ should work`, } as const; -export const $SimpleInteger_WIP = GENERIC as const; - export const $SimpleInteger = { type: 'number', description: `This is a simple number`, } as const; -export const $SimpleBoolean_WIP = GENERIC as const; - export const $SimpleBoolean = { type: 'boolean', description: `This is a simple boolean`, } as const; -export const $SimpleString_WIP = GENERIC as const; - export const $SimpleString = { type: 'string', description: `This is a simple string`, } as const; -export const $NonAsciiStringæøåÆØÅöôêÊ字符串_WIP = GENERIC as const; - export const $NonAsciiStringæøåÆØÅöôêÊ字符串 = { type: 'string', description: `A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)`, } as const; -export const $SimpleFile_WIP = GENERIC as const; - export const $SimpleFile = { type: 'binary', description: `This is a simple file`, } as const; -export const $SimpleReference_WIP = GENERIC as const; - export const $SimpleReference = { type: 'ModelWithString', description: `This is a simple reference`, } as const; -export const $SimpleStringWithPattern_WIP = GENERIC as const; - export const $SimpleStringWithPattern = { type: 'string', description: `This is a simple string`, @@ -95,57 +69,32 @@ export const $SimpleStringWithPattern = { pattern: '^[a-zA-Z0-9_]*$', } as const; -export const $EnumWithStrings_WIP = { - type: 'Enum', - enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], -} as const; - export const $EnumWithStrings = { type: 'Enum', enum: ['Success', 'Warning', 'Error', "'Single Quote'", '"Double Quotes"', 'Non-ascii: øæåôöØÆÅÔÖ字符串'], } as const; -export const $EnumWithReplacedCharacters_WIP = { - type: 'Enum', - enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], -} as const; - export const $EnumWithReplacedCharacters = { type: 'Enum', enum: ["'Single Quote'", '"Double Quotes"', 'øæåôöØÆÅÔÖ字符串', 3.1, ''], } as const; -export const $EnumWithNumbers_WIP = { - type: 'Enum', - 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 $EnumWithNumbers = { type: 'Enum', 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_WIP = GENERIC as const; - export const $EnumFromDescription = { type: 'number', description: `Success=1,Warning=2,Error=3`, } as const; -export const $EnumWithExtensions_WIP = { - type: 'Enum', - enum: [200, 400, 500], -} as const; - export const $EnumWithExtensions = { type: 'Enum', enum: [200, 400, 500], } as const; -export const $ArrayWithNumbers_WIP = ARR as const; - export const $ArrayWithNumbers = { type: 'array', contains: { @@ -153,8 +102,6 @@ export const $ArrayWithNumbers = { }, } as const; -export const $ArrayWithBooleans_WIP = ARR as const; - export const $ArrayWithBooleans = { type: 'array', contains: { @@ -162,8 +109,6 @@ export const $ArrayWithBooleans = { }, } as const; -export const $ArrayWithStrings_WIP = ARR as const; - export const $ArrayWithStrings = { type: 'array', contains: { @@ -172,8 +117,6 @@ export const $ArrayWithStrings = { default: ['test'], } as const; -export const $ArrayWithReferences_WIP = ARR as const; - export const $ArrayWithReferences = { type: 'array', contains: { @@ -181,8 +124,6 @@ export const $ArrayWithReferences = { }, } as const; -export const $ArrayWithArray_WIP = ARR as const; - export const $ArrayWithArray = { type: 'array', contains: { @@ -193,8 +134,6 @@ export const $ArrayWithArray = { }, } as const; -export const $ArrayWithProperties_WIP = ARR as const; - export const $ArrayWithProperties = { type: 'array', contains: { @@ -209,8 +148,6 @@ export const $ArrayWithProperties = { }, } as const; -export const $ArrayWithAnyOfProperties_WIP = ARR as const; - export const $ArrayWithAnyOfProperties = { type: 'array', contains: { @@ -235,8 +172,6 @@ export const $ArrayWithAnyOfProperties = { }, } as const; -export const $AnyOfAnyAndNull_WIP = INTERFACE as const; - export const $AnyOfAnyAndNull = { properties: { data: { @@ -253,8 +188,6 @@ export const $AnyOfAnyAndNull = { }, } as const; -export const $AnyOfArrays_WIP = INTERFACE as const; - export const $AnyOfArrays = { description: `This is a simple array with any of properties`, properties: { @@ -283,8 +216,6 @@ export const $AnyOfArrays = { }, } as const; -export const $DictionaryWithString_WIP = DICT as const; - export const $DictionaryWithString = { type: 'dictionary', contains: { @@ -292,8 +223,6 @@ export const $DictionaryWithString = { }, } as const; -export const $DictionaryWithReference_WIP = DICT as const; - export const $DictionaryWithReference = { type: 'dictionary', contains: { @@ -301,8 +230,6 @@ export const $DictionaryWithReference = { }, } as const; -export const $DictionaryWithArray_WIP = DICT as const; - export const $DictionaryWithArray = { type: 'dictionary', contains: { @@ -313,8 +240,6 @@ export const $DictionaryWithArray = { }, } as const; -export const $DictionaryWithDictionary_WIP = DICT as const; - export const $DictionaryWithDictionary = { type: 'dictionary', contains: { @@ -325,8 +250,6 @@ export const $DictionaryWithDictionary = { }, } as const; -export const $DictionaryWithProperties_WIP = DICT as const; - export const $DictionaryWithProperties = { type: 'dictionary', contains: { @@ -341,8 +264,6 @@ export const $DictionaryWithProperties = { }, } as const; -export const $ModelWithInteger_WIP = INTERFACE as const; - export const $ModelWithInteger = { description: `This is a model with one number property`, properties: { @@ -353,8 +274,6 @@ export const $ModelWithInteger = { }, } as const; -export const $ModelWithBoolean_WIP = INTERFACE as const; - export const $ModelWithBoolean = { description: `This is a model with one boolean property`, properties: { @@ -365,8 +284,6 @@ export const $ModelWithBoolean = { }, } as const; -export const $ModelWithString_WIP = INTERFACE as const; - export const $ModelWithString = { description: `This is a model with one string property`, properties: { @@ -377,8 +294,6 @@ export const $ModelWithString = { }, } as const; -export const $ModelWithNullableString_WIP = INTERFACE as const; - export const $ModelWithNullableString = { description: `This is a model with one string property`, properties: { @@ -411,8 +326,6 @@ export const $ModelWithNullableString = { }, } as const; -export const $ModelWithEnum_WIP = INTERFACE as const; - export const $ModelWithEnum = { description: `This is a model with one enum`, properties: { @@ -431,8 +344,6 @@ export const $ModelWithEnum = { }, } as const; -export const $ModelWithEnumWithHyphen_WIP = INTERFACE as const; - export const $ModelWithEnumWithHyphen = { description: `This is a model with one enum with escaped name`, properties: { @@ -444,8 +355,6 @@ export const $ModelWithEnumWithHyphen = { }, } as const; -export const $ModelWithEnumFromDescription_WIP = INTERFACE as const; - export const $ModelWithEnumFromDescription = { description: `This is a model with one enum`, properties: { @@ -456,8 +365,6 @@ export const $ModelWithEnumFromDescription = { }, } as const; -export const $ModelWithNestedEnums_WIP = INTERFACE as const; - export const $ModelWithNestedEnums = { description: `This is a model with nested enums`, properties: { @@ -496,8 +403,6 @@ export const $ModelWithNestedEnums = { }, } as const; -export const $ModelWithReference_WIP = INTERFACE as const; - export const $ModelWithReference = { description: `This is a model with one property containing a reference`, properties: { @@ -507,8 +412,6 @@ export const $ModelWithReference = { }, } as const; -export const $ModelWithArrayReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithArrayReadOnlyAndWriteOnly = { description: `This is a model with one property containing an array`, properties: { @@ -533,8 +436,6 @@ export const $ModelWithArrayReadOnlyAndWriteOnly = { }, } as const; -export const $ModelWithArray_WIP = INTERFACE as const; - export const $ModelWithArray = { description: `This is a model with one property containing an array`, properties: { @@ -559,8 +460,6 @@ export const $ModelWithArray = { }, } as const; -export const $ModelWithDictionary_WIP = INTERFACE as const; - export const $ModelWithDictionary = { description: `This is a model with one property containing a dictionary`, properties: { @@ -573,8 +472,6 @@ export const $ModelWithDictionary = { }, } as const; -export const $DeprecatedModel_WIP = INTERFACE as const; - export const $DeprecatedModel = { description: `This is a deprecated model with a deprecated property`, properties: { @@ -585,8 +482,6 @@ export const $DeprecatedModel = { }, } as const; -export const $ModelWithCircularReference_WIP = INTERFACE as const; - export const $ModelWithCircularReference = { description: `This is a model with one property containing a circular reference`, properties: { @@ -596,8 +491,6 @@ export const $ModelWithCircularReference = { }, } as const; -export const $CompositionWithOneOf_WIP = INTERFACE as const; - export const $CompositionWithOneOf = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -621,8 +514,6 @@ export const $CompositionWithOneOf = { }, } as const; -export const $CompositionWithOneOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithOneOfAnonymous = { description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, properties: { @@ -650,8 +541,6 @@ export const $CompositionWithOneOfAnonymous = { }, } as const; -export const $ModelCircle_WIP = INTERFACE as const; - export const $ModelCircle = { description: `Circle`, properties: { @@ -665,8 +554,6 @@ export const $ModelCircle = { }, } as const; -export const $ModelSquare_WIP = INTERFACE as const; - export const $ModelSquare = { description: `Square`, properties: { @@ -680,8 +567,6 @@ export const $ModelSquare = { }, } as const; -export const $CompositionWithOneOfDiscriminator_WIP = COMP as const; - export const $CompositionWithOneOfDiscriminator = { type: 'one-of', description: `This is a model with one property with a 'one of' relationship where the options are not $ref`, @@ -695,8 +580,6 @@ export const $CompositionWithOneOfDiscriminator = { ], } as const; -export const $CompositionWithAnyOf_WIP = INTERFACE as const; - export const $CompositionWithAnyOf = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -720,8 +603,6 @@ export const $CompositionWithAnyOf = { }, } as const; -export const $CompositionWithAnyOfAnonymous_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAnonymous = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -749,8 +630,6 @@ export const $CompositionWithAnyOfAnonymous = { }, } as const; -export const $CompositionWithNestedAnyAndTypeNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyAndTypeNull = { description: `This is a model with nested 'any of' property with a type null`, properties: { @@ -790,24 +669,15 @@ export const $CompositionWithNestedAnyAndTypeNull = { }, } as const; -export const $Enum1_WIP = { - type: 'Enum', - enum: ['Bird', 'Dog'], -} as const; - export const $Enum1 = { type: 'Enum', enum: ['Bird', 'Dog'], } as const; -export const $ConstValue_WIP = GENERIC as const; - export const $ConstValue = { type: '"ConstValue"', } as const; -export const $CompositionWithNestedAnyOfAndNull_WIP = INTERFACE as const; - export const $CompositionWithNestedAnyOfAndNull = { description: `This is a model with one property with a 'any of' relationship where the options are not $ref`, properties: { @@ -836,8 +706,6 @@ export const $CompositionWithNestedAnyOfAndNull = { }, } as const; -export const $CompositionWithOneOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndNullable = { description: `This is a model with one property with a 'one of' relationship`, properties: { @@ -866,8 +734,6 @@ export const $CompositionWithOneOfAndNullable = { }, } as const; -export const $CompositionWithOneOfAndSimpleDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleDictionary = { description: `This is a model that contains a simple dictionary within composition`, properties: { @@ -888,8 +754,6 @@ export const $CompositionWithOneOfAndSimpleDictionary = { }, } as const; -export const $CompositionWithOneOfAndSimpleArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndSimpleArrayDictionary = { description: `This is a model that contains a dictionary of simple arrays within composition`, properties: { @@ -913,8 +777,6 @@ export const $CompositionWithOneOfAndSimpleArrayDictionary = { }, } as const; -export const $CompositionWithOneOfAndComplexArrayDictionary_WIP = INTERFACE as const; - export const $CompositionWithOneOfAndComplexArrayDictionary = { description: `This is a model that contains a dictionary of complex arrays (composited) within composition`, properties: { @@ -946,8 +808,6 @@ export const $CompositionWithOneOfAndComplexArrayDictionary = { }, } as const; -export const $CompositionWithAllOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAllOfAndNullable = { description: `This is a model with one property with a 'all of' relationship`, properties: { @@ -976,8 +836,6 @@ export const $CompositionWithAllOfAndNullable = { }, } as const; -export const $CompositionWithAnyOfAndNullable_WIP = INTERFACE as const; - export const $CompositionWithAnyOfAndNullable = { description: `This is a model with one property with a 'any of' relationship`, properties: { @@ -1006,8 +864,6 @@ export const $CompositionWithAnyOfAndNullable = { }, } as const; -export const $CompositionBaseModel_WIP = INTERFACE as const; - export const $CompositionBaseModel = { description: `This is a base model with two simple optional properties`, properties: { @@ -1020,8 +876,6 @@ export const $CompositionBaseModel = { }, } as const; -export const $CompositionExtendedModel_WIP = COMP as const; - export const $CompositionExtendedModel = { type: 'all-of', description: `This is a model that extends the base model`, @@ -1048,8 +902,6 @@ export const $CompositionExtendedModel = { ], } as const; -export const $ModelWithProperties_WIP = INTERFACE as const; - export const $ModelWithProperties = { description: `This is a model with one nested property`, properties: { @@ -1099,8 +951,6 @@ export const $ModelWithProperties = { }, } as const; -export const $ModelWithNestedProperties_WIP = INTERFACE as const; - export const $ModelWithNestedProperties = { description: `This is a model with one nested property`, properties: { @@ -1127,8 +977,6 @@ export const $ModelWithNestedProperties = { }, } as const; -export const $ModelWithDuplicateProperties_WIP = INTERFACE as const; - export const $ModelWithDuplicateProperties = { description: `This is a model with duplicated properties`, properties: { @@ -1138,8 +986,6 @@ export const $ModelWithDuplicateProperties = { }, } as const; -export const $ModelWithOrderedProperties_WIP = INTERFACE as const; - export const $ModelWithOrderedProperties = { description: `This is a model with ordered properties`, properties: { @@ -1155,8 +1001,6 @@ export const $ModelWithOrderedProperties = { }, } as const; -export const $ModelWithDuplicateImports_WIP = INTERFACE as const; - export const $ModelWithDuplicateImports = { description: `This is a model with duplicated imports`, properties: { @@ -1172,8 +1016,6 @@ export const $ModelWithDuplicateImports = { }, } as const; -export const $ModelThatExtends_WIP = COMP as const; - export const $ModelThatExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1194,8 +1036,6 @@ export const $ModelThatExtends = { ], } as const; -export const $ModelThatExtendsExtends_WIP = COMP as const; - export const $ModelThatExtendsExtends = { type: 'all-of', description: `This is a model that extends another model`, @@ -1219,8 +1059,6 @@ export const $ModelThatExtendsExtends = { ], } as const; -export const $ModelWithPattern_WIP = INTERFACE as const; - export const $ModelWithPattern = { description: `This is a model that contains a some patterns`, properties: { @@ -1267,8 +1105,6 @@ export const $ModelWithPattern = { }, } as const; -export const $File_WIP = INTERFACE as const; - export const $File = { properties: { id: { @@ -1300,8 +1136,6 @@ export const $File = { }, } as const; -export const $_default_WIP = INTERFACE as const; - export const $_default = { properties: { name: { @@ -1310,8 +1144,6 @@ export const $_default = { }, } as const; -export const $Pageable_WIP = INTERFACE as const; - export const $Pageable = { properties: { page: { @@ -1334,8 +1166,6 @@ export const $Pageable = { }, } as const; -export const $FreeFormObjectWithoutAdditionalProperties_WIP = DICT as const; - export const $FreeFormObjectWithoutAdditionalProperties = { type: 'dictionary', contains: { @@ -1343,8 +1173,6 @@ export const $FreeFormObjectWithoutAdditionalProperties = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqTrue_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { type: 'dictionary', contains: { @@ -1352,8 +1180,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqTrue = { }, } as const; -export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject_WIP = DICT as const; - export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { type: 'dictionary', contains: { @@ -1361,8 +1187,6 @@ export const $FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { }, } as const; -export const $ModelWithConst_WIP = INTERFACE as const; - export const $ModelWithConst = { properties: { String: { @@ -1380,8 +1204,6 @@ export const $ModelWithConst = { }, } as const; -export const $ModelWithAdditionalPropertiesEqTrue_WIP = INTERFACE as const; - export const $ModelWithAdditionalPropertiesEqTrue = { description: `This is a model with one property and additionalProperties: true`, properties: { @@ -1392,8 +1214,6 @@ export const $ModelWithAdditionalPropertiesEqTrue = { }, } as const; -export const $NestedAnyOfArraysNullable_WIP = INTERFACE as const; - export const $NestedAnyOfArraysNullable = { properties: { nullableArray: { @@ -1421,8 +1241,6 @@ export const $NestedAnyOfArraysNullable = { }, } as const; -export const $CompositionWithOneOfAndProperties_WIP = COMP as const; - export const $CompositionWithOneOfAndProperties = { type: 'one-of', contains: [ @@ -1471,8 +1289,6 @@ export const $CompositionWithOneOfAndProperties = { ], } as const; -export const $NullableObject_WIP = INTERFACE as const; - export const $NullableObject = { description: `An object that can be null`, properties: { @@ -1484,8 +1300,6 @@ export const $NullableObject = { isNullable: true, } as const; -export const $ModelWithNullableObject_WIP = INTERFACE as const; - export const $ModelWithNullableObject = { properties: { data: { @@ -1494,8 +1308,6 @@ export const $ModelWithNullableObject = { }, } as const; -export const $ModelWithOneOfEnum_WIP = COMP as const; - export const $ModelWithOneOfEnum = { type: 'one-of', contains: [ @@ -1568,28 +1380,16 @@ export const $ModelWithOneOfEnum = { ], } as const; -export const $ModelWithNestedArrayEnumsDataFoo_WIP = { - type: 'Enum', - enum: ['foo', 'bar'], -} as const; - export const $ModelWithNestedArrayEnumsDataFoo = { type: 'Enum', enum: ['foo', 'bar'], } as const; -export const $ModelWithNestedArrayEnumsDataBar_WIP = { - type: 'Enum', - enum: ['baz', 'qux'], -} as const; - export const $ModelWithNestedArrayEnumsDataBar = { type: 'Enum', enum: ['baz', 'qux'], } as const; -export const $ModelWithNestedArrayEnumsData_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnumsData = { properties: { foo: { @@ -1607,8 +1407,6 @@ export const $ModelWithNestedArrayEnumsData = { }, } as const; -export const $ModelWithNestedArrayEnums_WIP = INTERFACE as const; - export const $ModelWithNestedArrayEnums = { properties: { array_strings: { @@ -1628,8 +1426,6 @@ export const $ModelWithNestedArrayEnums = { }, } as const; -export const $ModelWithNestedCompositionEnums_WIP = INTERFACE as const; - export const $ModelWithNestedCompositionEnums = { properties: { foo: { @@ -1643,8 +1439,6 @@ export const $ModelWithNestedCompositionEnums = { }, } as const; -export const $ModelWithReadOnlyAndWriteOnly_WIP = INTERFACE as const; - export const $ModelWithReadOnlyAndWriteOnly = { properties: { foo: { @@ -1663,8 +1457,6 @@ export const $ModelWithReadOnlyAndWriteOnly = { }, } as const; -export const $SimpleParameter_WIP = GENERIC as const; - export const $SimpleParameter = { type: 'string', description: `This is a reusable parameter`, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/index.ts.snap index aed9e1736..e9644dae4 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_models/index.ts.snap @@ -1 +1 @@ -export const $CompositionWithOneOfDiscriminator_WIP = { type: "one-of", description: This is a model with one property with a 'one of' relationship where the options are not $ref, contains: (export * from './models'; \ No newline at end of file +export * from './models'; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/index.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/index.ts.snap index 8a48353ae..01c3fb836 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/index.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3_node/index.ts.snap @@ -1,3 +1,3 @@ -export const $CompositionWithOneOfDiscriminator_WIP = { type: "one-of", description: This is a model with one property with a 'one of' relationship where the options are not $ref, contains: (export { ApiError } from './core/ApiError'; +export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; \ No newline at end of file +export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';