@kubb/adapter-oas 5.14.2 → 5.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.
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ var compatibility = {
36
36
  };
37
37
  //#endregion
38
38
  //#region package.json
39
- var version = "5.14.2";
39
+ var version = "5.14.4";
40
40
  //#endregion
41
41
  //#region src/constants.ts
42
42
  /**
@@ -1919,7 +1919,7 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
1919
1919
  nullable,
1920
1920
  defaultValue
1921
1921
  };
1922
- if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: "unknown" });
1922
+ if (refPath && document.components && !refs.resolve(refPath, { report: false })) return createNode(ctx, { type: _kubb_kit.ast.schemaTypes.unknown });
1923
1923
  if (refPath && !refPath.startsWith("#/components/schemas/") && resolvedSchema) return _kubb_kit.ast.factory.createSchema({
1924
1924
  ...resolvedSchema,
1925
1925
  title: schema.title ?? resolvedSchema.title,
@@ -1933,7 +1933,7 @@ function convertRef({ schema, name, nullable, defaultValue, document, parse, ref
1933
1933
  });
1934
1934
  const targetName = renames?.get(schema.$ref);
1935
1935
  return createNode(ctx, {
1936
- type: "ref",
1936
+ type: _kubb_kit.ast.schemaTypes.ref,
1937
1937
  name: (0, _kubb_kit.extractRefName)(schema.$ref),
1938
1938
  ref: schema.$ref,
1939
1939
  ...targetName ? { targetName } : {},
@@ -1945,7 +1945,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
1945
1945
  const { not, ...rest } = schema;
1946
1946
  const [subschema] = resolveUnionMembers([not], rest.properties ?? {});
1947
1947
  const notNode = _kubb_kit.ast.factory.createSchema({
1948
- type: "not",
1948
+ type: _kubb_kit.ast.schemaTypes.not,
1949
1949
  members: [parse({ schema: subschema })]
1950
1950
  });
1951
1951
  return createNode({
@@ -1954,7 +1954,7 @@ function convertNot({ schema, name, nullable, defaultValue, parse }) {
1954
1954
  nullable,
1955
1955
  defaultValue
1956
1956
  }, {
1957
- type: "intersection",
1957
+ type: _kubb_kit.ast.schemaTypes.intersection,
1958
1958
  members: [parse({
1959
1959
  schema: rest,
1960
1960
  name
@@ -2074,7 +2074,7 @@ function convertAllOf({ schema: original, name, nullable, defaultValue, parse, r
2074
2074
  nullable,
2075
2075
  defaultValue
2076
2076
  }, {
2077
- type: "intersection",
2077
+ type: _kubb_kit.ast.schemaTypes.intersection,
2078
2078
  members: [...(0, _kubb_kit.mergeAdjacentObjectsLazy)(allOfMembers.slice(0, syntheticStart)), ...(0, _kubb_kit.mergeAdjacentObjectsLazy)(allOfMembers.slice(syntheticStart))]
2079
2079
  });
2080
2080
  }
@@ -2100,7 +2100,8 @@ function convertUnion(context) {
2100
2100
  schema: memberBaseSchema,
2101
2101
  name
2102
2102
  }) : void 0;
2103
- if (sharedPropertiesNode || discriminator) {
2103
+ const missingRequired = (Array.isArray(schema.required) ? schema.required : []).filter((key) => !Object.hasOwn(schema.properties ?? {}, key));
2104
+ if (sharedPropertiesNode || discriminator || missingRequired.length) {
2104
2105
  const members = narrowUnionMembers({
2105
2106
  unionMembers,
2106
2107
  discriminator,
@@ -2115,15 +2116,25 @@ function convertUnion(context) {
2115
2116
  refs
2116
2117
  });
2117
2118
  const unionNode = createNode(ctx, {
2118
- type: "union",
2119
+ type: _kubb_kit.ast.schemaTypes.union,
2119
2120
  strategy,
2120
2121
  members,
2121
2122
  discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.inferDiscriminatorPropertyName(members)
2122
2123
  });
2123
- if (!sharedPropertiesNode) return unionNode;
2124
+ const requiredProperties = missingRequired.map((name) => _kubb_kit.ast.factory.createProperty({
2125
+ name,
2126
+ required: true,
2127
+ schema: _kubb_kit.ast.factory.createSchema({ type: _kubb_kit.ast.schemaTypes.unknown })
2128
+ }));
2129
+ const siblings = sharedPropertiesNode ? [sharedPropertiesNode] : [];
2130
+ if (requiredProperties.length) siblings.push(_kubb_kit.ast.factory.createSchema({
2131
+ type: _kubb_kit.ast.schemaTypes.object,
2132
+ properties: requiredProperties
2133
+ }));
2134
+ if (!siblings.length) return unionNode;
2124
2135
  return createNode(ctx, {
2125
- type: "intersection",
2126
- members: [unionNode, sharedPropertiesNode]
2136
+ type: _kubb_kit.ast.schemaTypes.intersection,
2137
+ members: [unionNode, ...siblings]
2127
2138
  });
2128
2139
  }
2129
2140
  const members = unionMembers.map((s) => parse({
@@ -2131,7 +2142,7 @@ function convertUnion(context) {
2131
2142
  name
2132
2143
  }));
2133
2144
  const unionNode = createNode(ctx, {
2134
- type: "union",
2145
+ type: _kubb_kit.ast.schemaTypes.union,
2135
2146
  strategy,
2136
2147
  members,
2137
2148
  discriminatorPropertyName: explicitDiscriminatorPropertyName ?? _kubb_kit.ast.inferDiscriminatorPropertyName(members)
@@ -2153,7 +2164,7 @@ function convertMultiType({ schema, name, nullable, defaultValue, parse }) {
2153
2164
  nullable: types.includes("null") || nullable || void 0,
2154
2165
  defaultValue
2155
2166
  }, {
2156
- type: "union",
2167
+ type: _kubb_kit.ast.schemaTypes.union,
2157
2168
  members: nonNullTypes.map((t) => {
2158
2169
  return parse({
2159
2170
  schema: {