@kubb/adapter-oas 5.0.0-beta.20 → 5.0.0-beta.21
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 +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/adapter.ts +1 -1
- package/src/discriminator.ts +3 -3
- package/src/parser.ts +7 -7
- package/src/stream.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -1151,7 +1151,7 @@ function createSchemaParser(ctx) {
|
|
|
1151
1151
|
* Circular refs are detected via `resolvingRefs` and leave `schema` as `undefined`.
|
|
1152
1152
|
*/
|
|
1153
1153
|
function convertRef({ schema, name, nullable, defaultValue, rawOptions }) {
|
|
1154
|
-
let resolvedSchema;
|
|
1154
|
+
let resolvedSchema = null;
|
|
1155
1155
|
const refPath = schema.$ref;
|
|
1156
1156
|
if (refPath && !resolvingRefs.has(refPath)) {
|
|
1157
1157
|
if (!resolvedRefCache.has(refPath)) {
|
|
@@ -1165,7 +1165,7 @@ function createSchemaParser(ctx) {
|
|
|
1165
1165
|
} catch {}
|
|
1166
1166
|
resolvedRefCache.set(refPath, resolvedSchema);
|
|
1167
1167
|
}
|
|
1168
|
-
resolvedSchema = resolvedRefCache.get(refPath);
|
|
1168
|
+
resolvedSchema = resolvedRefCache.get(refPath) ?? null;
|
|
1169
1169
|
}
|
|
1170
1170
|
return ast.createSchema({
|
|
1171
1171
|
...buildSchemaNode(schema, name, nullable, defaultValue),
|
|
@@ -1551,7 +1551,7 @@ function createSchemaParser(ctx) {
|
|
|
1551
1551
|
*/
|
|
1552
1552
|
function convertArray({ schema, name, nullable, defaultValue, rawOptions, options }) {
|
|
1553
1553
|
const rawItems = schema.items;
|
|
1554
|
-
const itemName = rawItems?.enum?.length && name ? ast.enumPropName(
|
|
1554
|
+
const itemName = rawItems?.enum?.length && name ? ast.enumPropName(null, name, options.enumSuffix) : void 0;
|
|
1555
1555
|
const items = rawItems ? [parseSchema({
|
|
1556
1556
|
schema: rawItems,
|
|
1557
1557
|
name: itemName
|
|
@@ -1742,13 +1742,13 @@ function createSchemaParser(ctx) {
|
|
|
1742
1742
|
* `$ref` entries are skipped since their flags live on the dereferenced target.
|
|
1743
1743
|
*/
|
|
1744
1744
|
function collectPropertyKeysByFlag(schema, flag) {
|
|
1745
|
-
if (!schema?.properties) return
|
|
1745
|
+
if (!schema?.properties) return null;
|
|
1746
1746
|
const keys = [];
|
|
1747
1747
|
for (const key in schema.properties) {
|
|
1748
1748
|
const prop = schema.properties[key];
|
|
1749
1749
|
if (prop && !isReference(prop) && prop[flag]) keys.push(key);
|
|
1750
1750
|
}
|
|
1751
|
-
return keys.length ? keys :
|
|
1751
|
+
return keys.length ? keys : null;
|
|
1752
1752
|
}
|
|
1753
1753
|
/**
|
|
1754
1754
|
* Converts an OAS `Operation` into an `OperationNode`.
|
|
@@ -1834,15 +1834,15 @@ function buildDiscriminatorChildMap(schemas) {
|
|
|
1834
1834
|
for (const member of members) {
|
|
1835
1835
|
const intersectionNode = ast.narrowSchema(member, "intersection");
|
|
1836
1836
|
if (!intersectionNode?.members) continue;
|
|
1837
|
-
let refNode;
|
|
1838
|
-
let objNode;
|
|
1837
|
+
let refNode = null;
|
|
1838
|
+
let objNode = null;
|
|
1839
1839
|
for (const m of intersectionNode.members) {
|
|
1840
1840
|
refNode ??= ast.narrowSchema(m, "ref");
|
|
1841
1841
|
objNode ??= ast.narrowSchema(m, "object");
|
|
1842
1842
|
}
|
|
1843
1843
|
if (!refNode?.name || !objNode) continue;
|
|
1844
1844
|
const prop = objNode.properties.find((p) => p.name === discriminatorPropertyName);
|
|
1845
|
-
const enumNode = prop ? ast.narrowSchema(prop.schema, "enum") :
|
|
1845
|
+
const enumNode = prop ? ast.narrowSchema(prop.schema, "enum") : null;
|
|
1846
1846
|
if (!enumNode?.enumValues?.length) continue;
|
|
1847
1847
|
const enumValues = enumNode.enumValues.filter((v) => v !== null);
|
|
1848
1848
|
if (!enumValues.length) continue;
|
|
@@ -1890,7 +1890,7 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
1890
1890
|
* Reads the server URL from the document's `servers` array at `serverIndex`,
|
|
1891
1891
|
* interpolating any `serverVariables` into the URL template.
|
|
1892
1892
|
*
|
|
1893
|
-
* Returns `
|
|
1893
|
+
* Returns `null` when `serverIndex` is omitted or out of range.
|
|
1894
1894
|
*
|
|
1895
1895
|
* @example Resolve the first server
|
|
1896
1896
|
* `resolveBaseUrl({ document, serverIndex: 0 })`
|
|
@@ -1900,7 +1900,7 @@ function patchDiscriminatorNode(node, entry) {
|
|
|
1900
1900
|
*/
|
|
1901
1901
|
function resolveBaseUrl({ document, serverIndex, serverVariables }) {
|
|
1902
1902
|
const server = serverIndex !== void 0 ? document.servers?.at(serverIndex) : void 0;
|
|
1903
|
-
return server?.url ? resolveServerUrl(server, serverVariables) :
|
|
1903
|
+
return server?.url ? resolveServerUrl(server, serverVariables) : null;
|
|
1904
1904
|
}
|
|
1905
1905
|
/**
|
|
1906
1906
|
* Parses every schema once to build the lookup structures that streaming needs upfront.
|
|
@@ -2116,7 +2116,7 @@ const adapterOas = createAdapter((options) => {
|
|
|
2116
2116
|
nameMapping,
|
|
2117
2117
|
resolve: (schemaName) => {
|
|
2118
2118
|
const result = resolve(schemaName);
|
|
2119
|
-
if (!result) return;
|
|
2119
|
+
if (!result) return null;
|
|
2120
2120
|
return ast.createImport({
|
|
2121
2121
|
name: [result.name],
|
|
2122
2122
|
path: result.path
|