@kubb/oas 4.33.4 → 4.33.5

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.
package/dist/index.cjs CHANGED
@@ -5018,32 +5018,53 @@ var Oas = class extends oas.default {
5018
5018
  const schemasWithMeta = [];
5019
5019
  if (includes.includes("schemas")) {
5020
5020
  const componentSchemas = components?.schemas || {};
5021
- for (const [name, schema] of Object.entries(componentSchemas)) schemasWithMeta.push({
5022
- schema,
5023
- source: "schemas",
5024
- originalName: name
5025
- });
5021
+ for (const [name, schemaObject] of Object.entries(componentSchemas)) {
5022
+ let schema = schemaObject;
5023
+ if (isReference(schemaObject)) {
5024
+ const resolved = this.get(schemaObject.$ref);
5025
+ if (resolved && !isReference(resolved)) schema = resolved;
5026
+ }
5027
+ schemasWithMeta.push({
5028
+ schema,
5029
+ source: "schemas",
5030
+ originalName: name
5031
+ });
5032
+ }
5026
5033
  }
5027
5034
  if (includes.includes("responses")) {
5028
5035
  const responses = components?.responses || {};
5029
5036
  for (const [name, response] of Object.entries(responses)) {
5030
5037
  const schema = extractSchemaFromContent(response.content, contentType);
5031
- if (schema) schemasWithMeta.push({
5032
- schema,
5033
- source: "responses",
5034
- originalName: name
5035
- });
5038
+ if (schema) {
5039
+ let resolvedSchema = schema;
5040
+ if (isReference(schema)) {
5041
+ const resolved = this.get(schema.$ref);
5042
+ if (resolved && !isReference(resolved)) resolvedSchema = resolved;
5043
+ }
5044
+ schemasWithMeta.push({
5045
+ schema: resolvedSchema,
5046
+ source: "responses",
5047
+ originalName: name
5048
+ });
5049
+ }
5036
5050
  }
5037
5051
  }
5038
5052
  if (includes.includes("requestBodies")) {
5039
5053
  const requestBodies = components?.requestBodies || {};
5040
5054
  for (const [name, request] of Object.entries(requestBodies)) {
5041
5055
  const schema = extractSchemaFromContent(request.content, contentType);
5042
- if (schema) schemasWithMeta.push({
5043
- schema,
5044
- source: "requestBodies",
5045
- originalName: name
5046
- });
5056
+ if (schema) {
5057
+ let resolvedSchema = schema;
5058
+ if (isReference(schema)) {
5059
+ const resolved = this.get(schema.$ref);
5060
+ if (resolved && !isReference(resolved)) resolvedSchema = resolved;
5061
+ }
5062
+ schemasWithMeta.push({
5063
+ schema: resolvedSchema,
5064
+ source: "requestBodies",
5065
+ originalName: name
5066
+ });
5067
+ }
5047
5068
  }
5048
5069
  }
5049
5070
  const { schemas, nameMapping } = shouldResolveCollisions ? resolveCollisions(schemasWithMeta) : legacyResolve(schemasWithMeta);