@kubb/plugin-oas 3.14.1 → 3.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,6 +216,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
216
216
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
217
217
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
218
218
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
219
+ static combineObjects(tree: Schema[] | undefined): Schema[];
219
220
  build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
220
221
  /**
221
222
  * Schema
@@ -216,6 +216,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
216
216
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
217
217
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
218
218
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
219
+ static combineObjects(tree: Schema[] | undefined): Schema[];
219
220
  build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
220
221
  /**
221
222
  * Schema
@@ -129,6 +129,48 @@ var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
129
129
  });
130
130
  return foundItem;
131
131
  }
132
+ static combineObjects(tree) {
133
+ if (!tree) {
134
+ return [];
135
+ }
136
+ return tree.map((schema) => {
137
+ if (!chunkYWMMI3MO_cjs.isKeyword(schema, chunkYWMMI3MO_cjs.schemaKeywords.and)) {
138
+ return schema;
139
+ }
140
+ let mergedProperties = null;
141
+ let mergedAdditionalProps = [];
142
+ const newArgs = [];
143
+ for (const subSchema of schema.args) {
144
+ if (chunkYWMMI3MO_cjs.isKeyword(subSchema, chunkYWMMI3MO_cjs.schemaKeywords.object)) {
145
+ const { properties = {}, additionalProperties = [] } = subSchema.args ?? {};
146
+ if (!mergedProperties) {
147
+ mergedProperties = {};
148
+ }
149
+ for (const [key, value] of Object.entries(properties)) {
150
+ mergedProperties[key] = value;
151
+ }
152
+ if (additionalProperties.length > 0) {
153
+ mergedAdditionalProps = additionalProperties;
154
+ }
155
+ } else {
156
+ newArgs.push(subSchema);
157
+ }
158
+ }
159
+ if (mergedProperties) {
160
+ newArgs.push({
161
+ keyword: chunkYWMMI3MO_cjs.schemaKeywords.object,
162
+ args: {
163
+ properties: mergedProperties,
164
+ additionalProperties: mergedAdditionalProps
165
+ }
166
+ });
167
+ }
168
+ return {
169
+ keyword: chunkYWMMI3MO_cjs.schemaKeywords.and,
170
+ args: newArgs
171
+ };
172
+ });
173
+ }
132
174
  #getUsedEnumNames(props) {
133
175
  const options = this.#getOptions(props);
134
176
  return options.usedEnumNames || {};
@@ -464,35 +506,44 @@ var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
464
506
  return item && this.parse({ schemaObject: item, name, parentName })[0];
465
507
  }).filter(Boolean).filter((item) => !chunkYWMMI3MO_cjs.isKeyword(item, chunkYWMMI3MO_cjs.schemaKeywords.unknown))
466
508
  };
467
- if (schemaWithoutAllOf.required) {
468
- const schemas = schemaObject.allOf.map((item) => {
469
- if (oas.isReference(item)) {
470
- return this.context.oas.get(item.$ref);
509
+ if (schemaWithoutAllOf.required?.length) {
510
+ const allOfItems = schemaObject.allOf;
511
+ const resolvedSchemas = [];
512
+ for (const item of allOfItems) {
513
+ const resolved = oas.isReference(item) ? this.context.oas.get(item.$ref) : item;
514
+ if (resolved) {
515
+ resolvedSchemas.push(resolved);
471
516
  }
472
- }).filter(Boolean);
473
- const items = schemaWithoutAllOf.required.filter((key) => {
474
- if (schemaWithoutAllOf.properties) {
475
- return !Object.keys(schemaWithoutAllOf.properties).includes(key);
517
+ }
518
+ const existingKeys = schemaWithoutAllOf.properties ? new Set(Object.keys(schemaWithoutAllOf.properties)) : null;
519
+ const parsedItems = [];
520
+ for (const key of schemaWithoutAllOf.required) {
521
+ if (existingKeys?.has(key)) {
522
+ continue;
476
523
  }
477
- return true;
478
- }).map((key) => {
479
- const schema = schemas.find((item) => item.properties && Object.keys(item.properties).find((propertyKey) => propertyKey === key));
480
- if (schema?.properties?.[key]) {
481
- return {
482
- ...schema,
483
- properties: {
484
- [key]: schema.properties[key]
485
- },
486
- required: [key]
487
- };
524
+ for (const schema of resolvedSchemas) {
525
+ if (schema.properties?.[key]) {
526
+ parsedItems.push({
527
+ properties: {
528
+ [key]: schema.properties[key]
529
+ },
530
+ required: [key]
531
+ });
532
+ break;
533
+ }
488
534
  }
489
- }).filter(Boolean);
490
- and.args = [...and.args || [], ...items.flatMap((item) => this.parse({ schemaObject: item, name, parentName }))];
535
+ }
536
+ for (const item of parsedItems) {
537
+ const parsed = this.parse({ schemaObject: item, name, parentName });
538
+ if (Array.isArray(parsed)) {
539
+ and.args = and.args ? and.args.concat(parsed) : parsed;
540
+ }
541
+ }
491
542
  }
492
543
  if (schemaWithoutAllOf.properties) {
493
544
  and.args = [...and.args || [], ...this.parse({ schemaObject: schemaWithoutAllOf, name, parentName })];
494
545
  }
495
- return [and, ...baseItems];
546
+ return _SchemaGenerator.combineObjects([and, ...baseItems]);
496
547
  }
497
548
  if (schemaObject.enum) {
498
549
  if (options.enumSuffix === "") {
@@ -624,20 +675,23 @@ var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
624
675
  ];
625
676
  }
626
677
  if (version === "3.1" && "const" in schemaObject) {
627
- if (schemaObject["const"]) {
628
- return [
629
- {
630
- keyword: chunkYWMMI3MO_cjs.schemaKeywords.const,
631
- args: {
632
- name: schemaObject["const"],
633
- format: typeof schemaObject["const"] === "number" ? "number" : "string",
634
- value: schemaObject["const"]
635
- }
636
- },
637
- ...baseItems
638
- ];
678
+ if (schemaObject["const"] === null) {
679
+ return [{ keyword: chunkYWMMI3MO_cjs.schemaKeywords.null }];
680
+ }
681
+ if (schemaObject["const"] === void 0) {
682
+ return [{ keyword: chunkYWMMI3MO_cjs.schemaKeywords.undefined }];
639
683
  }
640
- return [{ keyword: chunkYWMMI3MO_cjs.schemaKeywords.null }];
684
+ return [
685
+ {
686
+ keyword: chunkYWMMI3MO_cjs.schemaKeywords.const,
687
+ args: {
688
+ name: schemaObject["const"],
689
+ format: typeof schemaObject["const"] === "number" ? "number" : "string",
690
+ value: schemaObject["const"]
691
+ }
692
+ },
693
+ ...baseItems
694
+ ];
641
695
  }
642
696
  if (schemaObject.format) {
643
697
  if (schemaObject.type === "integer" && (schemaObject.format === "int32" || schemaObject.format === "int64")) {
@@ -815,5 +869,5 @@ var SchemaGenerator = class _SchemaGenerator extends core.BaseGenerator {
815
869
  };
816
870
 
817
871
  exports.SchemaGenerator = SchemaGenerator;
818
- //# sourceMappingURL=chunk-HBZVPYJH.cjs.map
819
- //# sourceMappingURL=chunk-HBZVPYJH.cjs.map
872
+ //# sourceMappingURL=chunk-2LJ3ZJZP.cjs.map
873
+ //# sourceMappingURL=chunk-2LJ3ZJZP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SchemaGenerator.ts"],"names":["BaseGenerator","uniqueWith","isDeepEqual","isKeyword","schemaKeywords","isDiscriminator","getUniqueName","getSchemaFactory","isNullable","transformers","isReference","pascalCase","name","isNumber","min","max","getSchemas"],"mappings":";;;;;;;;;;;;;;AAgEa,IAAA,eAAA,GAAN,MAAM,gBAAA,SAIHA,kBAA2D,CAAA;AAAA;AAAA,EAEnE,OAAa,EAAC;AAAA;AAAA,EAGd,kBAA0C,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3C,MAAM,KAA8B,EAAA;AAClC,IAAM,MAAA,OAAA,GAAU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A,CAAQ,CAAC,SAAc,KAAA;AACjC,QAAA,MAAM,OAAO,IAAK,CAAA,KAAA,CAAM,EAAE,YAAc,EAAA,KAAA,EAAO,MAAY,CAAA;AAE3D,QAAM,MAAA,OAAA,GAAU,UAAU,MAAS,GAAA;AAAA,UACjC,QAAU,EAAA,IAAA;AAAA,UACV,MAAQ,EAAA;AAAA,YACN,IAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA,WACF;AAAA,UACA,OAAS,EAAA;AAAA,YACP,GAAG,IAAK,CAAA,OAAA;AAAA,YACR,GAAG;AAAA;AACL,SACM,CAAA;AAER,QAAA,IAAI,OAAS,EAAA;AACX,UAAA,GAAA,CAAI,KAAK,OAAO,CAAA;AAAA;AAClB,OACD,CAAA;AAED,MAAO,OAAA,GAAA;AAAA,KACT,EAAG,EAAqC,CAAA;AAExC,IAAA,MAAM,KAAQ,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,QAAQ,CAAA;AAGxC,IAAA,OAAO,KAAM,CAAA,IAAA,EAAO,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA;AACpC;AAAA;AAAA;AAAA,EAKA,MAAM,MAAA,CAAO,KAAe,EAAA,OAAA,EAAuB,QAAmD,EAAA;AACpG,IAAA,OAAO,EAAC;AAAA;AAEZ","file":"chunk-2LJ3ZJZP.cjs","sourcesContent":["import type { Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from '@kubb/core'\nimport { BaseGenerator, type FileMetaBase } from '@kubb/core'\nimport type { KubbFile } from '@kubb/core/fs'\nimport transformers, { pascalCase } from '@kubb/core/transformers'\nimport { getUniqueName } from '@kubb/core/utils'\nimport type { contentType, Oas, OpenAPIV3, SchemaObject } from '@kubb/oas'\nimport { isDiscriminator, isNullable, isReference } from '@kubb/oas'\nimport { isDeepEqual, isNumber, uniqueWith } from 'remeda'\nimport type { Generator } from './generator.tsx'\nimport type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'\nimport { isKeyword, schemaKeywords } from './SchemaMapper.ts'\nimport type { OperationSchema, Override, Refs } from './types.ts'\nimport { getSchemaFactory } from './utils/getSchemaFactory.ts'\nimport { getSchemas } from './utils/getSchemas.ts'\n\nexport type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never\n\nexport type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>\n\ntype Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {\n oas: Oas\n pluginManager: PluginManager\n /**\n * Current plugin\n */\n plugin: Plugin<TPluginOptions>\n mode: KubbFile.Mode\n include?: Array<'schemas' | 'responses' | 'requestBodies'>\n override: Array<Override<TOptions>> | undefined\n contentType?: contentType\n output?: string\n}\n\nexport type SchemaGeneratorOptions = {\n dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date'\n unknownType: 'any' | 'unknown' | 'void'\n emptySchemaType: 'any' | 'unknown' | 'void'\n enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\n enumSuffix?: string\n usedEnumNames?: Record<string, number>\n mapper?: Record<string, string>\n typed?: boolean\n transformers: {\n /**\n * Customize the names based on the type that is provided by the plugin.\n */\n name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string\n /**\n * Receive schema and name(propertName) and return FakerMeta array\n * TODO TODO add docs\n * @beta\n */\n schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined\n }\n}\n\nexport type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>\n\ntype SchemaProps = {\n schemaObject?: SchemaObject\n name?: string\n parentName?: string\n}\n\nexport class SchemaGenerator<\n TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions,\n TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,\n TFileMeta extends FileMetaBase = FileMetaBase,\n> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {\n // Collect the types of all referenced schemas, so we can export them later\n refs: Refs = {}\n\n // Keep track of already used type aliases\n #usedAliasNames: Record<string, number> = {}\n\n /**\n * Creates a type node from a given schema.\n * Delegates to getBaseTypeFromSchema internally and\n * optionally adds a union with null.\n */\n parse(props: SchemaProps): Schema[] {\n const options = this.#getOptions(props)\n\n const defaultSchemas = this.#parseSchemaObject(props)\n const schemas = options.transformers?.schema?.(props, defaultSchemas) || defaultSchemas || []\n\n return uniqueWith(schemas, isDeepEqual)\n }\n\n deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {\n return SchemaGenerator.deepSearch<T>(tree, keyword)\n }\n\n find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {\n return SchemaGenerator.find<T>(tree, keyword)\n }\n\n static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]> {\n const foundItems: SchemaKeywordMapper[T][] = []\n\n tree?.forEach((schema) => {\n if (schema.keyword === keyword) {\n foundItems.push(schema as SchemaKeywordMapper[T])\n }\n\n if (isKeyword(schema, schemaKeywords.object)) {\n Object.values(schema.args?.properties || {}).forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>(entrySchema, keyword))\n })\n\n Object.values(schema.args?.additionalProperties || {}).forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))\n })\n }\n\n if (isKeyword(schema, schemaKeywords.array)) {\n schema.args.items.forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))\n })\n }\n\n if (isKeyword(schema, schemaKeywords.and)) {\n schema.args.forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))\n })\n }\n\n if (isKeyword(schema, schemaKeywords.tuple)) {\n schema.args.items.forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))\n })\n }\n\n if (isKeyword(schema, schemaKeywords.union)) {\n schema.args.forEach((entrySchema) => {\n foundItems.push(...SchemaGenerator.deepSearch<T>([entrySchema], keyword))\n })\n }\n })\n\n return foundItems\n }\n\n static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {\n let foundItem: SchemaKeywordMapper[T] | undefined\n\n tree?.forEach((schema) => {\n if (!foundItem && schema.keyword === keyword) {\n foundItem = schema as SchemaKeywordMapper[T]\n }\n\n if (isKeyword(schema, schemaKeywords.object)) {\n Object.values(schema.args?.properties || {}).forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>(entrySchema, keyword)\n }\n })\n\n Object.values(schema.args?.additionalProperties || {}).forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>([entrySchema], keyword)\n }\n })\n }\n })\n\n return foundItem\n }\n\n static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined {\n let foundItem: SchemaKeywordMapper[T] | undefined\n\n tree?.forEach((schema) => {\n if (!foundItem && schema.keyword === keyword) {\n foundItem = schema as SchemaKeywordMapper[T]\n }\n\n if (isKeyword(schema, schemaKeywords.array)) {\n schema.args.items.forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>([entrySchema], keyword)\n }\n })\n }\n\n if (isKeyword(schema, schemaKeywords.and)) {\n schema.args.forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>([entrySchema], keyword)\n }\n })\n }\n\n if (isKeyword(schema, schemaKeywords.tuple)) {\n schema.args.items.forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>([entrySchema], keyword)\n }\n })\n }\n\n if (isKeyword(schema, schemaKeywords.union)) {\n schema.args.forEach((entrySchema) => {\n if (!foundItem) {\n foundItem = SchemaGenerator.find<T>([entrySchema], keyword)\n }\n })\n }\n })\n\n return foundItem\n }\n\n static combineObjects(tree: Schema[] | undefined): Schema[] {\n if (!tree) {\n return []\n }\n\n return tree.map((schema) => {\n if (!isKeyword(schema, schemaKeywords.and)) {\n return schema\n }\n\n let mergedProperties: Record<string, Schema[]> | null = null\n let mergedAdditionalProps: Schema[] = []\n\n const newArgs: Schema[] = []\n\n for (const subSchema of schema.args) {\n if (isKeyword(subSchema, schemaKeywords.object)) {\n const { properties = {}, additionalProperties = [] } = subSchema.args ?? {}\n\n if (!mergedProperties) {\n mergedProperties = {}\n }\n\n for (const [key, value] of Object.entries(properties)) {\n mergedProperties[key] = value\n }\n\n if (additionalProperties.length > 0) {\n mergedAdditionalProps = additionalProperties\n }\n } else {\n newArgs.push(subSchema)\n }\n }\n\n if (mergedProperties) {\n newArgs.push({\n keyword: schemaKeywords.object,\n args: {\n properties: mergedProperties,\n additionalProperties: mergedAdditionalProps,\n },\n })\n }\n\n return {\n keyword: schemaKeywords.and,\n args: newArgs,\n }\n })\n }\n\n #getUsedEnumNames(props: SchemaProps) {\n const options = this.#getOptions(props)\n\n return options.usedEnumNames || {}\n }\n\n #getOptions({ name }: SchemaProps): Partial<TOptions> {\n const { override = [] } = this.context\n\n return {\n ...this.options,\n ...(override.find(({ pattern, type }) => {\n if (name && type === 'schemaName') {\n return !!name.match(pattern)\n }\n\n return false\n })?.options || {}),\n }\n }\n\n #getUnknownType(props: SchemaProps) {\n const options = this.#getOptions(props)\n\n if (options.unknownType === 'any') {\n return schemaKeywords.any\n }\n if (options.unknownType === 'void') {\n return schemaKeywords.void\n }\n\n return schemaKeywords.unknown\n }\n\n #getEmptyType(props: SchemaProps) {\n const options = this.#getOptions(props)\n\n if (options.emptySchemaType === 'any') {\n return schemaKeywords.any\n }\n if (options.emptySchemaType === 'void') {\n return schemaKeywords.void\n }\n\n return schemaKeywords.unknown\n }\n\n /**\n * Recursively creates a type literal with the given props.\n */\n #parseProperties({ schemaObject, name }: SchemaProps): Schema[] {\n const properties = schemaObject?.properties || {}\n const additionalProperties = schemaObject?.additionalProperties\n const required = schemaObject?.required\n\n const propertiesSchemas = Object.keys(properties)\n .map((propertyName) => {\n const validationFunctions: Schema[] = []\n const propertySchema = properties[propertyName] as SchemaObject\n\n const isRequired = Array.isArray(required) ? required?.includes(propertyName) : !!required\n const nullable = propertySchema.nullable ?? propertySchema['x-nullable'] ?? false\n\n validationFunctions.push(...this.parse({ schemaObject: propertySchema, name: propertyName, parentName: name }))\n\n validationFunctions.push({\n keyword: schemaKeywords.name,\n args: propertyName,\n })\n\n if (!isRequired && nullable) {\n validationFunctions.push({ keyword: schemaKeywords.nullish })\n } else if (!isRequired) {\n validationFunctions.push({ keyword: schemaKeywords.optional })\n }\n\n return {\n [propertyName]: validationFunctions,\n }\n })\n .reduce((acc, curr) => ({ ...acc, ...curr }), {})\n let additionalPropertiesSchemas: Schema[] = []\n\n if (additionalProperties) {\n additionalPropertiesSchemas =\n additionalProperties === true || !Object.keys(additionalProperties).length\n ? [{ keyword: this.#getUnknownType({ schemaObject, name }) }]\n : this.parse({ schemaObject: additionalProperties as SchemaObject, parentName: name })\n }\n\n return [\n {\n keyword: schemaKeywords.object,\n args: {\n properties: propertiesSchemas,\n additionalProperties: additionalPropertiesSchemas,\n },\n },\n ]\n }\n\n /**\n * Create a type alias for the schema referenced by the given ReferenceObject\n */\n #getRefAlias(schemaObject: OpenAPIV3.ReferenceObject, name: string | undefined): Schema[] {\n const { $ref } = schemaObject\n const ref = this.refs[$ref]\n\n if (ref) {\n const dereferencedSchema = this.context.oas.dereferenceWithRef(schemaObject)\n // pass name to getRefAlias and use that to find in discriminator.mapping value\n\n if (dereferencedSchema && isDiscriminator(dereferencedSchema)) {\n const [key] = Object.entries(dereferencedSchema.discriminator.mapping || {}).find(([_key, value]) => value.replace(/.+\\//, '') === name) || []\n\n if (key) {\n return [\n {\n keyword: schemaKeywords.and,\n args: [\n {\n keyword: schemaKeywords.ref,\n args: { name: ref.propertyName, $ref, path: ref.path, isImportable: !!this.context.oas.get($ref) },\n },\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n [dereferencedSchema.discriminator.propertyName]: [\n {\n keyword: schemaKeywords.const,\n args: {\n name: key,\n format: 'string',\n value: key,\n },\n },\n ],\n },\n },\n },\n ],\n },\n ] as Schema[]\n }\n }\n\n return [\n {\n keyword: schemaKeywords.ref,\n args: { name: ref.propertyName, $ref, path: ref.path, isImportable: !!this.context.oas.get($ref) },\n },\n ]\n }\n\n const originalName = getUniqueName($ref.replace(/.+\\//, ''), this.#usedAliasNames)\n const propertyName = this.context.pluginManager.resolveName({\n name: originalName,\n pluginKey: this.context.plugin.key,\n type: 'function',\n })\n\n const fileName = this.context.pluginManager.resolveName({\n name: originalName,\n pluginKey: this.context.plugin.key,\n type: 'file',\n })\n const file = this.context.pluginManager.getFile({\n name: fileName,\n pluginKey: this.context.plugin.key,\n extname: '.ts',\n })\n\n this.refs[$ref] = {\n propertyName,\n originalName,\n path: file.path,\n }\n\n return this.#getRefAlias(schemaObject, name)\n }\n\n #getParsedSchemaObject(schema?: SchemaObject) {\n return getSchemaFactory(this.context.oas)(schema)\n }\n\n #addDiscriminatorToSchema<TSchema extends Schema>({\n schema,\n schemaObject,\n discriminator,\n }: {\n schemaObject: SchemaObject\n schema: TSchema\n discriminator: OpenAPIV3.DiscriminatorObject\n }): TSchema {\n if (!isKeyword(schema, schemaKeywords.union)) {\n return schema\n }\n\n const objectPropertySchema = SchemaGenerator.find(this.parse({ schemaObject: schemaObject }), schemaKeywords.object)\n\n return {\n ...schema,\n args: Object.entries(discriminator.mapping || {}).map(([key, value]) => {\n const arg = schema.args.find((item) => isKeyword(item, schemaKeywords.ref) && item.args.$ref === value)\n return {\n keyword: schemaKeywords.and,\n args: [\n arg,\n {\n keyword: schemaKeywords.object,\n args: {\n properties: {\n ...(objectPropertySchema?.args?.properties || {}),\n [discriminator.propertyName]: [\n {\n keyword: schemaKeywords.const,\n args: {\n name: key,\n format: 'string',\n value: key,\n },\n },\n //enum and literal will conflict\n ...(objectPropertySchema?.args?.properties[discriminator.propertyName] || []),\n ].filter((item) => !isKeyword(item, schemaKeywords.enum)),\n },\n },\n },\n ],\n }\n }),\n }\n }\n\n /**\n * This is the very core of the OpenAPI to TS conversion - it takes a\n * schema and returns the appropriate type.\n */\n #parseSchemaObject({ schemaObject: _schemaObject, name, parentName }: SchemaProps): Schema[] {\n const { schemaObject, version } = this.#getParsedSchemaObject(_schemaObject)\n\n const options = this.#getOptions({ schemaObject, name })\n const emptyType = this.#getEmptyType({ schemaObject, name })\n\n if (!schemaObject) {\n return [{ keyword: emptyType }]\n }\n\n const baseItems: Schema[] = [\n {\n keyword: schemaKeywords.schema,\n args: {\n type: schemaObject.type as any,\n format: schemaObject.format,\n },\n },\n ]\n const min = schemaObject.minimum ?? schemaObject.minLength ?? schemaObject.minItems ?? undefined\n const max = schemaObject.maximum ?? schemaObject.maxLength ?? schemaObject.maxItems ?? undefined\n const nullable = isNullable(schemaObject)\n const defaultNullAndNullable = schemaObject.default === null && nullable\n\n if (schemaObject.default !== undefined && !defaultNullAndNullable && !Array.isArray(schemaObject.default)) {\n if (typeof schemaObject.default === 'string') {\n baseItems.push({\n keyword: schemaKeywords.default,\n args: transformers.stringify(schemaObject.default),\n })\n } else if (typeof schemaObject.default === 'boolean') {\n baseItems.push({\n keyword: schemaKeywords.default,\n args: schemaObject.default ?? false,\n })\n } else {\n baseItems.push({\n keyword: schemaKeywords.default,\n args: schemaObject.default,\n })\n }\n }\n\n if (schemaObject.deprecated) {\n baseItems.push({\n keyword: schemaKeywords.deprecated,\n })\n }\n\n if (schemaObject.description) {\n baseItems.push({\n keyword: schemaKeywords.describe,\n args: schemaObject.description,\n })\n }\n\n if (max !== undefined) {\n baseItems.unshift({ keyword: schemaKeywords.max, args: max })\n }\n\n if (min !== undefined) {\n baseItems.unshift({ keyword: schemaKeywords.min, args: min })\n }\n\n if (nullable) {\n baseItems.push({ keyword: schemaKeywords.nullable })\n }\n\n if (schemaObject.type && Array.isArray(schemaObject.type)) {\n // OPENAPI v3.1.0: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n const items = schemaObject.type.filter((value) => value !== 'null') as Array<OpenAPIV3.NonArraySchemaObjectType>\n const hasNull = (schemaObject.type as string[]).includes('null')\n\n if (hasNull && !nullable) {\n baseItems.push({ keyword: schemaKeywords.nullable })\n }\n\n if (items.length > 1) {\n const parsedItems = [\n {\n keyword: schemaKeywords.union,\n args: items\n .map(\n (item) =>\n this.parse({\n schemaObject: { ...schemaObject, type: item },\n name,\n parentName,\n })[0],\n )\n .filter(Boolean)\n .filter((item) => !isKeyword(item, schemaKeywords.unknown))\n .map((item) => (isKeyword(item, schemaKeywords.object) ? { ...item, args: { ...item.args, strict: true } } : item)),\n },\n ]\n\n return [...parsedItems, ...baseItems].filter(Boolean)\n }\n }\n\n if (schemaObject.readOnly) {\n baseItems.push({ keyword: schemaKeywords.readOnly })\n }\n\n if (schemaObject.writeOnly) {\n baseItems.push({ keyword: schemaKeywords.writeOnly })\n }\n\n if (isReference(schemaObject)) {\n return [\n ...this.#getRefAlias(schemaObject, name),\n schemaObject.description && {\n keyword: schemaKeywords.describe,\n args: schemaObject.description,\n },\n nullable && { keyword: schemaKeywords.nullable },\n schemaObject.readOnly && { keyword: schemaKeywords.readOnly },\n schemaObject.writeOnly && { keyword: schemaKeywords.writeOnly },\n {\n keyword: schemaKeywords.schema,\n args: {\n type: schemaObject.type as any,\n format: schemaObject.format,\n },\n },\n ].filter(Boolean)\n }\n\n if (schemaObject.oneOf || schemaObject.anyOf) {\n // union\n const schemaWithoutOneOf = { ...schemaObject, oneOf: undefined, anyOf: undefined }\n const discriminator = this.context.oas.getDiscriminator(schemaObject)\n\n const union: SchemaKeywordMapper['union'] = {\n keyword: schemaKeywords.union,\n args: (schemaObject.oneOf || schemaObject.anyOf)!\n .map((item) => {\n // first item, this will be ref\n return item && this.parse({ schemaObject: item as SchemaObject, name, parentName })[0]\n })\n .filter(Boolean)\n .filter((item) => !isKeyword(item, schemaKeywords.unknown)),\n }\n\n if (discriminator) {\n if (this.context) return [this.#addDiscriminatorToSchema({ schemaObject: schemaWithoutOneOf, schema: union, discriminator }), ...baseItems]\n }\n\n if (schemaWithoutOneOf.properties) {\n const propertySchemas = this.parse({ schemaObject: schemaWithoutOneOf, name, parentName })\n\n union.args = [\n ...union.args.map((arg) => {\n return {\n keyword: schemaKeywords.and,\n args: [arg, ...propertySchemas],\n }\n }),\n ]\n\n return [union, ...baseItems]\n }\n\n return [union, ...baseItems]\n }\n\n if (schemaObject.allOf) {\n // intersection/add\n const schemaWithoutAllOf = { ...schemaObject, allOf: undefined }\n\n const and: Schema = {\n keyword: schemaKeywords.and,\n args: schemaObject.allOf\n .map((item) => {\n return item && this.parse({ schemaObject: item as SchemaObject, name, parentName })[0]\n })\n .filter(Boolean)\n .filter((item) => !isKeyword(item, schemaKeywords.unknown)),\n }\n\n if (schemaWithoutAllOf.required?.length) {\n const allOfItems = schemaObject.allOf\n const resolvedSchemas: SchemaObject[] = []\n\n for (const item of allOfItems) {\n const resolved = isReference(item) ? (this.context.oas.get(item.$ref) as SchemaObject) : item\n\n if (resolved) {\n resolvedSchemas.push(resolved)\n }\n }\n\n const existingKeys = schemaWithoutAllOf.properties ? new Set(Object.keys(schemaWithoutAllOf.properties)) : null\n\n const parsedItems: SchemaObject[] = []\n\n for (const key of schemaWithoutAllOf.required) {\n if (existingKeys?.has(key)) {\n continue\n }\n\n for (const schema of resolvedSchemas) {\n if (schema.properties?.[key]) {\n parsedItems.push({\n properties: {\n [key]: schema.properties[key],\n },\n required: [key],\n } as SchemaObject)\n break\n }\n }\n }\n\n for (const item of parsedItems) {\n const parsed = this.parse({ schemaObject: item, name, parentName })\n\n if (Array.isArray(parsed)) {\n and.args = and.args ? and.args.concat(parsed) : parsed\n }\n }\n }\n\n if (schemaWithoutAllOf.properties) {\n and.args = [...(and.args || []), ...this.parse({ schemaObject: schemaWithoutAllOf, name, parentName })]\n }\n\n return SchemaGenerator.combineObjects([and, ...baseItems])\n }\n\n if (schemaObject.enum) {\n if (options.enumSuffix === '') {\n this.context.pluginManager.logger.emit('info', 'EnumSuffix set to an empty string does not work')\n }\n\n const enumName = getUniqueName(pascalCase([parentName, name, options.enumSuffix].join(' ')), this.#getUsedEnumNames({ schemaObject, name }))\n const typeName = this.context.pluginManager.resolveName({\n name: enumName,\n pluginKey: this.context.plugin.key,\n type: 'type',\n })\n\n const nullableEnum = schemaObject.enum.includes(null)\n if (nullableEnum) {\n baseItems.push({ keyword: schemaKeywords.nullable })\n }\n const filteredValues = schemaObject.enum.filter((value) => value !== null)\n\n // x-enumNames has priority\n const extensionEnums = ['x-enumNames', 'x-enum-varnames']\n .filter((extensionKey) => extensionKey in schemaObject)\n .map((extensionKey) => {\n return [\n {\n keyword: schemaKeywords.enum,\n args: {\n name,\n typeName,\n asConst: false,\n items: [...new Set(schemaObject[extensionKey as keyof typeof schemaObject] as string[])].map((name: string | number, index) => ({\n name: transformers.stringify(name),\n value: schemaObject.enum?.[index] as string | number,\n format: isNumber(schemaObject.enum?.[index]) ? 'number' : 'string',\n })),\n },\n },\n ...baseItems.filter(\n (item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches,\n ),\n ]\n })\n\n if (schemaObject.type === 'number' || schemaObject.type === 'integer') {\n // we cannot use z.enum when enum type is number/integer\n const enumNames = extensionEnums[0]?.find((item) => isKeyword(item, schemaKeywords.enum)) as unknown as SchemaKeywordMapper['enum']\n return [\n {\n keyword: schemaKeywords.enum,\n args: {\n name: enumName,\n typeName,\n asConst: true,\n items: enumNames?.args?.items\n ? [...new Set(enumNames.args.items)].map(({ name, value }) => ({\n name,\n value,\n format: 'number',\n }))\n : [...new Set(filteredValues)].map((value: string) => {\n return {\n name: value,\n value,\n format: 'number',\n }\n }),\n },\n },\n ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches),\n ]\n }\n\n if (schemaObject.type === 'boolean') {\n // we cannot use z.enum when enum type is boolean\n const enumNames = extensionEnums[0]?.find((item) => isKeyword(item, schemaKeywords.enum)) as unknown as SchemaKeywordMapper['enum']\n return [\n {\n keyword: schemaKeywords.enum,\n args: {\n name: enumName,\n typeName,\n asConst: true,\n items: enumNames?.args?.items\n ? [...new Set(enumNames.args.items)].map(({ name, value }) => ({\n name,\n value,\n format: 'boolean',\n }))\n : [...new Set(filteredValues)].map((value: string) => {\n return {\n name: value,\n value,\n format: 'boolean',\n }\n }),\n },\n },\n ...baseItems.filter((item) => item.keyword !== schemaKeywords.matches),\n ]\n }\n\n if (extensionEnums.length > 0 && extensionEnums[0]) {\n return extensionEnums[0]\n }\n\n return [\n {\n keyword: schemaKeywords.enum,\n args: {\n name: enumName,\n typeName,\n asConst: false,\n items: [...new Set(filteredValues)].map((value: string) => ({\n name: transformers.stringify(value),\n value,\n format: isNumber(value) ? 'number' : 'string',\n })),\n },\n },\n ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches),\n ]\n }\n\n if ('prefixItems' in schemaObject) {\n const prefixItems = schemaObject.prefixItems as SchemaObject[]\n const items = 'items' in schemaObject ? (schemaObject.items as SchemaObject[]) : []\n const min = schemaObject.minimum ?? schemaObject.minLength ?? schemaObject.minItems ?? undefined\n const max = schemaObject.maximum ?? schemaObject.maxLength ?? schemaObject.maxItems ?? undefined\n\n return [\n {\n keyword: schemaKeywords.tuple,\n args: {\n min,\n max,\n items: prefixItems\n .map((item) => {\n return this.parse({ schemaObject: item, name, parentName })[0]\n })\n .filter(Boolean),\n rest: this.parse({\n schemaObject: items,\n name,\n parentName,\n })[0],\n },\n },\n ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max),\n ]\n }\n\n if (version === '3.1' && 'const' in schemaObject) {\n // const keyword takes precendence over the actual type.\n\n if (schemaObject['const'] === null) {\n return [{ keyword: schemaKeywords.null }]\n }\n if (schemaObject['const'] === undefined) {\n return [{ keyword: schemaKeywords.undefined }]\n }\n\n return [\n {\n keyword: schemaKeywords.const,\n args: {\n name: schemaObject['const'],\n format: typeof schemaObject['const'] === 'number' ? 'number' : 'string',\n value: schemaObject['const'],\n },\n },\n ...baseItems,\n ]\n }\n\n /**\n * > Structural validation alone may be insufficient to allow an application to correctly utilize certain values. The \"format\"\n * > annotation keyword is defined to allow schema authors to convey semantic information for a fixed subset of values which are\n * > accurately described by authoritative resources, be they RFCs or other external specifications.\n *\n * In other words: format is more specific than type alone, hence it should override the type value, if possible.\n *\n * see also https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7\n */\n if (schemaObject.format) {\n if (schemaObject.type === 'integer' && (schemaObject.format === 'int32' || schemaObject.format === 'int64')) {\n baseItems.unshift({ keyword: schemaKeywords.integer })\n return baseItems\n }\n\n if (schemaObject.type === 'number' && (schemaObject.format === 'float' || schemaObject.format === 'double')) {\n baseItems.unshift({ keyword: schemaKeywords.number })\n return baseItems\n }\n\n switch (schemaObject.format) {\n case 'binary':\n baseItems.push({ keyword: schemaKeywords.blob })\n return baseItems\n case 'date-time':\n if (options.dateType) {\n if (options.dateType === 'date') {\n baseItems.unshift({ keyword: schemaKeywords.date, args: { type: 'date' } })\n\n return baseItems\n }\n\n if (options.dateType === 'stringOffset') {\n baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: true } })\n return baseItems\n }\n\n if (options.dateType === 'stringLocal') {\n baseItems.unshift({ keyword: schemaKeywords.datetime, args: { local: true } })\n return baseItems\n }\n\n baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: false } })\n\n return baseItems\n }\n break\n case 'date':\n if (options.dateType) {\n if (options.dateType === 'date') {\n baseItems.unshift({ keyword: schemaKeywords.date, args: { type: 'date' } })\n\n return baseItems\n }\n\n baseItems.unshift({ keyword: schemaKeywords.date, args: { type: 'string' } })\n\n return baseItems\n }\n break\n case 'time':\n if (options.dateType) {\n if (options.dateType === 'date') {\n baseItems.unshift({ keyword: schemaKeywords.time, args: { type: 'date' } })\n\n return baseItems\n }\n\n baseItems.unshift({ keyword: schemaKeywords.time, args: { type: 'string' } })\n\n return baseItems\n }\n break\n case 'uuid':\n baseItems.unshift({ keyword: schemaKeywords.uuid })\n return baseItems\n case 'email':\n case 'idn-email':\n baseItems.unshift({ keyword: schemaKeywords.email })\n return baseItems\n case 'uri':\n case 'ipv4':\n case 'ipv6':\n case 'uri-reference':\n case 'hostname':\n case 'idn-hostname':\n baseItems.unshift({ keyword: schemaKeywords.url })\n return baseItems\n // case 'duration':\n // case 'json-pointer':\n // case 'relative-json-pointer':\n default:\n // formats not yet implemented: ignore.\n break\n }\n }\n\n if (schemaObject.pattern && schemaObject.type === 'string') {\n baseItems.unshift({\n keyword: schemaKeywords.matches,\n args: schemaObject.pattern,\n })\n\n return baseItems\n }\n\n // type based logic\n if ('items' in schemaObject || schemaObject.type === ('array' as 'string')) {\n const min = schemaObject.minimum ?? schemaObject.minLength ?? schemaObject.minItems ?? undefined\n const max = schemaObject.maximum ?? schemaObject.maxLength ?? schemaObject.maxItems ?? undefined\n const items = this.parse({ schemaObject: 'items' in schemaObject ? (schemaObject.items as SchemaObject) : [], name, parentName })\n const unique = !!schemaObject.uniqueItems\n\n return [\n {\n keyword: schemaKeywords.array,\n args: {\n items,\n min,\n max,\n unique,\n },\n },\n ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max),\n ]\n }\n\n if (schemaObject.properties || schemaObject.additionalProperties) {\n if (isDiscriminator(schemaObject)) {\n // override schema to set type to be based on discriminator mapping, use of enum to convert type string to type 'mapping1' | 'mapping2'\n const schemaObjectOverriden = Object.keys(schemaObject.properties || {}).reduce((acc, propertyName) => {\n if (acc.properties?.[propertyName] && propertyName === schemaObject.discriminator.propertyName) {\n return {\n ...acc,\n properties: {\n ...acc.properties,\n [propertyName]: {\n ...((acc.properties[propertyName] as any) || {}),\n enum: schemaObject.discriminator.mapping ? Object.keys(schemaObject.discriminator.mapping) : undefined,\n },\n },\n }\n }\n\n return acc\n }, schemaObject || {}) as SchemaObject\n\n return [\n ...this.#parseProperties({\n schemaObject: schemaObjectOverriden,\n name,\n }),\n ...baseItems,\n ]\n }\n\n return [...this.#parseProperties({ schemaObject, name }), ...baseItems]\n }\n\n if (schemaObject.type) {\n const type = (\n Array.isArray(schemaObject.type) ? schemaObject.type.filter((item) => item !== 'null')[0] : schemaObject.type\n ) as OpenAPIV3.NonArraySchemaObjectType\n\n if (!['boolean', 'object', 'number', 'string', 'integer', 'null'].includes(type)) {\n this.context.pluginManager.logger.emit('warning', `Schema type '${schemaObject.type}' is not valid for schema ${parentName}.${name}`)\n }\n\n // 'string' | 'number' | 'integer' | 'boolean'\n return [{ keyword: type }, ...baseItems]\n }\n\n return [{ keyword: emptyType }]\n }\n\n async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {\n const { oas, contentType, include } = this.context\n\n const schemas = getSchemas({ oas, contentType, includes: include })\n\n const promises = Object.entries(schemas).reduce((acc, [name, value]) => {\n if (!value) {\n return acc\n }\n\n const options = this.#getOptions({ name })\n const promiseOperation = this.schema.call(this, name, value, {\n ...this.options,\n ...options,\n })\n\n if (promiseOperation) {\n acc.push(promiseOperation)\n }\n\n generators?.forEach((generator) => {\n const tree = this.parse({ schemaObject: value, name: name })\n\n const promise = generator.schema?.({\n instance: this,\n schema: {\n name,\n value,\n tree,\n },\n options: {\n ...this.options,\n ...options,\n },\n } as any) as Promise<Array<KubbFile.File<TFileMeta>>>\n\n if (promise) {\n acc.push(promise)\n }\n })\n\n return acc\n }, [] as SchemaMethodResult<TFileMeta>[])\n\n const files = await Promise.all(promises)\n\n // using .flat because schemaGenerator[method] can return an array of files or just one file\n return files.flat().filter(Boolean)\n }\n\n /**\n * Schema\n */\n async schema(_name: string, _object: SchemaObject, _options: TOptions): SchemaMethodResult<TFileMeta> {\n return []\n }\n}\n"]}
@@ -123,6 +123,48 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
123
123
  });
124
124
  return foundItem;
125
125
  }
126
+ static combineObjects(tree) {
127
+ if (!tree) {
128
+ return [];
129
+ }
130
+ return tree.map((schema) => {
131
+ if (!isKeyword(schema, schemaKeywords.and)) {
132
+ return schema;
133
+ }
134
+ let mergedProperties = null;
135
+ let mergedAdditionalProps = [];
136
+ const newArgs = [];
137
+ for (const subSchema of schema.args) {
138
+ if (isKeyword(subSchema, schemaKeywords.object)) {
139
+ const { properties = {}, additionalProperties = [] } = subSchema.args ?? {};
140
+ if (!mergedProperties) {
141
+ mergedProperties = {};
142
+ }
143
+ for (const [key, value] of Object.entries(properties)) {
144
+ mergedProperties[key] = value;
145
+ }
146
+ if (additionalProperties.length > 0) {
147
+ mergedAdditionalProps = additionalProperties;
148
+ }
149
+ } else {
150
+ newArgs.push(subSchema);
151
+ }
152
+ }
153
+ if (mergedProperties) {
154
+ newArgs.push({
155
+ keyword: schemaKeywords.object,
156
+ args: {
157
+ properties: mergedProperties,
158
+ additionalProperties: mergedAdditionalProps
159
+ }
160
+ });
161
+ }
162
+ return {
163
+ keyword: schemaKeywords.and,
164
+ args: newArgs
165
+ };
166
+ });
167
+ }
126
168
  #getUsedEnumNames(props) {
127
169
  const options = this.#getOptions(props);
128
170
  return options.usedEnumNames || {};
@@ -458,35 +500,44 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
458
500
  return item && this.parse({ schemaObject: item, name, parentName })[0];
459
501
  }).filter(Boolean).filter((item) => !isKeyword(item, schemaKeywords.unknown))
460
502
  };
461
- if (schemaWithoutAllOf.required) {
462
- const schemas = schemaObject.allOf.map((item) => {
463
- if (isReference(item)) {
464
- return this.context.oas.get(item.$ref);
503
+ if (schemaWithoutAllOf.required?.length) {
504
+ const allOfItems = schemaObject.allOf;
505
+ const resolvedSchemas = [];
506
+ for (const item of allOfItems) {
507
+ const resolved = isReference(item) ? this.context.oas.get(item.$ref) : item;
508
+ if (resolved) {
509
+ resolvedSchemas.push(resolved);
465
510
  }
466
- }).filter(Boolean);
467
- const items = schemaWithoutAllOf.required.filter((key) => {
468
- if (schemaWithoutAllOf.properties) {
469
- return !Object.keys(schemaWithoutAllOf.properties).includes(key);
511
+ }
512
+ const existingKeys = schemaWithoutAllOf.properties ? new Set(Object.keys(schemaWithoutAllOf.properties)) : null;
513
+ const parsedItems = [];
514
+ for (const key of schemaWithoutAllOf.required) {
515
+ if (existingKeys?.has(key)) {
516
+ continue;
470
517
  }
471
- return true;
472
- }).map((key) => {
473
- const schema = schemas.find((item) => item.properties && Object.keys(item.properties).find((propertyKey) => propertyKey === key));
474
- if (schema?.properties?.[key]) {
475
- return {
476
- ...schema,
477
- properties: {
478
- [key]: schema.properties[key]
479
- },
480
- required: [key]
481
- };
518
+ for (const schema of resolvedSchemas) {
519
+ if (schema.properties?.[key]) {
520
+ parsedItems.push({
521
+ properties: {
522
+ [key]: schema.properties[key]
523
+ },
524
+ required: [key]
525
+ });
526
+ break;
527
+ }
482
528
  }
483
- }).filter(Boolean);
484
- and.args = [...and.args || [], ...items.flatMap((item) => this.parse({ schemaObject: item, name, parentName }))];
529
+ }
530
+ for (const item of parsedItems) {
531
+ const parsed = this.parse({ schemaObject: item, name, parentName });
532
+ if (Array.isArray(parsed)) {
533
+ and.args = and.args ? and.args.concat(parsed) : parsed;
534
+ }
535
+ }
485
536
  }
486
537
  if (schemaWithoutAllOf.properties) {
487
538
  and.args = [...and.args || [], ...this.parse({ schemaObject: schemaWithoutAllOf, name, parentName })];
488
539
  }
489
- return [and, ...baseItems];
540
+ return _SchemaGenerator.combineObjects([and, ...baseItems]);
490
541
  }
491
542
  if (schemaObject.enum) {
492
543
  if (options.enumSuffix === "") {
@@ -618,20 +669,23 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
618
669
  ];
619
670
  }
620
671
  if (version === "3.1" && "const" in schemaObject) {
621
- if (schemaObject["const"]) {
622
- return [
623
- {
624
- keyword: schemaKeywords.const,
625
- args: {
626
- name: schemaObject["const"],
627
- format: typeof schemaObject["const"] === "number" ? "number" : "string",
628
- value: schemaObject["const"]
629
- }
630
- },
631
- ...baseItems
632
- ];
672
+ if (schemaObject["const"] === null) {
673
+ return [{ keyword: schemaKeywords.null }];
674
+ }
675
+ if (schemaObject["const"] === void 0) {
676
+ return [{ keyword: schemaKeywords.undefined }];
633
677
  }
634
- return [{ keyword: schemaKeywords.null }];
678
+ return [
679
+ {
680
+ keyword: schemaKeywords.const,
681
+ args: {
682
+ name: schemaObject["const"],
683
+ format: typeof schemaObject["const"] === "number" ? "number" : "string",
684
+ value: schemaObject["const"]
685
+ }
686
+ },
687
+ ...baseItems
688
+ ];
635
689
  }
636
690
  if (schemaObject.format) {
637
691
  if (schemaObject.type === "integer" && (schemaObject.format === "int32" || schemaObject.format === "int64")) {
@@ -809,5 +863,5 @@ var SchemaGenerator = class _SchemaGenerator extends BaseGenerator {
809
863
  };
810
864
 
811
865
  export { SchemaGenerator };
812
- //# sourceMappingURL=chunk-ZJMQ57BF.js.map
813
- //# sourceMappingURL=chunk-ZJMQ57BF.js.map
866
+ //# sourceMappingURL=chunk-JSR2ZSPP.js.map
867
+ //# sourceMappingURL=chunk-JSR2ZSPP.js.map