diff --git a/.changeset/shiny-bears-double.md b/.changeset/shiny-bears-double.md new file mode 100644 index 000000000..9465c3b19 --- /dev/null +++ b/.changeset/shiny-bears-double.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix: handle discriminators in experimental parser diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index efc73f7b6..04a9a1dba 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -283,7 +283,7 @@ const getSpec = async ({ config }: { config: Config }) => { const absolutePathOrUrl = existsSync(config.input.path) ? path.resolve(config.input.path) : config.input.path; - spec = await $RefParser.bundle(absolutePathOrUrl, absolutePathOrUrl, {}); + spec = await $RefParser.bundle(absolutePathOrUrl); } return spec; diff --git a/packages/openapi-ts/src/ir/context.ts b/packages/openapi-ts/src/ir/context.ts index 463efa21d..3fb2fafe3 100644 --- a/packages/openapi-ts/src/ir/context.ts +++ b/packages/openapi-ts/src/ir/context.ts @@ -21,10 +21,23 @@ interface ContextFile { } export class IRContext = any> { + /** + * Configuration for parsing and generating the output. This + * is a mix of user-provided and default values. + */ public config: Config; + /** + * A map of files that will be generated from `spec`. + */ public files: Files; + /** + * Intermediate representation model obtained from `spec`. + */ public ir: IR; public parserConfig: ParserConfig; + /** + * Resolved specification from `input`. + */ public spec: Spec; constructor({ @@ -62,6 +75,9 @@ export class IRContext = any> { return createdFile; } + /** + * Returns a specific file by ID from `files`. + */ public file({ id }: Pick): TypeScriptFile | undefined { return this.files[id]; } @@ -77,6 +93,9 @@ export class IRContext = any> { }); } + /** + * Returns a resolved reference from `spec`. + */ public resolveRef($ref: string) { return resolveRef({ $ref, diff --git a/packages/openapi-ts/src/ir/schema.ts b/packages/openapi-ts/src/ir/schema.ts index 75422a53c..045c00d21 100644 --- a/packages/openapi-ts/src/ir/schema.ts +++ b/packages/openapi-ts/src/ir/schema.ts @@ -17,7 +17,13 @@ export const deduplicateSchema = ({ for (const item of schema.items) { // skip nested schemas for now, handle if necessary + if (!item.type && item.items) { + uniqueItems.push(item); + continue; + } + if ( + // no `type` might still include `$ref` or `const` !item.type || item.type === 'boolean' || item.type === 'null' || diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/index.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/index.ts index 7c8604f9d..50fc0d95e 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/index.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/index.ts @@ -238,8 +238,8 @@ export const parseV3_0_X = (context: IRContext) => { const schema = context.spec.components.schemas[name]; parseSchema({ + $ref, context, - name, schema, }); } diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts index 0fb81cbc2..85a7764bd 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts @@ -1,8 +1,19 @@ import type { IRContext } from '../../../ir/context'; import type { IRSchemaObject } from '../../../ir/ir'; import { addItemsToSchema } from '../../../ir/utils'; +import { refToName } from '../../../utils/ref'; +import { discriminatorValue } from '../../shared/utils/discriminator'; import type { ReferenceObject, SchemaObject } from '../types/spec'; +interface SchemaContext { + /** + * Optional schema $ref. This will be only defined for reusable components + * from the OpenAPI specification. + */ + $ref?: string; + context: IRContext; +} + type SchemaWithRequired> = Omit< SchemaObject, K @@ -52,8 +63,7 @@ const parseArray = ({ context, irSchema = {}, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -106,8 +116,7 @@ const parseArray = ({ const parseBoolean = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -118,8 +127,7 @@ const parseBoolean = ({ const parseNumber = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -132,8 +140,7 @@ const parseObject = ({ context, irSchema = {}, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -186,8 +193,7 @@ const parseObject = ({ const parseString = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -224,10 +230,10 @@ const initIrSchema = ({ schema }: { schema: SchemaObject }): IRSchemaObject => { }; const parseAllOf = ({ + $ref, context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'allOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -244,6 +250,23 @@ const parseAllOf = ({ schema: compositionSchema, }), ); + + if ('$ref' in compositionSchema) { + const ref = context.resolveRef(compositionSchema.$ref); + // `$ref` should be passed from the root `parseSchema()` call + if (ref.discriminator && $ref) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [ref.discriminator.propertyName]: { + const: discriminatorValue($ref, ref.discriminator.mapping), + type: 'string', + }, + }, + type: 'object', + }; + schemaItems.push(irDiscriminatorSchema); + } + } } if (schemaType === 'object') { @@ -326,19 +349,13 @@ const parseAllOf = ({ } } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseAnyOf = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'anyOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -346,13 +363,35 @@ const parseAnyOf = ({ const schemaItems: Array = []; const schemaType = getSchemaType({ schema }); - for (const anyOf of schema.anyOf) { - schemaItems.push( - schemaToIrSchema({ - context, - schema: anyOf, - }), - ); + const compositionSchemas = schema.anyOf; + + for (const compositionSchema of compositionSchemas) { + let irCompositionSchema = schemaToIrSchema({ + context, + schema: compositionSchema, + }); + + // `$ref` should be defined with discriminators + if (schema.discriminator && '$ref' in compositionSchema) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [schema.discriminator.propertyName]: { + const: discriminatorValue( + compositionSchema.$ref, + schema.discriminator.mapping, + ), + type: 'string', + }, + }, + type: 'object', + }; + irCompositionSchema = { + items: [irDiscriminatorSchema, irCompositionSchema], + logicalOperator: 'and', + }; + } + + schemaItems.push(irCompositionSchema); } if (schema.nullable) { @@ -383,19 +422,13 @@ const parseAnyOf = ({ } } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseEnum = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'enum'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -463,8 +496,7 @@ const parseEnum = ({ const parseOneOf = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'oneOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -472,19 +504,44 @@ const parseOneOf = ({ let schemaItems: Array = []; const schemaType = getSchemaType({ schema }); - for (const oneOf of schema.oneOf) { - const irOneOfSchema = schemaToIrSchema({ + const compositionSchemas = schema.oneOf; + + for (const compositionSchema of compositionSchemas) { + let irCompositionSchema = schemaToIrSchema({ context, - schema: oneOf, + schema: compositionSchema, }); + // `$ref` should be defined with discriminators + if (schema.discriminator && '$ref' in compositionSchema) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [schema.discriminator.propertyName]: { + const: discriminatorValue( + compositionSchema.$ref, + schema.discriminator.mapping, + ), + type: 'string', + }, + }, + type: 'object', + }; + irCompositionSchema = { + items: [irDiscriminatorSchema, irCompositionSchema], + logicalOperator: 'and', + }; + } + // since we know oneOf will be using "or" logical operator, if the parsed // composition schema also has an "or" operator, we can bring it up // to avoid unnecessary brackets - if (irOneOfSchema.logicalOperator === 'or' && irOneOfSchema.items) { - schemaItems = schemaItems.concat(irOneOfSchema.items); + if ( + irCompositionSchema.logicalOperator === 'or' && + irCompositionSchema.items + ) { + schemaItems = schemaItems.concat(irCompositionSchema.items); } else { - schemaItems.push(irOneOfSchema); + schemaItems.push(irCompositionSchema); } } @@ -516,18 +573,12 @@ const parseOneOf = ({ } } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseRef = ({ schema, -}: { - context: IRContext; +}: SchemaContext & { schema: ReferenceObject; }): IRSchemaObject => { const irSchema: IRSchemaObject = {}; @@ -543,8 +594,7 @@ const parseNullableType = ({ context, irSchema, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaWithRequired<'type'>; }): IRSchemaObject => { @@ -579,8 +629,7 @@ const parseNullableType = ({ const parseType = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'type'>; }): IRSchemaObject => { const irSchema = initIrSchema({ schema }); @@ -621,8 +670,7 @@ const parseOneType = ({ context, irSchema, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaWithRequired<'type'>; }): IRSchemaObject => { @@ -672,8 +720,7 @@ const parseOneType = ({ const parseUnknown = ({ schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaObject; }): IRSchemaObject => { const irSchema = initIrSchema({ schema }); @@ -689,14 +736,15 @@ const parseUnknown = ({ }; export const schemaToIrSchema = ({ + $ref, context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaObject | ReferenceObject; }): IRSchemaObject => { if ('$ref' in schema) { return parseRef({ + $ref, context, schema, }); @@ -704,6 +752,7 @@ export const schemaToIrSchema = ({ if (schema.enum) { return parseEnum({ + $ref, context, schema: schema as SchemaWithRequired<'enum'>, }); @@ -711,6 +760,7 @@ export const schemaToIrSchema = ({ if (schema.allOf) { return parseAllOf({ + $ref, context, schema: schema as SchemaWithRequired<'allOf'>, }); @@ -718,6 +768,7 @@ export const schemaToIrSchema = ({ if (schema.anyOf) { return parseAnyOf({ + $ref, context, schema: schema as SchemaWithRequired<'anyOf'>, }); @@ -725,6 +776,7 @@ export const schemaToIrSchema = ({ if (schema.oneOf) { return parseOneOf({ + $ref, context, schema: schema as SchemaWithRequired<'oneOf'>, }); @@ -733,24 +785,24 @@ export const schemaToIrSchema = ({ // infer object based on the presence of properties if (schema.type || schema.properties) { return parseType({ + $ref, context, schema: schema as SchemaWithRequired<'type'>, }); } return parseUnknown({ + $ref, context, schema, }); }; export const parseSchema = ({ + $ref, context, - name, schema, -}: { - context: IRContext; - name: string; +}: Required & { schema: SchemaObject | ReferenceObject; }) => { if (!context.ir.components) { @@ -761,7 +813,8 @@ export const parseSchema = ({ context.ir.components.schemas = {}; } - context.ir.components.schemas[name] = schemaToIrSchema({ + context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({ + $ref, context, schema, }); diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/index.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/index.ts index d41fd38a9..9cb9afb8a 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/index.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/index.ts @@ -231,8 +231,8 @@ export const parseV3_1_X = (context: IRContext) => { const schema = context.spec.components.schemas[name]; parseSchema({ + $ref, context, - name, schema, }); } diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts index d42a2bf6c..10b409b06 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts @@ -1,8 +1,19 @@ import type { IRContext } from '../../../ir/context'; import type { IRSchemaObject } from '../../../ir/ir'; import { addItemsToSchema } from '../../../ir/utils'; +import { refToName } from '../../../utils/ref'; +import { discriminatorValue } from '../../shared/utils/discriminator'; import type { SchemaObject } from '../types/spec'; +interface SchemaContext { + /** + * Optional schema $ref. This will be only defined for reusable components + * from the OpenAPI specification. + */ + $ref?: string; + context: IRContext; +} + type SchemaWithRequired> = Omit< SchemaObject, K @@ -82,8 +93,7 @@ const parseArray = ({ context, irSchema = {}, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -148,8 +158,7 @@ const parseArray = ({ const parseBoolean = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -160,8 +169,7 @@ const parseBoolean = ({ const parseNull = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }) => { @@ -172,8 +180,7 @@ const parseNull = ({ const parseNumber = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -186,8 +193,7 @@ const parseObject = ({ context, irSchema = {}, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -240,8 +246,7 @@ const parseObject = ({ const parseString = ({ irSchema = {}, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: SchemaObject; }): IRSchemaObject => { @@ -278,10 +283,10 @@ const initIrSchema = ({ schema }: { schema: SchemaObject }): IRSchemaObject => { }; const parseAllOf = ({ + $ref, context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'allOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -298,6 +303,23 @@ const parseAllOf = ({ schema: compositionSchema, }), ); + + if (compositionSchema.$ref) { + const ref = context.resolveRef(compositionSchema.$ref); + // `$ref` should be passed from the root `parseSchema()` call + if (ref.discriminator && $ref) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [ref.discriminator.propertyName]: { + const: discriminatorValue($ref, ref.discriminator.mapping), + type: 'string', + }, + }, + type: 'object', + }; + schemaItems.push(irDiscriminatorSchema); + } + } } if (schemaTypes.includes('object')) { @@ -369,19 +391,13 @@ const parseAllOf = ({ }; } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseAnyOf = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'anyOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -389,13 +405,35 @@ const parseAnyOf = ({ const schemaItems: Array = []; const schemaTypes = getSchemaTypes({ schema }); - for (const anyOf of schema.anyOf) { - schemaItems.push( - schemaToIrSchema({ - context, - schema: anyOf, - }), - ); + const compositionSchemas = schema.anyOf; + + for (const compositionSchema of compositionSchemas) { + let irCompositionSchema = schemaToIrSchema({ + context, + schema: compositionSchema, + }); + + // `$ref` should be defined with discriminators + if (schema.discriminator && compositionSchema.$ref) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [schema.discriminator.propertyName]: { + const: discriminatorValue( + compositionSchema.$ref, + schema.discriminator.mapping, + ), + type: 'string', + }, + }, + type: 'object', + }; + irCompositionSchema = { + items: [irDiscriminatorSchema, irCompositionSchema], + logicalOperator: 'and', + }; + } + + schemaItems.push(irCompositionSchema); } if (schemaTypes.includes('null')) { @@ -426,19 +464,13 @@ const parseAnyOf = ({ } } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseEnum = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'enum'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -501,8 +533,7 @@ const parseEnum = ({ const parseOneOf = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'oneOf'>; }): IRSchemaObject => { let irSchema = initIrSchema({ schema }); @@ -510,19 +541,44 @@ const parseOneOf = ({ let schemaItems: Array = []; const schemaTypes = getSchemaTypes({ schema }); - for (const oneOf of schema.oneOf) { - const irOneOfSchema = schemaToIrSchema({ + const compositionSchemas = schema.oneOf; + + for (const compositionSchema of compositionSchemas) { + let irCompositionSchema = schemaToIrSchema({ context, - schema: oneOf, + schema: compositionSchema, }); + // `$ref` should be defined with discriminators + if (schema.discriminator && compositionSchema.$ref) { + const irDiscriminatorSchema: IRSchemaObject = { + properties: { + [schema.discriminator.propertyName]: { + const: discriminatorValue( + compositionSchema.$ref, + schema.discriminator.mapping, + ), + type: 'string', + }, + }, + type: 'object', + }; + irCompositionSchema = { + items: [irDiscriminatorSchema, irCompositionSchema], + logicalOperator: 'and', + }; + } + // since we know oneOf will be using "or" logical operator, if the parsed // composition schema also has an "or" operator, we can bring it up // to avoid unnecessary brackets - if (irOneOfSchema.logicalOperator === 'or' && irOneOfSchema.items) { - schemaItems = schemaItems.concat(irOneOfSchema.items); + if ( + irCompositionSchema.logicalOperator === 'or' && + irCompositionSchema.items + ) { + schemaItems = schemaItems.concat(irCompositionSchema.items); } else { - schemaItems.push(irOneOfSchema); + schemaItems.push(irCompositionSchema); } } @@ -554,18 +610,12 @@ const parseOneOf = ({ } } - if (schema.discriminator) { - // TODO: parser - support discriminator - // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf - } - return irSchema; }; const parseRef = ({ schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'$ref'>; }): IRSchemaObject => { const irSchema = initIrSchema({ schema }); @@ -581,8 +631,7 @@ const parseOneType = ({ context, irSchema, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: Omit & { type: SchemaType; @@ -642,8 +691,7 @@ const parseManyTypes = ({ context, irSchema, schema, -}: { - context: IRContext; +}: SchemaContext & { irSchema?: IRSchemaObject; schema: Omit & { type: ReadonlyArray; @@ -684,8 +732,7 @@ const parseManyTypes = ({ const parseType = ({ context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaWithRequired<'type'>; }): IRSchemaObject => { const irSchema = initIrSchema({ schema }); @@ -720,8 +767,7 @@ const parseType = ({ const parseUnknown = ({ schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaObject; }): IRSchemaObject => { const irSchema = initIrSchema({ schema }); @@ -737,14 +783,15 @@ const parseUnknown = ({ }; export const schemaToIrSchema = ({ + $ref, context, schema, -}: { - context: IRContext; +}: SchemaContext & { schema: SchemaObject; }): IRSchemaObject => { if (schema.$ref) { return parseRef({ + $ref, context, schema: schema as SchemaWithRequired<'$ref'>, }); @@ -752,6 +799,7 @@ export const schemaToIrSchema = ({ if (schema.enum) { return parseEnum({ + $ref, context, schema: schema as SchemaWithRequired<'enum'>, }); @@ -759,6 +807,7 @@ export const schemaToIrSchema = ({ if (schema.allOf) { return parseAllOf({ + $ref, context, schema: schema as SchemaWithRequired<'allOf'>, }); @@ -766,6 +815,7 @@ export const schemaToIrSchema = ({ if (schema.anyOf) { return parseAnyOf({ + $ref, context, schema: schema as SchemaWithRequired<'anyOf'>, }); @@ -773,6 +823,7 @@ export const schemaToIrSchema = ({ if (schema.oneOf) { return parseOneOf({ + $ref, context, schema: schema as SchemaWithRequired<'oneOf'>, }); @@ -781,24 +832,24 @@ export const schemaToIrSchema = ({ // infer object based on the presence of properties if (schema.type || schema.properties) { return parseType({ + $ref, context, schema: schema as SchemaWithRequired<'type'>, }); } return parseUnknown({ + $ref, context, schema, }); }; export const parseSchema = ({ + $ref, context, - name, schema, -}: { - context: IRContext; - name: string; +}: Required & { schema: SchemaObject; }) => { if (!context.ir.components) { @@ -809,7 +860,8 @@ export const parseSchema = ({ context.ir.components.schemas = {}; } - context.ir.components.schemas[name] = schemaToIrSchema({ + context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({ + $ref, context, schema, }); diff --git a/packages/openapi-ts/src/openApi/shared/utils/discriminator.ts b/packages/openapi-ts/src/openApi/shared/utils/discriminator.ts new file mode 100644 index 000000000..4bc2f34a6 --- /dev/null +++ b/packages/openapi-ts/src/openApi/shared/utils/discriminator.ts @@ -0,0 +1,14 @@ +import { refToName } from '../../../utils/ref'; + +export const discriminatorValue = ( + $ref: string, + mapping?: Record, +) => { + for (const name in mapping) { + const refMapped = mapping[name]; + if (refMapped === $ref) { + return name; + } + } + return refToName($ref); +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts index 96e0ab3ff..5ae2c8c8a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts @@ -62,9 +62,9 @@ const schemaToJsonSchemaDraft_05 = ({ const schema = structuredClone(_schema); if ('$ref' in schema) { - // refs are encoded probably by json-schema-ref-parser, didn't investigate - // further - schema.$ref = decodeURIComponent(schema.$ref); + // refs using unicode characters become encoded, didn't investigate why + // but the suspicion is this comes from `@apidevtools/json-schema-ref-parser` + schema.$ref = decodeURI(schema.$ref); return schema; } @@ -151,9 +151,9 @@ const schemaToJsonSchema2020_12 = ({ stripSchema({ context, schema }); if (schema.$ref) { - // refs are encoded probably by json-schema-ref-parser, didn't investigate - // further - schema.$ref = decodeURIComponent(schema.$ref); + // refs using unicode characters become encoded, didn't investigate why + // but the suspicion is this comes from `@apidevtools/json-schema-ref-parser` + schema.$ref = decodeURI(schema.$ref); } if ( diff --git a/packages/openapi-ts/src/utils/ref.ts b/packages/openapi-ts/src/utils/ref.ts index 72b714030..b48909569 100644 --- a/packages/openapi-ts/src/utils/ref.ts +++ b/packages/openapi-ts/src/utils/ref.ts @@ -6,6 +6,17 @@ export const isRefOpenApiComponent = ($ref: string): boolean => { return parts.length === 3 && parts[0] === 'components'; }; +/** + * Returns the component name from `$ref`. + */ +export const refToName = ($ref: string): string => { + const parts = refToParts($ref); + const name = parts[parts.length - 1]; + // refs using unicode characters become encoded, didn't investigate why + // but the suspicion is this comes from `@apidevtools/json-schema-ref-parser` + return decodeURI(name); +}; + const refToParts = ($ref: string): string[] => { // Remove the leading `#` and split by `/` to traverse the object const parts = $ref.replace(/^#\//, '').split('/'); @@ -19,7 +30,9 @@ export const resolveRef = ({ $ref: string; spec: Record; }): T => { - const parts = refToParts($ref); + // refs using unicode characters become encoded, didn't investigate why + // but the suspicion is this comes from `@apidevtools/json-schema-ref-parser` + const parts = refToParts(decodeURI($ref)); let current = spec; diff --git a/packages/openapi-ts/test/3.0.x.spec.ts b/packages/openapi-ts/test/3.0.x.spec.ts index 6d7583786..76ba59d59 100644 --- a/packages/openapi-ts/test/3.0.x.spec.ts +++ b/packages/openapi-ts/test/3.0.x.spec.ts @@ -56,6 +56,27 @@ describe(`OpenAPI ${VERSION}`, () => { description: 'generates correct array when items are oneOf array with single item', }, + { + config: createConfig({ + input: 'discriminator-all-of.yaml', + output: 'discriminator-all-of', + }), + description: 'handles discriminator with and without mapping', + }, + { + config: createConfig({ + input: 'discriminator-any-of.yaml', + output: 'discriminator-any-of', + }), + description: 'handles discriminator with and without mapping', + }, + { + config: createConfig({ + input: 'discriminator-one-of.yaml', + output: 'discriminator-one-of', + }), + description: 'handles discriminator with and without mapping', + }, { config: createConfig({ input: 'enum-escape.json', diff --git a/packages/openapi-ts/test/3.1.x.spec.ts b/packages/openapi-ts/test/3.1.x.spec.ts index ab11ad5f8..1a0133379 100644 --- a/packages/openapi-ts/test/3.1.x.spec.ts +++ b/packages/openapi-ts/test/3.1.x.spec.ts @@ -56,6 +56,27 @@ describe(`OpenAPI ${VERSION}`, () => { description: 'generates correct array when items are oneOf array with single item', }, + { + config: createConfig({ + input: 'discriminator-all-of.yaml', + output: 'discriminator-all-of', + }), + description: 'handles discriminator with and without mapping', + }, + { + config: createConfig({ + input: 'discriminator-any-of.yaml', + output: 'discriminator-any-of', + }), + description: 'handles discriminator with and without mapping', + }, + { + config: createConfig({ + input: 'discriminator-one-of.yaml', + output: 'discriminator-one-of', + }), + description: 'handles discriminator with and without mapping', + }, { config: createConfig({ input: 'duplicate-null.json', diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts new file mode 100644 index 000000000..7d0377879 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts @@ -0,0 +1,45 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + id: string; +}; + +export type Bar = Foo & { + id?: 'Bar'; +} & { + bar?: string; +}; + +export type Baz = Foo & { + id?: 'Baz'; +} & { + baz?: string; +}; + +export type Qux = Foo & { + id?: 'Qux'; +} & { + qux?: boolean; +}; + +export type FooMapped = { + id: string; +}; + +export type BarMapped = FooMapped & { + id?: 'bar'; +} & { + bar?: string; +}; + +export type BazMapped = FooMapped & { + id?: 'baz'; +} & { + baz?: string; +}; + +export type QuxMapped = FooMapped & { + id?: 'QuxMapped'; +} & { + qux?: boolean; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts new file mode 100644 index 000000000..f922d6763 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = ({ + type?: 'Bar'; +} & Bar) | ({ + type?: 'Baz'; +} & Baz); + +export type Baz = Qux; + +export type Bar = Qux; + +export type Qux = { + id: string; + type: Quux; +}; + +export type Quux = 'Bar' | 'Baz'; + +export type Quuz = ({ + type?: 'bar'; +} & Bar) | ({ + type?: 'baz'; +} & Baz); \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts new file mode 100644 index 000000000..f922d6763 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = ({ + type?: 'Bar'; +} & Bar) | ({ + type?: 'Baz'; +} & Baz); + +export type Baz = Qux; + +export type Bar = Qux; + +export type Qux = { + id: string; + type: Quux; +}; + +export type Quux = 'Bar' | 'Baz'; + +export type Quuz = ({ + type?: 'bar'; +} & Bar) | ({ + type?: 'baz'; +} & Baz); \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@hey-api/services/default/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index 19d84c4f2..b914fd963 100644 --- a/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts new file mode 100644 index 000000000..7d0377879 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts @@ -0,0 +1,45 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + id: string; +}; + +export type Bar = Foo & { + id?: 'Bar'; +} & { + bar?: string; +}; + +export type Baz = Foo & { + id?: 'Baz'; +} & { + baz?: string; +}; + +export type Qux = Foo & { + id?: 'Qux'; +} & { + qux?: boolean; +}; + +export type FooMapped = { + id: string; +}; + +export type BarMapped = FooMapped & { + id?: 'bar'; +} & { + bar?: string; +}; + +export type BazMapped = FooMapped & { + id?: 'baz'; +} & { + baz?: string; +}; + +export type QuxMapped = FooMapped & { + id?: 'QuxMapped'; +} & { + qux?: boolean; +}; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts new file mode 100644 index 000000000..f922d6763 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = ({ + type?: 'Bar'; +} & Bar) | ({ + type?: 'Baz'; +} & Baz); + +export type Baz = Qux; + +export type Bar = Qux; + +export type Qux = { + id: string; + type: Quux; +}; + +export type Quux = 'Bar' | 'Baz'; + +export type Quuz = ({ + type?: 'bar'; +} & Bar) | ({ + type?: 'baz'; +} & Baz); \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/index.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/index.ts new file mode 100644 index 000000000..56bade120 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/index.ts @@ -0,0 +1,2 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './types.gen'; \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts new file mode 100644 index 000000000..f922d6763 --- /dev/null +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = ({ + type?: 'Bar'; +} & Bar) | ({ + type?: 'Baz'; +} & Baz); + +export type Baz = Qux; + +export type Bar = Qux; + +export type Qux = { + id: string; + type: Quux; +}; + +export type Quux = 'Bar' | 'Baz'; + +export type Quuz = ({ + type?: 'bar'; +} & Bar) | ({ + type?: 'baz'; +} & Baz); \ No newline at end of file diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/services/default/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/services/default/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/services/default/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@hey-api/services/default/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index c38cc6074..2f6b56c07 100644 --- a/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -425,7 +425,11 @@ export type ModelSquare = { /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export type CompositionWithOneOfDiscriminator = ModelCircle | ModelSquare; +export type CompositionWithOneOfDiscriminator = ({ + kind?: 'circle'; +} & ModelCircle) | ({ + kind?: 'square'; +} & ModelSquare); /** * This is a model with one property with a 'any of' relationship diff --git a/packages/openapi-ts/test/sample.cjs b/packages/openapi-ts/test/sample.cjs index 2b69ea7ea..4b0f5d5e0 100644 --- a/packages/openapi-ts/test/sample.cjs +++ b/packages/openapi-ts/test/sample.cjs @@ -13,7 +13,8 @@ const main = async () => { input: { // include: // '^(#/components/schemas/import|#/paths/api/v{api-version}/simple/options)$', - path: './test/spec/3.1.x/array-items-one-of-length-1.json', + path: './test/spec/3.1.x/discriminator-one-of.yaml', + // path: './test/spec/3.0.x/full.json', // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', }, // name: 'foo', diff --git a/packages/openapi-ts/test/spec/3.0.x/discriminator-all-of.yaml b/packages/openapi-ts/test/spec/3.0.x/discriminator-all-of.yaml new file mode 100644 index 000000000..f69cca684 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/discriminator-all-of.yaml @@ -0,0 +1,69 @@ +openapi: 3.0.3 +info: + title: OpenAPI 3.0.3 discriminator all of example + version: 1 +components: + schemas: + Foo: + type: object + required: + - id + properties: + id: + type: string + discriminator: + propertyName: id + Bar: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + bar: + type: string + Baz: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + baz: + type: string + Qux: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + qux: + type: boolean + FooMapped: + type: object + required: + - id + properties: + id: + type: string + discriminator: + propertyName: id + mapping: + bar: '#/components/schemas/BarMapped' + baz: '#/components/schemas/BazMapped' + BarMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + bar: + type: string + BazMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + baz: + type: string + QuxMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + qux: + type: boolean diff --git a/packages/openapi-ts/test/spec/3.0.x/discriminator-any-of.yaml b/packages/openapi-ts/test/spec/3.0.x/discriminator-any-of.yaml new file mode 100644 index 000000000..c852f9504 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/discriminator-any-of.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.3 +info: + title: OpenAPI 3.0.3 discriminator any of example + version: 1 +components: + schemas: + Foo: + anyOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + Baz: + allOf: + - $ref: '#/components/schemas/Qux' + Bar: + allOf: + - $ref: '#/components/schemas/Qux' + Qux: + type: object + properties: + id: + type: string + type: + $ref: '#/components/schemas/Quux' + required: + - id + - type + Quux: + enum: + - Bar + - Baz + type: string + Quuz: + anyOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + mapping: + bar: '#/components/schemas/Bar' + baz: '#/components/schemas/Baz' diff --git a/packages/openapi-ts/test/spec/3.0.x/discriminator-one-of.yaml b/packages/openapi-ts/test/spec/3.0.x/discriminator-one-of.yaml new file mode 100644 index 000000000..30732a2ea --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/discriminator-one-of.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.3 +info: + title: OpenAPI 3.0.3 discriminator one of example + version: 1 +components: + schemas: + Foo: + oneOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + Baz: + allOf: + - $ref: '#/components/schemas/Qux' + Bar: + allOf: + - $ref: '#/components/schemas/Qux' + Qux: + type: object + properties: + id: + type: string + type: + $ref: '#/components/schemas/Quux' + required: + - id + - type + Quux: + enum: + - Bar + - Baz + type: string + Quuz: + oneOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + mapping: + bar: '#/components/schemas/Bar' + baz: '#/components/schemas/Baz' diff --git a/packages/openapi-ts/test/spec/3.0.x/ref-duplicate-url.yaml b/packages/openapi-ts/test/spec/3.0.x/ref-duplicate-url.yaml new file mode 100644 index 000000000..50684876c --- /dev/null +++ b/packages/openapi-ts/test/spec/3.0.x/ref-duplicate-url.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.3 +info: + title: OpenAPI 3.0.3 $ref duplicate URL example + version: 1 +paths: + /a: + get: + responses: + default: + description: OK + content: + application/json: + schema: + $ref: './enum-escape.json#/components/schemas/Foo' + /b: + get: + responses: + default: + description: OK + content: + application/json: + schema: + $ref: './enum-escape.json#/components/schemas/Foo' diff --git a/packages/openapi-ts/test/spec/3.1.x/discriminator-all-of.yaml b/packages/openapi-ts/test/spec/3.1.x/discriminator-all-of.yaml new file mode 100644 index 000000000..b49e72508 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/discriminator-all-of.yaml @@ -0,0 +1,69 @@ +openapi: 3.1.0 +info: + title: OpenAPI 3.1.0 discriminator all of example + version: 1 +components: + schemas: + Foo: + type: object + required: + - id + properties: + id: + type: string + discriminator: + propertyName: id + Bar: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + bar: + type: string + Baz: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + baz: + type: string + Qux: + allOf: + - $ref: '#/components/schemas/Foo' + - type: object + properties: + qux: + type: boolean + FooMapped: + type: object + required: + - id + properties: + id: + type: string + discriminator: + propertyName: id + mapping: + bar: '#/components/schemas/BarMapped' + baz: '#/components/schemas/BazMapped' + BarMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + bar: + type: string + BazMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + baz: + type: string + QuxMapped: + allOf: + - $ref: '#/components/schemas/FooMapped' + - type: object + properties: + qux: + type: boolean diff --git a/packages/openapi-ts/test/spec/3.1.x/discriminator-any-of.yaml b/packages/openapi-ts/test/spec/3.1.x/discriminator-any-of.yaml new file mode 100644 index 000000000..d5e9be83d --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/discriminator-any-of.yaml @@ -0,0 +1,42 @@ +openapi: 3.1.0 +info: + title: OpenAPI 3.1.0 discriminator any of example + version: 1 +components: + schemas: + Foo: + anyOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + Baz: + allOf: + - $ref: '#/components/schemas/Qux' + Bar: + allOf: + - $ref: '#/components/schemas/Qux' + Qux: + type: object + properties: + id: + type: string + type: + $ref: '#/components/schemas/Quux' + required: + - id + - type + Quux: + enum: + - Bar + - Baz + type: string + Quuz: + anyOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + mapping: + bar: '#/components/schemas/Bar' + baz: '#/components/schemas/Baz' diff --git a/packages/openapi-ts/test/spec/3.1.x/discriminator-one-of.yaml b/packages/openapi-ts/test/spec/3.1.x/discriminator-one-of.yaml new file mode 100644 index 000000000..a60d120c1 --- /dev/null +++ b/packages/openapi-ts/test/spec/3.1.x/discriminator-one-of.yaml @@ -0,0 +1,42 @@ +openapi: 3.1.0 +info: + title: OpenAPI 3.1.0 discriminator one of example + version: 1 +components: + schemas: + Foo: + oneOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + Baz: + allOf: + - $ref: '#/components/schemas/Qux' + Bar: + allOf: + - $ref: '#/components/schemas/Qux' + Qux: + type: object + properties: + id: + type: string + type: + $ref: '#/components/schemas/Quux' + required: + - id + - type + Quux: + enum: + - Bar + - Baz + type: string + Quuz: + oneOf: + - $ref: '#/components/schemas/Bar' + - $ref: '#/components/schemas/Baz' + discriminator: + propertyName: type + mapping: + bar: '#/components/schemas/Bar' + baz: '#/components/schemas/Baz' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4962683e9..4e33f78c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -266,7 +266,7 @@ importers: devDependencies: '@angular-devkit/build-angular': specifier: ^18.2.11 - version: 18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(karma@6.4.4)(tailwindcss@3.4.9)(typescript@5.5.3) + version: 18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(karma@6.4.4)(tailwindcss@3.4.9(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)))(typescript@5.5.3) '@angular/cli': specifier: ^18.2.11 version: 18.2.11(chokidar@3.6.0) @@ -5120,10 +5120,6 @@ packages: engines: {node: '>=18'} hasBin: true - escalade@3.1.2: - resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} - engines: {node: '>=6'} - escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -8893,7 +8889,7 @@ snapshots: dependencies: '@ampproject/remapping': 2.3.0 '@angular-devkit/architect': 0.1802.11(chokidar@3.6.0) - '@angular-devkit/build-webpack': 0.1802.11(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0(esbuild@0.23.0)))(webpack@5.94.0(esbuild@0.23.0)) + '@angular-devkit/build-webpack': 0.1802.11(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0))(webpack@5.94.0(esbuild@0.23.0)) '@angular-devkit/core': 18.2.11(chokidar@3.6.0) '@angular/build': 18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(tailwindcss@3.4.9(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)))(terser@5.31.6)(typescript@5.5.3) '@angular/compiler-cli': 18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3) @@ -8950,9 +8946,9 @@ snapshots: typescript: 5.5.3 vite: 5.4.6(@types/node@22.8.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) watchpack: 2.4.1 - webpack: 5.94.0(esbuild@0.23.1) - webpack-dev-middleware: 7.4.2(webpack@5.94.0(esbuild@0.23.0)) - webpack-dev-server: 5.0.4(webpack@5.94.0(esbuild@0.23.0)) + webpack: 5.94.0(esbuild@0.23.0) + webpack-dev-middleware: 7.4.2(webpack@5.94.0) + webpack-dev-server: 5.0.4(webpack@5.94.0) webpack-merge: 6.0.1 webpack-subresource-integrity: 5.1.0(webpack@5.94.0(esbuild@0.23.0)) optionalDependencies: @@ -8977,100 +8973,12 @@ snapshots: - utf-8-validate - webpack-cli - '@angular-devkit/build-angular@18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(karma@6.4.4)(tailwindcss@3.4.9)(typescript@5.5.3)': - dependencies: - '@ampproject/remapping': 2.3.0 - '@angular-devkit/architect': 0.1802.11(chokidar@3.6.0) - '@angular-devkit/build-webpack': 0.1802.11(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0(esbuild@0.23.0)))(webpack@5.94.0(esbuild@0.23.0)) - '@angular-devkit/core': 18.2.11(chokidar@3.6.0) - '@angular/build': 18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(tailwindcss@3.4.9)(terser@5.31.6)(typescript@5.5.3) - '@angular/compiler-cli': 18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3) - '@babel/core': 7.25.2 - '@babel/generator': 7.25.0 - '@babel/helper-annotate-as-pure': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/plugin-transform-async-generator-functions': 7.25.0(@babel/core@7.25.2) - '@babel/plugin-transform-async-to-generator': 7.24.7(@babel/core@7.25.2) - '@babel/plugin-transform-runtime': 7.24.7(@babel/core@7.25.2) - '@babel/preset-env': 7.25.3(@babel/core@7.25.2) - '@babel/runtime': 7.25.0 - '@discoveryjs/json-ext': 0.6.1 - '@ngtools/webpack': 18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(typescript@5.5.3)(webpack@5.94.0(esbuild@0.23.0)) - '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.8.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) - ansi-colors: 4.1.3 - autoprefixer: 10.4.20(postcss@8.4.41) - babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.94.0(esbuild@0.23.0)) - browserslist: 4.24.2 - copy-webpack-plugin: 12.0.2(webpack@5.94.0(esbuild@0.23.0)) - critters: 0.0.24 - css-loader: 7.1.2(webpack@5.94.0(esbuild@0.23.0)) - esbuild-wasm: 0.23.0 - fast-glob: 3.3.2 - http-proxy-middleware: 3.0.3 - https-proxy-agent: 7.0.5 - istanbul-lib-instrument: 6.0.3 - jsonc-parser: 3.3.1 - karma-source-map-support: 1.4.0 - less: 4.2.0 - less-loader: 12.2.0(less@4.2.0)(webpack@5.94.0(esbuild@0.23.0)) - license-webpack-plugin: 4.0.2(webpack@5.94.0(esbuild@0.23.0)) - loader-utils: 3.3.1 - magic-string: 0.30.11 - mini-css-extract-plugin: 2.9.0(webpack@5.94.0(esbuild@0.23.0)) - mrmime: 2.0.0 - open: 10.1.0 - ora: 5.4.1 - parse5-html-rewriting-stream: 7.0.0 - picomatch: 4.0.2 - piscina: 4.6.1 - postcss: 8.4.41 - postcss-loader: 8.1.1(postcss@8.4.41)(typescript@5.5.3)(webpack@5.94.0(esbuild@0.23.0)) - resolve-url-loader: 5.0.0 - rxjs: 7.8.1 - sass: 1.77.6 - sass-loader: 16.0.0(sass@1.77.6)(webpack@5.94.0(esbuild@0.23.0)) - semver: 7.6.3 - source-map-loader: 5.0.0(webpack@5.94.0(esbuild@0.23.0)) - source-map-support: 0.5.21 - terser: 5.31.6 - tree-kill: 1.2.2 - tslib: 2.6.3 - typescript: 5.5.3 - vite: 5.4.6(@types/node@22.8.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) - watchpack: 2.4.1 - webpack: 5.94.0(esbuild@0.23.1) - webpack-dev-middleware: 7.4.2(webpack@5.94.0(esbuild@0.23.0)) - webpack-dev-server: 5.0.4(webpack@5.94.0(esbuild@0.23.0)) - webpack-merge: 6.0.1 - webpack-subresource-integrity: 5.1.0(webpack@5.94.0(esbuild@0.23.0)) - optionalDependencies: - esbuild: 0.23.0 - karma: 6.4.4 - tailwindcss: 3.4.9(ts-node@10.9.2(@types/node@20.14.5)(typescript@5.5.3)) - transitivePeerDependencies: - - '@rspack/core' - - '@swc/core' - - '@types/node' - - bufferutil - - chokidar - - debug - - html-webpack-plugin - - lightningcss - - node-sass - - sass-embedded - - stylus - - sugarss - - supports-color - - uglify-js - - utf-8-validate - - webpack-cli - - '@angular-devkit/build-webpack@0.1802.11(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0(esbuild@0.23.0)))(webpack@5.94.0(esbuild@0.23.0))': + '@angular-devkit/build-webpack@0.1802.11(chokidar@3.6.0)(webpack-dev-server@5.0.4(webpack@5.94.0))(webpack@5.94.0(esbuild@0.23.0))': dependencies: '@angular-devkit/architect': 0.1802.11(chokidar@3.6.0) rxjs: 7.8.1 - webpack: 5.94.0(esbuild@0.23.1) - webpack-dev-server: 5.0.4(webpack@5.94.0(esbuild@0.23.0)) + webpack: 5.94.0(esbuild@0.23.0) + webpack-dev-server: 5.0.4(webpack@5.94.0) transitivePeerDependencies: - chokidar @@ -9143,49 +9051,6 @@ snapshots: - supports-color - terser - '@angular/build@18.2.11(@angular/compiler-cli@18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3))(@types/node@22.8.5)(chokidar@3.6.0)(less@4.2.0)(postcss@8.4.41)(tailwindcss@3.4.9)(terser@5.31.6)(typescript@5.5.3)': - dependencies: - '@ampproject/remapping': 2.3.0 - '@angular-devkit/architect': 0.1802.11(chokidar@3.6.0) - '@angular/compiler-cli': 18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3) - '@babel/core': 7.25.2 - '@babel/helper-annotate-as-pure': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/plugin-syntax-import-attributes': 7.24.7(@babel/core@7.25.2) - '@inquirer/confirm': 3.1.22 - '@vitejs/plugin-basic-ssl': 1.1.0(vite@5.4.6(@types/node@22.8.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6)) - browserslist: 4.24.2 - critters: 0.0.24 - esbuild: 0.23.0 - fast-glob: 3.3.2 - https-proxy-agent: 7.0.5 - listr2: 8.2.4 - lmdb: 3.0.13 - magic-string: 0.30.11 - mrmime: 2.0.0 - parse5-html-rewriting-stream: 7.0.0 - picomatch: 4.0.2 - piscina: 4.6.1 - rollup: 4.22.4 - sass: 1.77.6 - semver: 7.6.3 - typescript: 5.5.3 - vite: 5.4.6(@types/node@22.8.5)(less@4.2.0)(sass@1.77.6)(terser@5.31.6) - watchpack: 2.4.1 - optionalDependencies: - less: 4.2.0 - postcss: 8.4.41 - tailwindcss: 3.4.9(ts-node@10.9.2(@types/node@20.14.5)(typescript@5.5.3)) - transitivePeerDependencies: - - '@types/node' - - chokidar - - lightningcss - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - '@angular/cdk@18.2.11(@angular/common@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0))(rxjs@7.8.1))(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0))(rxjs@7.8.1)': dependencies: '@angular/common': 18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0))(rxjs@7.8.1) @@ -11088,7 +10953,7 @@ snapshots: dependencies: '@angular/compiler-cli': 18.2.10(@angular/compiler@18.2.10(@angular/core@18.2.10(rxjs@7.8.1)(zone.js@0.15.0)))(typescript@5.5.3) typescript: 5.5.3 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) '@nodelib/fs.scandir@2.1.5': dependencies: @@ -12203,7 +12068,7 @@ snapshots: '@types/cors@2.8.17': dependencies: - '@types/node': 20.14.10 + '@types/node': 22.8.5 '@types/cross-spawn@6.0.6': dependencies: @@ -12770,7 +12635,7 @@ snapshots: '@vue/compiler-sfc@3.5.12': dependencies: - '@babel/parser': 7.25.3 + '@babel/parser': 7.26.2 '@vue/compiler-core': 3.5.12 '@vue/compiler-dom': 3.5.12 '@vue/compiler-ssr': 3.5.12 @@ -13267,7 +13132,7 @@ snapshots: '@babel/core': 7.25.2 find-cache-dir: 4.0.0 schema-utils: 4.2.0 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) babel-plugin-polyfill-corejs2@0.4.11(@babel/core@7.25.2): dependencies: @@ -13720,7 +13585,7 @@ snapshots: normalize-path: 3.0.0 schema-utils: 4.2.0 serialize-javascript: 6.0.2 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) core-js-compat@3.39.0: dependencies: @@ -13777,7 +13642,7 @@ snapshots: postcss-value-parser: 4.2.0 semver: 7.6.3 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) css-select@5.1.0: dependencies: @@ -13995,7 +13860,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 20.14.10 + '@types/node': 22.8.5 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 @@ -14133,8 +13998,6 @@ snapshots: '@esbuild/win32-ia32': 0.23.1 '@esbuild/win32-x64': 0.23.1 - escalade@3.1.2: {} - escalade@3.2.0: {} escape-html@1.0.3: {} @@ -15307,7 +15170,7 @@ snapshots: dependencies: less: 4.2.0 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) less@4.2.0: dependencies: @@ -15332,7 +15195,7 @@ snapshots: dependencies: webpack-sources: 3.2.3 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) lilconfig@2.1.0: {} @@ -15453,7 +15316,7 @@ snapshots: log4js@6.9.1: dependencies: date-format: 4.0.14 - debug: 4.3.5 + debug: 4.3.7 flatted: 3.3.1 rfdc: 1.4.1 streamroller: 3.1.5 @@ -15601,7 +15464,7 @@ snapshots: dependencies: schema-utils: 4.2.0 tapable: 2.2.1 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) minimalistic-assert@1.0.1: {} @@ -16171,11 +16034,25 @@ snapshots: read-cache: 1.0.0 resolve: 1.22.8 + postcss-import@15.1.0(postcss@8.4.47): + dependencies: + postcss: 8.4.47 + postcss-value-parser: 4.2.0 + read-cache: 1.0.0 + resolve: 1.22.8 + optional: true + postcss-js@4.0.1(postcss@8.4.41): dependencies: camelcase-css: 2.0.1 postcss: 8.4.41 + postcss-js@4.0.1(postcss@8.4.47): + dependencies: + camelcase-css: 2.0.1 + postcss: 8.4.47 + optional: true + postcss-load-config@3.1.4(postcss@8.4.41)(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)): dependencies: lilconfig: 2.1.0 @@ -16200,6 +16077,15 @@ snapshots: postcss: 8.4.41 ts-node: 10.9.2(@types/node@22.8.5)(typescript@5.5.3) + postcss-load-config@4.0.2(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)): + dependencies: + lilconfig: 3.1.2 + yaml: 2.4.5 + optionalDependencies: + postcss: 8.4.47 + ts-node: 10.9.2(@types/node@22.8.5)(typescript@5.5.3) + optional: true + postcss-load-config@6.0.1(jiti@2.3.1)(postcss@8.4.47)(tsx@4.19.1)(yaml@2.4.5): dependencies: lilconfig: 3.1.2 @@ -16216,7 +16102,7 @@ snapshots: postcss: 8.4.41 semver: 7.6.3 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) transitivePeerDependencies: - typescript @@ -16248,6 +16134,12 @@ snapshots: postcss: 8.4.41 postcss-selector-parser: 6.1.0 + postcss-nested@6.0.1(postcss@8.4.47): + dependencies: + postcss: 8.4.47 + postcss-selector-parser: 6.1.0 + optional: true + postcss-safe-parser@6.0.0(postcss@8.4.41): dependencies: postcss: 8.4.41 @@ -16670,7 +16562,7 @@ snapshots: neo-async: 2.6.2 optionalDependencies: sass: 1.77.6 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) sass@1.77.6: dependencies: @@ -16887,7 +16779,7 @@ snapshots: accepts: 1.3.8 base64id: 2.0.0 cors: 2.8.5 - debug: 4.3.5 + debug: 4.3.7 engine.io: 6.6.2 socket.io-adapter: 2.5.5 socket.io-parser: 4.2.4 @@ -16936,7 +16828,7 @@ snapshots: dependencies: iconv-lite: 0.6.3 source-map-js: 1.2.1 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) source-map-support@0.5.21: dependencies: @@ -17168,7 +17060,7 @@ snapshots: '@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/trace-mapping': 0.3.25 '@types/estree': 1.0.5 - acorn: 8.12.1 + acorn: 8.14.0 aria-query: 5.3.0 axobject-query: 4.1.0 code-red: 1.0.4 @@ -17258,15 +17150,15 @@ snapshots: is-glob: 4.0.3 jiti: 1.21.6 lilconfig: 2.1.0 - micromatch: 4.0.7 + micromatch: 4.0.8 normalize-path: 3.0.0 object-hash: 3.0.0 - picocolors: 1.0.1 - postcss: 8.4.41 - postcss-import: 15.1.0(postcss@8.4.41) - postcss-js: 4.0.1(postcss@8.4.41) - postcss-load-config: 4.0.2(postcss@8.4.41)(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)) - postcss-nested: 6.0.1(postcss@8.4.41) + picocolors: 1.1.0 + postcss: 8.4.47 + postcss-import: 15.1.0(postcss@8.4.47) + postcss-js: 4.0.1(postcss@8.4.47) + postcss-load-config: 4.0.2(postcss@8.4.47)(ts-node@10.9.2(@types/node@22.8.5)(typescript@5.5.3)) + postcss-nested: 6.0.1(postcss@8.4.47) postcss-selector-parser: 6.1.0 resolve: 1.22.8 sucrase: 3.35.0 @@ -17301,16 +17193,16 @@ snapshots: term-size@2.2.1: {} - terser-webpack-plugin@5.3.10(esbuild@0.23.1)(webpack@5.94.0(esbuild@0.23.0)): + terser-webpack-plugin@5.3.10(esbuild@0.23.0)(webpack@5.94.0): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.31.6 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) optionalDependencies: - esbuild: 0.23.1 + esbuild: 0.23.0 terser@5.31.6: dependencies: @@ -18040,7 +17932,7 @@ snapshots: webidl-conversions@7.0.0: {} - webpack-dev-middleware@7.4.2(webpack@5.94.0(esbuild@0.23.0)): + webpack-dev-middleware@7.4.2(webpack@5.94.0): dependencies: colorette: 2.0.20 memfs: 4.14.0 @@ -18049,9 +17941,9 @@ snapshots: range-parser: 1.2.1 schema-utils: 4.2.0 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) - webpack-dev-server@5.0.4(webpack@5.94.0(esbuild@0.23.0)): + webpack-dev-server@5.0.4(webpack@5.94.0): dependencies: '@types/bonjour': 3.5.13 '@types/connect-history-api-fallback': 1.5.4 @@ -18081,10 +17973,10 @@ snapshots: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack-dev-middleware: 7.4.2(webpack@5.94.0(esbuild@0.23.0)) + webpack-dev-middleware: 7.4.2(webpack@5.94.0) ws: 8.17.1 optionalDependencies: - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) transitivePeerDependencies: - bufferutil - debug @@ -18102,9 +17994,9 @@ snapshots: webpack-subresource-integrity@5.1.0(webpack@5.94.0(esbuild@0.23.0)): dependencies: typed-assert: 1.0.9 - webpack: 5.94.0(esbuild@0.23.1) + webpack: 5.94.0(esbuild@0.23.0) - webpack@5.94.0(esbuild@0.23.1): + webpack@5.94.0(esbuild@0.23.0): dependencies: '@types/estree': 1.0.5 '@webassemblyjs/ast': 1.12.1 @@ -18126,7 +18018,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(esbuild@0.23.1)(webpack@5.94.0(esbuild@0.23.0)) + terser-webpack-plugin: 5.3.10(esbuild@0.23.0)(webpack@5.94.0) watchpack: 2.4.1 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -18245,7 +18137,7 @@ snapshots: yargs@16.2.0: dependencies: cliui: 7.0.4 - escalade: 3.1.2 + escalade: 3.2.0 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3