@sdk-it/spec 0.45.0 → 0.46.1
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/README.md +65 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
- package/dist/lib/find-polymorphic-varients.js +6 -11
- package/dist/lib/find-polymorphic-varients.js.map +2 -2
- package/dist/lib/for-each-operation.d.ts +11 -3
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +23 -15
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/format-name.d.ts.map +1 -1
- package/dist/lib/format-name.js +0 -1
- package/dist/lib/format-name.js.map +2 -2
- package/dist/lib/ir.d.ts +2 -2
- package/dist/lib/ir.d.ts.map +1 -1
- package/dist/lib/ir.js +6 -120
- package/dist/lib/ir.js.map +2 -2
- package/dist/lib/is-primitive-schema.js +1 -1
- package/dist/lib/is-primitive-schema.js.map +1 -1
- package/dist/lib/is.d.ts +2 -0
- package/dist/lib/is.d.ts.map +1 -1
- package/dist/lib/is.js +6 -3
- package/dist/lib/is.js.map +2 -2
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.js +1 -11
- package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
- package/dist/lib/options.d.ts +7 -45
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +26 -28
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/overview-pagination.d.ts +1 -1
- package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-pagination.js +1 -1
- package/dist/lib/overview-docs/overview-pagination.js.map +2 -2
- package/dist/lib/pagination/guess-pagination.d.ts.map +1 -1
- package/dist/lib/pagination/guess-pagination.js +1 -1
- package/dist/lib/pagination/guess-pagination.js.map +2 -2
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.js +15 -5
- package/dist/lib/pagination/pagination-result.js.map +2 -2
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +7 -6
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts +3 -0
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js +29 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js.map +7 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +5 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js +30 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +7 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts +25 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -0
- package/dist/lib/processing-plugins/enrich-examples.js +93 -0
- package/dist/lib/processing-plugins/enrich-examples.js.map +7 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js +165 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js +13 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js.map +7 -0
- package/dist/lib/processing-plugins/index.d.ts +14 -0
- package/dist/lib/processing-plugins/index.d.ts.map +1 -0
- package/dist/lib/processing-plugins/index.js +14 -0
- package/dist/lib/processing-plugins/index.js.map +7 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts +3 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -0
- package/dist/lib/processing-plugins/infer-pagination.js +21 -0
- package/dist/lib/processing-plugins/infer-pagination.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js +74 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-parameters.js +29 -0
- package/dist/lib/processing-plugins/normalize-parameters.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-paths.js +67 -0
- package/dist/lib/processing-plugins/normalize-paths.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +6 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js +139 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -0
- package/dist/lib/{tune-response.js → processing-plugins/normalize-responses.js} +55 -25
- package/dist/lib/processing-plugins/normalize-responses.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-schemas.js +170 -0
- package/dist/lib/processing-plugins/normalize-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-tags.js +18 -0
- package/dist/lib/processing-plugins/normalize-tags.js.map +7 -0
- package/dist/lib/processing.d.ts +33 -0
- package/dist/lib/processing.d.ts.map +1 -0
- package/dist/lib/processing.js +41 -0
- package/dist/lib/processing.js.map +7 -0
- package/dist/lib/reserved-keywords.d.ts.map +1 -1
- package/dist/lib/reserved-keywords.js +18 -1
- package/dist/lib/reserved-keywords.js.map +2 -2
- package/dist/lib/tag.js +2 -2
- package/dist/lib/tag.js.map +2 -2
- package/dist/lib/types.d.ts +4 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/walk-schemas.d.ts +8 -0
- package/dist/lib/walk-schemas.d.ts.map +1 -0
- package/dist/lib/walk-schemas.js +51 -0
- package/dist/lib/walk-schemas.js.map +7 -0
- package/package.json +2 -2
- package/dist/lib/tune-request-body.d.ts +0 -5
- package/dist/lib/tune-request-body.d.ts.map +0 -1
- package/dist/lib/tune-request-body.js +0 -91
- package/dist/lib/tune-request-body.js.map +0 -7
- package/dist/lib/tune-response.d.ts +0 -5
- package/dist/lib/tune-response.d.ts.map +0 -1
- package/dist/lib/tune-response.js.map +0 -7
- package/dist/lib/tune.d.ts +0 -11
- package/dist/lib/tune.d.ts.map +0 -1
- package/dist/lib/tune.js +0 -291
- package/dist/lib/tune.js.map +0 -7
package/dist/lib/types.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { PaginationGuess } from './pagination/guess-pagination.js';
|
|
|
3
3
|
import type { SidebarData, TagGroups } from './sidebar.js';
|
|
4
4
|
export interface IR extends OpenAPIObject {
|
|
5
5
|
servers: ServerObject[];
|
|
6
|
-
'x-sdk-
|
|
6
|
+
'x-sdk-processing'?: {
|
|
7
|
+
plugins: string[];
|
|
8
|
+
configuration: string;
|
|
9
|
+
};
|
|
7
10
|
'x-docs': SidebarData;
|
|
8
11
|
'x-tagGroups': TagGroups[];
|
|
9
12
|
components: Omit<ComponentsObject, 'schemas'> & {
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,EAAG,SAAQ,aAAa;IACvC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,EAAG,SAAQ,aAAa;IACvC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE;QACnB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE,WAAW,CAAC;IACtB,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;QAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CA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
1
|
+
import type { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import type { IR } from './types.js';
|
|
3
|
+
export interface WalkedSchema {
|
|
4
|
+
schema: SchemaObject;
|
|
5
|
+
pointer: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function walkSchemas(spec: IR): Generator<WalkedSchema>;
|
|
8
|
+
//# sourceMappingURL=walk-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk-schemas.d.ts","sourceRoot":"","sources":["../../src/lib/walk-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAiDD,wBAAiB,WAAW,CAAC,IAAI,EAAE,EAAE,GAAG,SAAS,CAAC,YAAY,CAAC,CAS9D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isRef } from "@sdk-it/core/ref.js";
|
|
2
|
+
function escapePointerSegment(segment) {
|
|
3
|
+
return segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
4
|
+
}
|
|
5
|
+
function* walkSchema(schema, pointer, visited) {
|
|
6
|
+
if (isRef(schema) || visited.has(schema)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
visited.add(schema);
|
|
10
|
+
yield { schema, pointer };
|
|
11
|
+
for (const key of ["properties", "x-properties"]) {
|
|
12
|
+
const properties = schema[key];
|
|
13
|
+
for (const [name, property] of Object.entries(properties ?? {})) {
|
|
14
|
+
yield* walkSchema(
|
|
15
|
+
property,
|
|
16
|
+
`${pointer}/${key}/${escapePointerSegment(name)}`,
|
|
17
|
+
visited
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const key of [
|
|
22
|
+
"items",
|
|
23
|
+
"not",
|
|
24
|
+
"additionalProperties",
|
|
25
|
+
"propertyNames"
|
|
26
|
+
]) {
|
|
27
|
+
const child = schema[key];
|
|
28
|
+
if (typeof child === "object" && child !== null) {
|
|
29
|
+
yield* walkSchema(child, `${pointer}/${key}`, visited);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const key of ["allOf", "oneOf", "anyOf", "prefixItems"]) {
|
|
33
|
+
for (const [index, child] of (schema[key] ?? []).entries()) {
|
|
34
|
+
yield* walkSchema(child, `${pointer}/${key}/${index}`, visited);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function* walkSchemas(spec) {
|
|
39
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
40
|
+
for (const [name, schema] of Object.entries(spec.components.schemas)) {
|
|
41
|
+
yield* walkSchema(
|
|
42
|
+
schema,
|
|
43
|
+
`#/components/schemas/${escapePointerSegment(name)}`,
|
|
44
|
+
visited
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
walkSchemas
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=walk-schemas.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/walk-schemas.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { isRef } from '@sdk-it/core/ref.js';\n\nimport type { IR } from './types.js';\n\nexport interface WalkedSchema {\n schema: SchemaObject;\n pointer: string;\n}\n\nfunction escapePointerSegment(segment: string) {\n return segment.replaceAll('~', '~0').replaceAll('/', '~1');\n}\n\nfunction* walkSchema(\n schema: SchemaObject | ReferenceObject,\n pointer: string,\n visited: WeakSet<SchemaObject>,\n): Generator<WalkedSchema> {\n if (isRef(schema) || visited.has(schema)) {\n return;\n }\n\n visited.add(schema);\n yield { schema, pointer };\n\n for (const key of ['properties', 'x-properties'] as const) {\n const properties = schema[key] as\n Record<string, SchemaObject | ReferenceObject> | undefined;\n for (const [name, property] of Object.entries(properties ?? {})) {\n yield* walkSchema(\n property,\n `${pointer}/${key}/${escapePointerSegment(name)}`,\n visited,\n );\n }\n }\n\n for (const key of [\n 'items',\n 'not',\n 'additionalProperties',\n 'propertyNames',\n ] as const) {\n const child = schema[key];\n if (typeof child === 'object' && child !== null) {\n yield* walkSchema(child, `${pointer}/${key}`, visited);\n }\n }\n\n for (const key of ['allOf', 'oneOf', 'anyOf', 'prefixItems'] as const) {\n for (const [index, child] of (schema[key] ?? []).entries()) {\n yield* walkSchema(child, `${pointer}/${key}/${index}`, visited);\n }\n }\n}\n\nexport function* walkSchemas(spec: IR): Generator<WalkedSchema> {\n const visited = new WeakSet<SchemaObject>();\n for (const [name, schema] of Object.entries(spec.components.schemas)) {\n yield* walkSchema(\n schema,\n `#/components/schemas/${escapePointerSegment(name)}`,\n visited,\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,aAAa;AAStB,SAAS,qBAAqB,SAAiB;AAC7C,SAAO,QAAQ,WAAW,KAAK,IAAI,EAAE,WAAW,KAAK,IAAI;AAC3D;AAEA,UAAU,WACR,QACA,SACA,SACyB;AACzB,MAAI,MAAM,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG;AACxC;AAAA,EACF;AAEA,UAAQ,IAAI,MAAM;AAClB,QAAM,EAAE,QAAQ,QAAQ;AAExB,aAAW,OAAO,CAAC,cAAc,cAAc,GAAY;AACzD,UAAM,aAAa,OAAO,GAAG;AAE7B,eAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,cAAc,CAAC,CAAC,GAAG;AAC/D,aAAO;AAAA,QACL;AAAA,QACA,GAAG,OAAO,IAAI,GAAG,IAAI,qBAAqB,IAAI,CAAC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,aAAW,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAY;AACV,UAAM,QAAQ,OAAO,GAAG;AACxB,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,aAAO,WAAW,OAAO,GAAG,OAAO,IAAI,GAAG,IAAI,OAAO;AAAA,IACvD;AAAA,EACF;AAEA,aAAW,OAAO,CAAC,SAAS,SAAS,SAAS,aAAa,GAAY;AACrE,eAAW,CAAC,OAAO,KAAK,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,QAAQ,GAAG;AAC1D,aAAO,WAAW,OAAO,GAAG,OAAO,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO;AAAA,IAChE;AAAA,EACF;AACF;AAEO,UAAU,YAAY,MAAmC;AAC9D,QAAM,UAAU,oBAAI,QAAsB;AAC1C,aAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,KAAK,WAAW,OAAO,GAAG;AACpE,WAAO;AAAA,MACL;AAAA,MACA,wBAAwB,qBAAqB,IAAI,CAAC;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdk-it/spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"!**/*.test.*"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@sdk-it/core": "0.
|
|
30
|
+
"@sdk-it/core": "0.46.1",
|
|
31
31
|
"openapi3-ts": "4.5.0",
|
|
32
32
|
"pluralize": "^8.0.0",
|
|
33
33
|
"stringcase": "^4.3.1",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { OperationObject, ParameterObject, SchemaObject, SecurityRequirementObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import type { IR, OurRequestBodyObject } from './types.js';
|
|
3
|
-
export declare function patchParameters(spec: IR, schema: SchemaObject, parameters: ParameterObject[], security: SecurityRequirementObject[]): void;
|
|
4
|
-
export declare function tuneRequestBody(spec: IR, operationId: string, operation: OperationObject, parameters: ParameterObject[], security: SecurityRequirementObject[]): OurRequestBodyObject;
|
|
5
|
-
//# sourceMappingURL=tune-request-body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tune-request-body.d.ts","sourceRoot":"","sources":["../../src/lib/tune-request-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAEf,YAAY,EACZ,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAO3B,OAAO,KAAK,EAAE,EAAE,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3D,wBAAgB,eAAe,CAC7B,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,eAAe,EAAE,EAC7B,QAAQ,EAAE,yBAAyB,EAAE,QA+BtC;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,EAC1B,UAAU,EAAE,eAAe,EAAE,EAC7B,QAAQ,EAAE,yBAAyB,EAAE,GACpC,oBAAoB,CA+DtB"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { followRef, isRef } from "@sdk-it/core/ref.js";
|
|
2
|
-
import { isEmpty } from "@sdk-it/core/utils.js";
|
|
3
|
-
import { findUniqueSchemaName } from "./find-unique-schema-name.js";
|
|
4
|
-
import { securityToOptions } from "./security.js";
|
|
5
|
-
function patchParameters(spec, schema, parameters, security) {
|
|
6
|
-
const securityOptions = securityToOptions(
|
|
7
|
-
spec,
|
|
8
|
-
security,
|
|
9
|
-
spec.components.securitySchemes
|
|
10
|
-
);
|
|
11
|
-
let required = Array.isArray(schema.required) ? schema.required : [];
|
|
12
|
-
schema["x-properties"] ??= {};
|
|
13
|
-
for (const param of parameters) {
|
|
14
|
-
if (param.required) {
|
|
15
|
-
required.push(param.name);
|
|
16
|
-
}
|
|
17
|
-
schema["x-properties"][param.name] = {
|
|
18
|
-
"x-in": param.in,
|
|
19
|
-
...isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" }
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
for (const param of securityOptions) {
|
|
23
|
-
required = required.filter((name) => name !== param.name);
|
|
24
|
-
schema["x-properties"][param.name] = {
|
|
25
|
-
"x-in": "header",
|
|
26
|
-
...isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" }
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
schema["x-required"] = required;
|
|
30
|
-
}
|
|
31
|
-
function tuneRequestBody(spec, operationId, operation, parameters, security) {
|
|
32
|
-
const inputName = findUniqueSchemaName(spec, operationId, [
|
|
33
|
-
"input",
|
|
34
|
-
"payload",
|
|
35
|
-
"request"
|
|
36
|
-
]);
|
|
37
|
-
const requestBody = isRef(operation.requestBody) ? followRef(spec, operation.requestBody.$ref) : operation.requestBody ?? {
|
|
38
|
-
content: {},
|
|
39
|
-
required: false
|
|
40
|
-
};
|
|
41
|
-
if (isEmpty(requestBody.content)) {
|
|
42
|
-
const schema = {
|
|
43
|
-
"x-inputname": inputName,
|
|
44
|
-
"x-requestbody": true
|
|
45
|
-
};
|
|
46
|
-
patchParameters(spec, schema, parameters, security);
|
|
47
|
-
const tuned = {
|
|
48
|
-
...requestBody,
|
|
49
|
-
content: {
|
|
50
|
-
"application/empty": {
|
|
51
|
-
schema: { $ref: `#/components/schemas/${inputName}` }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
spec.components.schemas[inputName] = schema;
|
|
56
|
-
return tuned;
|
|
57
|
-
}
|
|
58
|
-
for (const contentType in requestBody.content) {
|
|
59
|
-
const mediaType = requestBody.content[contentType];
|
|
60
|
-
let schema;
|
|
61
|
-
switch (true) {
|
|
62
|
-
case isRef(mediaType.schema):
|
|
63
|
-
schema = followRef(spec, mediaType.schema.$ref);
|
|
64
|
-
break;
|
|
65
|
-
case isEmpty(mediaType.schema):
|
|
66
|
-
schema ??= {};
|
|
67
|
-
console.warn(
|
|
68
|
-
`Request body schema for content type "${contentType}" is empty.`
|
|
69
|
-
);
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
schema = mediaType.schema;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
patchParameters(spec, schema, parameters, security);
|
|
76
|
-
spec.components.schemas[inputName] = {
|
|
77
|
-
...schema,
|
|
78
|
-
"x-requestbody": true,
|
|
79
|
-
"x-inputname": inputName
|
|
80
|
-
};
|
|
81
|
-
requestBody.content[contentType].schema = {
|
|
82
|
-
$ref: `#/components/schemas/${inputName}`
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return requestBody;
|
|
86
|
-
}
|
|
87
|
-
export {
|
|
88
|
-
patchParameters,
|
|
89
|
-
tuneRequestBody
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=tune-request-body.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/lib/tune-request-body.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n SchemaObject,\n SecurityRequirementObject,\n} from 'openapi3-ts/oas31';\n\nimport { followRef, isRef } from '@sdk-it/core/ref.js';\nimport { isEmpty } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport { securityToOptions } from './security.js';\nimport type { IR, OurRequestBodyObject } from './types.js';\n\nexport function patchParameters(\n spec: IR,\n schema: SchemaObject,\n parameters: ParameterObject[],\n security: SecurityRequirementObject[],\n) {\n const securityOptions = securityToOptions(\n spec,\n security,\n spec.components.securitySchemes,\n );\n\n let required = Array.isArray(schema.required) ? schema.required : [];\n schema['x-properties'] ??= {};\n for (const param of parameters) {\n if (param.required) {\n required.push(param.name);\n }\n schema['x-properties'][param.name] = {\n 'x-in': param.in,\n ...(isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' })),\n };\n }\n for (const param of securityOptions) {\n required = required.filter((name) => name !== param.name);\n schema['x-properties'][param.name] = {\n 'x-in': 'header',\n ...(isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' })),\n };\n }\n schema['x-required'] = required;\n}\n\nexport function tuneRequestBody(\n spec: IR,\n operationId: string,\n operation: OperationObject,\n parameters: ParameterObject[],\n security: SecurityRequirementObject[],\n): OurRequestBodyObject {\n const inputName = findUniqueSchemaName(spec, operationId, [\n 'input',\n 'payload',\n 'request',\n ]);\n const requestBody = isRef(operation.requestBody)\n ? followRef<RequestBodyObject>(spec, operation.requestBody.$ref)\n : (operation.requestBody ?? {\n content: {},\n required: false,\n });\n if (isEmpty(requestBody.content)) {\n const schema: SchemaObject = {\n 'x-inputname': inputName,\n 'x-requestbody': true,\n };\n patchParameters(spec, schema, parameters, security);\n const tuned: OurRequestBodyObject = {\n ...requestBody,\n content: {\n 'application/empty': {\n schema: { $ref: `#/components/schemas/${inputName}` },\n },\n },\n };\n\n spec.components.schemas[inputName] = schema;\n return tuned;\n }\n for (const contentType in requestBody.content) {\n const mediaType = requestBody.content[contentType];\n let schema: SchemaObject | undefined;\n\n switch (true) {\n case isRef(mediaType.schema):\n schema = followRef<SchemaObject>(spec, mediaType.schema.$ref);\n // we cannot use the model name as inputName as it might be used in other places that are not request bodies\n // inputName = parseRef(mediaType.schema.$ref).model;\n break;\n case isEmpty(mediaType.schema):\n schema ??= {}; // default to empty schema if not defined\n console.warn(\n `Request body schema for content type \"${contentType}\" is empty.`,\n );\n break;\n default:\n schema = mediaType.schema;\n break;\n }\n\n patchParameters(spec, schema, parameters, security);\n spec.components.schemas[inputName] = {\n ...schema,\n 'x-requestbody': true,\n 'x-inputname': inputName,\n };\n\n requestBody.content[contentType].schema = {\n $ref: `#/components/schemas/${inputName}`,\n };\n }\n return requestBody as OurRequestBodyObject;\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,WAAW,aAAa;AACjC,SAAS,eAAe;AAExB,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAG3B,SAAS,gBACd,MACA,QACA,YACA,UACA;AACA,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,KAAK,WAAW;AAAA,EAClB;AAEA,MAAI,WAAW,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;AACnE,SAAO,cAAc,MAAM,CAAC;AAC5B,aAAW,SAAS,YAAY;AAC9B,QAAI,MAAM,UAAU;AAClB,eAAS,KAAK,MAAM,IAAI;AAAA,IAC1B;AACA,WAAO,cAAc,EAAE,MAAM,IAAI,IAAI;AAAA,MACnC,QAAQ,MAAM;AAAA,MACd,GAAI,MAAM,MAAM,MAAM,IAClB,UAAwB,MAAM,MAAM,OAAO,IAAI,IAC9C,MAAM,UAAU,EAAE,MAAM,SAAS;AAAA,IACxC;AAAA,EACF;AACA,aAAW,SAAS,iBAAiB;AACnC,eAAW,SAAS,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;AACxD,WAAO,cAAc,EAAE,MAAM,IAAI,IAAI;AAAA,MACnC,QAAQ;AAAA,MACR,GAAI,MAAM,MAAM,MAAM,IAClB,UAAwB,MAAM,MAAM,OAAO,IAAI,IAC9C,MAAM,UAAU,EAAE,MAAM,SAAS;AAAA,IACxC;AAAA,EACF;AACA,SAAO,YAAY,IAAI;AACzB;AAEO,SAAS,gBACd,MACA,aACA,WACA,YACA,UACsB;AACtB,QAAM,YAAY,qBAAqB,MAAM,aAAa;AAAA,IACxD;AAAA,IACA;AAAA,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/oas31';
|
|
2
|
-
import { type ResponsesConfig } from './options.js';
|
|
3
|
-
import type { IR } from './types.js';
|
|
4
|
-
export declare function resolveResponses(spec: IR, operationId: string, operation: OperationObject, responsesConfig?: ResponsesConfig): import("openapi3-ts/oas31").ResponsesObject;
|
|
5
|
-
//# sourceMappingURL=tune-response.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tune-response.d.ts","sourceRoot":"","sources":["../../src/lib/tune-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAc3B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,EAC1B,eAAe,CAAC,EAAE,eAAe,+CAuIlC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/lib/tune-response.ts"],
|
|
4
|
-
"sourcesContent": ["import { parse as parseContentType } from 'fast-content-type-parse';\nimport type {\n MediaTypeObject,\n OperationObject,\n ResponseObject,\n} from 'openapi3-ts/oas31';\n\nimport { isRef, parseRef, resolveRef } from '@sdk-it/core/ref.js';\nimport { isEmpty, pascalcase } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport {\n isBinaryContentType,\n isSseContentType,\n isStreamingContentType,\n isSuccessStatusCode,\n isTextContentType,\n parseJsonContentType,\n} from './is.js';\nimport { type ResponsesConfig } from './options.js';\nimport type { IR } from './types.js';\n\nexport function resolveResponses(\n spec: IR,\n operationId: string,\n operation: OperationObject,\n responsesConfig?: ResponsesConfig,\n) {\n const responses = operation.responses ?? {};\n operation.responses ??= {};\n let foundSuccessResponse = false;\n for (const status in responses) {\n if (status === 'default') {\n delete responses[status]; // Skip default response\n continue;\n }\n // use structuredClone to avoid mutating a response object\n // that is referenced by multiple operations\n operation.responses[status] = structuredClone(\n resolveRef<ResponseObject>(spec, responses[status]),\n );\n\n if (isSuccessStatusCode(status)) {\n foundSuccessResponse = true;\n }\n }\n\n if (!foundSuccessResponse) {\n operation.responses['200'] = {\n description: 'OK',\n content: {\n 'application/json': {\n schema: {},\n },\n },\n };\n }\n\n for (const status in operation.responses) {\n const response = operation.responses[status] as ResponseObject;\n const statusCode = +status;\n\n const outputName =\n statusCode !== 200\n ? pascalcase(operationId) + status\n : findUniqueSchemaName(spec, operationId, [\n 'output',\n 'payload',\n 'result',\n ]);\n\n if (!responsesConfig?.flattenErrorResponses) {\n if (!isSuccessStatusCode(status)) {\n continue;\n }\n }\n\n if (isEmpty(response.content)) {\n response.content = {\n 'application/octet-stream': {},\n };\n }\n\n response['x-response-name'] = outputName;\n\n // if (isErrorStatusCode(status)) {\n // const mediaType = response.content?.['application/json'];\n // if (mediaType && isRef(mediaType.schema)) {\n // const { model } = parseRef(mediaType.schema.$ref);\n // Object.assign(config.spec.components.schemas[model], {\n // 'x-responsebody': true,\n // // do not assign response ref to a group\n // // because they are supposed to be in a separate file only inlined\n // // schemas are grouped by operationId\n // });\n // response['x-response-name'] = model;\n // }\n // continue;\n // }\n\n for (const [contentType, mediaType] of Object.entries(\n response.content as Record<string, MediaTypeObject>,\n )) {\n if (isRef(mediaType.schema)) {\n const { model } = parseRef(mediaType.schema.$ref);\n Object.assign(spec.components.schemas[model], {\n 'x-responsebody': true,\n // do not assign response ref to a group\n // because they are supposed to be in a separate file only inlined\n // schemas are grouped by operationId\n });\n response['x-response-name'] = model;\n continue;\n }\n const isSse = isSseContentType(contentType);\n const normalizedContentType = normalizeContentType(contentType);\n const hasContentDisposition = hasHeader(\n response.headers,\n 'Content-Disposition',\n );\n const isBinary =\n isBinaryContentType(contentType) ||\n (isStreamingContentType(normalizedContentType) &&\n hasContentDisposition);\n const isText = isTextContentType(contentType);\n\n if (parseJsonContentType(contentType)) {\n if (isEmpty(mediaType.schema)) {\n // add \"additionalProperties\" because we're certain this is a response body is of json type\n spec.components.schemas[outputName] = {\n type: 'object',\n additionalProperties: true,\n };\n }\n } else {\n if (isEmpty(mediaType.schema) && (isText || isBinary)) {\n mediaType.schema = {\n type: 'string',\n ...(isBinary ? { format: 'binary' } : {}),\n };\n }\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n 'x-stream': isSse || (!isText && !isBinary),\n ...(isSse ? { 'x-sse': true } : {}),\n };\n }\n\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n ...mediaType.schema,\n 'x-responsebody': true,\n 'x-response-group': operationId,\n };\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n\n return operation.responses;\n}\n\nfunction normalizeContentType(contentType: string) {\n try {\n return parseContentType(contentType)?.type?.toLowerCase();\n } catch {\n return contentType.split(';')[0]?.trim().toLowerCase();\n }\n}\n\nfunction hasHeader(headers: ResponseObject['headers'], name: string) {\n if (!headers) {\n return false;\n }\n const target = name.toLowerCase();\n return Object.keys(headers).some((key) => key.toLowerCase() === target);\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS,wBAAwB;AAO1C,SAAS,OAAO,UAAU,kBAAkB;AAC5C,SAAS,SAAS,kBAAkB;AAEpC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,eAAqC;AAG9B,SAAS,iBACd,MACA,aACA,WACA,iBACA;AACA,QAAM,YAAY,UAAU,aAAa,CAAC;AAC1C,YAAU,cAAc,CAAC;AACzB,MAAI,uBAAuB;AAC3B,aAAW,UAAU,WAAW;AAC9B,QAAI,WAAW,WAAW;AACxB,aAAO,UAAU,MAAM;AACvB;AAAA,IACF;AAGA,cAAU,UAAU,MAAM,IAAI;A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O,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,YAAY,MAAM,MAAM;AACxE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/lib/tune.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ReferenceObject, SchemaObject, SchemaObjectType } from 'openapi3-ts/oas31';
|
|
2
|
-
import type { IR } from './types.js';
|
|
3
|
-
export declare function fixSpec(spec: IR, schemas: (SchemaObject | ReferenceObject)[], visited?: Set<string>): void;
|
|
4
|
-
type Refs = {
|
|
5
|
-
name: string;
|
|
6
|
-
value: SchemaObject;
|
|
7
|
-
}[];
|
|
8
|
-
export declare function expandSpec(spec: IR, schemas: Record<string, SchemaObject | ReferenceObject>, refs: Refs): void;
|
|
9
|
-
export declare function coerceTypes(schema: SchemaObject, excludeNull?: boolean): SchemaObjectType[];
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=tune.d.ts.map
|
package/dist/lib/tune.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tune.d.ts","sourceRoot":"","sources":["../../src/lib/tune.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAgB,OAAO,CACrB,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAC3C,OAAO,cAAoB,QAqK5B;AAED,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,EAAE,CAAC;AAEpD,wBAAgB,UAAU,CACxB,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,EACvD,IAAI,EAAE,IAAI,QAoJX;AA0CD,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,WAAW,UAAO,GACjB,gBAAgB,EAAE,CAUpB"}
|
package/dist/lib/tune.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { merge, uniq } from "lodash-es";
|
|
2
|
-
import assert from "node:assert";
|
|
3
|
-
import {
|
|
4
|
-
isEmpty,
|
|
5
|
-
isRef,
|
|
6
|
-
joinSkipDigits,
|
|
7
|
-
notRef,
|
|
8
|
-
pascalcase,
|
|
9
|
-
resolveRef,
|
|
10
|
-
snakecase
|
|
11
|
-
} from "@sdk-it/core";
|
|
12
|
-
import { findVarients } from "./find-polymorphic-varients.js";
|
|
13
|
-
import { findUniqueSchemaName } from "./find-unique-schema-name.js";
|
|
14
|
-
import { formatName } from "./format-name.js";
|
|
15
|
-
import { isPrimitiveSchema } from "./is-primitive-schema.js";
|
|
16
|
-
function fixSpec(spec, schemas, visited = /* @__PURE__ */ new Set()) {
|
|
17
|
-
for (const schema of schemas) {
|
|
18
|
-
if (isRef(schema)) continue;
|
|
19
|
-
if (!isEmpty(schema.properties)) {
|
|
20
|
-
schema.type = "object";
|
|
21
|
-
delete schema.oneOf;
|
|
22
|
-
delete schema.anyOf;
|
|
23
|
-
fixSpec(spec, Object.values(schema.properties), visited);
|
|
24
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
25
|
-
if (notRef(value) && isPrimitiveSchema(value)) {
|
|
26
|
-
value.default ??= schema.default?.[key];
|
|
27
|
-
delete schema.default?.[key];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
delete schema.default;
|
|
31
|
-
}
|
|
32
|
-
if (!isEmpty(schema["x-properties"])) {
|
|
33
|
-
fixSpec(spec, Object.values(schema["x-properties"]), visited);
|
|
34
|
-
}
|
|
35
|
-
if (!isEmpty(schema.items)) {
|
|
36
|
-
delete schema.oneOf;
|
|
37
|
-
delete schema.anyOf;
|
|
38
|
-
schema.type = "array";
|
|
39
|
-
fixSpec(spec, [schema.items], visited);
|
|
40
|
-
const items = resolveRef(spec, schema.items);
|
|
41
|
-
if (Array.isArray(items.default)) {
|
|
42
|
-
schema.default ??= structuredClone(items.default);
|
|
43
|
-
}
|
|
44
|
-
delete items.default;
|
|
45
|
-
}
|
|
46
|
-
if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {
|
|
47
|
-
delete schema.anyOf;
|
|
48
|
-
}
|
|
49
|
-
if (isEmpty(schema.enum)) {
|
|
50
|
-
delete schema.enum;
|
|
51
|
-
}
|
|
52
|
-
if (!isEmpty(schema.enum)) {
|
|
53
|
-
if (schema.enum.length === 1) {
|
|
54
|
-
schema.const = schema.enum[0];
|
|
55
|
-
delete schema.enum;
|
|
56
|
-
} else {
|
|
57
|
-
const valuesSet = /* @__PURE__ */ new Set();
|
|
58
|
-
const valuesList = [];
|
|
59
|
-
for (const it of schema.enum) {
|
|
60
|
-
const formattedValue = formatName(snakecase(formatName(it)));
|
|
61
|
-
if (!valuesSet.has(formattedValue)) {
|
|
62
|
-
valuesSet.add(formattedValue);
|
|
63
|
-
valuesList.push(it);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
schema.enum = valuesList;
|
|
67
|
-
}
|
|
68
|
-
delete schema.allOf;
|
|
69
|
-
}
|
|
70
|
-
if (schema.const !== void 0) {
|
|
71
|
-
schema.default = schema.const;
|
|
72
|
-
}
|
|
73
|
-
if (!isEmpty(schema.allOf)) {
|
|
74
|
-
const schemas2 = schema.allOf;
|
|
75
|
-
const resolved = schemas2.map((it) => resolveRef(spec, it));
|
|
76
|
-
const hasObjects = resolved.some((it) => it.type === "object");
|
|
77
|
-
const hasOtherTypes = resolved.some(
|
|
78
|
-
(it) => it.type && it.type !== "object"
|
|
79
|
-
);
|
|
80
|
-
if (hasObjects && hasOtherTypes) {
|
|
81
|
-
assert(false, `allOf must be an object`);
|
|
82
|
-
}
|
|
83
|
-
merge(
|
|
84
|
-
schema,
|
|
85
|
-
...resolved.map((it) => {
|
|
86
|
-
fixSpec(spec, [it], visited);
|
|
87
|
-
return it;
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
delete schema.allOf;
|
|
91
|
-
} else {
|
|
92
|
-
delete schema.allOf;
|
|
93
|
-
}
|
|
94
|
-
if (schema.type === "object" && isEmpty(schema.properties) && typeof schema.additionalProperties === "object" && !isEmpty(schema.additionalProperties) && notRef(schema.additionalProperties) && !isEmpty(schema.additionalProperties.properties)) {
|
|
95
|
-
fixSpec(
|
|
96
|
-
spec,
|
|
97
|
-
Object.values(schema.additionalProperties.properties),
|
|
98
|
-
visited
|
|
99
|
-
);
|
|
100
|
-
Object.assign(schema, schema.additionalProperties);
|
|
101
|
-
delete schema.additionalProperties;
|
|
102
|
-
}
|
|
103
|
-
for (const kind of ["oneOf", "anyOf"]) {
|
|
104
|
-
if (!isEmpty(schema[kind])) {
|
|
105
|
-
delete schema.type;
|
|
106
|
-
fixSpec(spec, schema[kind], visited);
|
|
107
|
-
if (isEmpty(schema[kind])) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
let enumSchemaIndex = -1;
|
|
111
|
-
const enumValues = [];
|
|
112
|
-
for (let idx = 0; idx < schema[kind].length; idx++) {
|
|
113
|
-
const item = schema[kind][idx];
|
|
114
|
-
if (notRef(item) && item.type === "string") {
|
|
115
|
-
if (item.enum && item.enum.length > 1) {
|
|
116
|
-
enumValues.push(...item.enum);
|
|
117
|
-
if (enumSchemaIndex === -1) {
|
|
118
|
-
enumSchemaIndex = idx;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (enumSchemaIndex !== -1) {
|
|
124
|
-
const enumSchema = schema[kind][enumSchemaIndex];
|
|
125
|
-
if (notRef(enumSchema)) {
|
|
126
|
-
enumSchema.enum = uniq(enumValues);
|
|
127
|
-
}
|
|
128
|
-
schema[kind] = schema[kind].filter(
|
|
129
|
-
(it, idx) => idx === enumSchemaIndex || isRef(it)
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
const otherTypes = schema[kind].filter(
|
|
133
|
-
(it) => resolveRef(spec, it).type !== "null"
|
|
134
|
-
);
|
|
135
|
-
if (otherTypes.length === 1) {
|
|
136
|
-
Object.assign(schema, otherTypes[0]);
|
|
137
|
-
delete schema[kind];
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
schema["x-varients"] = findVarients(spec, schema[kind]);
|
|
141
|
-
} else {
|
|
142
|
-
delete schema[kind];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function expandSpec(spec, schemas, refs) {
|
|
148
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
149
|
-
if (isRef(schema)) continue;
|
|
150
|
-
if (!isEmpty(schema.properties)) {
|
|
151
|
-
if (!isEmpty(schema.oneOf)) {
|
|
152
|
-
for (const oneOfIdx in schema.oneOf) {
|
|
153
|
-
const oneOf = schema.oneOf[oneOfIdx];
|
|
154
|
-
if (isRef(oneOf)) continue;
|
|
155
|
-
for (const key of ["properties", "x-properties"]) {
|
|
156
|
-
if (!isEmpty(oneOf.required) && schema[key]) {
|
|
157
|
-
schema.oneOf[oneOfIdx] = schema[key][oneOf.required[0]];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
delete schema.type;
|
|
162
|
-
expandSpec(spec, schemas, refs);
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (schema.additionalProperties) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
spec.components.schemas[name] = schema;
|
|
169
|
-
const properties = schema.properties;
|
|
170
|
-
for (const [propName, value] of Object.entries(properties)) {
|
|
171
|
-
if (isRef(value)) continue;
|
|
172
|
-
const fixedPropName = propName.replace("[]", "");
|
|
173
|
-
const refName = pascalcase(joinSkipDigits([name, fixedPropName], " "));
|
|
174
|
-
if (!isEmpty(value.properties)) {
|
|
175
|
-
spec.components.schemas[refName] = value;
|
|
176
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
177
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
178
|
-
} else if (!isEmpty(value.oneOf)) {
|
|
179
|
-
expandOneOf(spec, name, value, refs, "oneOf");
|
|
180
|
-
spec.components.schemas[refName] = value;
|
|
181
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
182
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
183
|
-
} else if (!isEmpty(value.anyOf)) {
|
|
184
|
-
expandOneOf(spec, name, value, refs, "anyOf");
|
|
185
|
-
spec.components.schemas[refName] = value;
|
|
186
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
187
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
188
|
-
} else {
|
|
189
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
if (!isEmpty(schema["x-properties"])) {
|
|
195
|
-
spec.components.schemas[name] = schema;
|
|
196
|
-
const properties = schema["x-properties"];
|
|
197
|
-
for (const [propName, value] of Object.entries(properties)) {
|
|
198
|
-
if (isRef(value)) continue;
|
|
199
|
-
const fixedPropName = propName.replace("[]", "");
|
|
200
|
-
const refName = pascalcase(joinSkipDigits([name, fixedPropName], " "));
|
|
201
|
-
if (!isEmpty(value.properties)) {
|
|
202
|
-
spec.components.schemas[refName] = value;
|
|
203
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
204
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
205
|
-
} else if (!isEmpty(value.oneOf)) {
|
|
206
|
-
expandOneOf(spec, name, value, refs, "oneOf");
|
|
207
|
-
spec.components.schemas[refName] = value;
|
|
208
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
209
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
210
|
-
} else if (!isEmpty(value.anyOf)) {
|
|
211
|
-
expandOneOf(spec, name, value, refs, "anyOf");
|
|
212
|
-
spec.components.schemas[refName] = value;
|
|
213
|
-
properties[propName] = { $ref: `#/components/schemas/${refName}` };
|
|
214
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
215
|
-
} else {
|
|
216
|
-
expandSpec(spec, { [refName]: value }, refs);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if (schema.type === "array") {
|
|
222
|
-
if (isRef(schema.items)) continue;
|
|
223
|
-
if (isEmpty(schema.items)) continue;
|
|
224
|
-
const refName = findUniqueSchemaName(spec, name, ["Item", "Entry"]);
|
|
225
|
-
if (schema.items.type === "object") {
|
|
226
|
-
spec.components.schemas[refName] = schema.items;
|
|
227
|
-
expandSpec(spec, { [refName]: schema.items }, refs);
|
|
228
|
-
schema.items = { $ref: `#/components/schemas/${refName}` };
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
if (schema.items.type === "array") {
|
|
232
|
-
expandSpec(spec, { [refName]: schema.items }, refs);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (!isEmpty(schema.items.oneOf)) {
|
|
236
|
-
expandOneOf(spec, refName, schema.items, refs, "oneOf");
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (!isEmpty(schema.items.anyOf)) {
|
|
240
|
-
expandOneOf(spec, refName, schema.items, refs, "anyOf");
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (!isEmpty(schema.oneOf)) {
|
|
245
|
-
expandOneOf(spec, name, schema, refs, "oneOf");
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
if (!isEmpty(schema.anyOf)) {
|
|
249
|
-
expandOneOf(spec, name, schema, refs, "anyOf");
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function expandOneOf(spec, name, schema, refs, kind) {
|
|
255
|
-
const varients = schema["x-varients"];
|
|
256
|
-
if (!varients || varients.length === 0) {
|
|
257
|
-
console.warn(
|
|
258
|
-
`No varients found for ${name}. This might be an error in the OpenAPI spec.`
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
varients.forEach((varient) => {
|
|
262
|
-
const varientSchema = schema[kind][varient.position];
|
|
263
|
-
if (isRef(varientSchema)) return;
|
|
264
|
-
const refName = findUniqueSchemaName(
|
|
265
|
-
spec,
|
|
266
|
-
pascalcase(`${name} ${varient.name}`),
|
|
267
|
-
["Varient"]
|
|
268
|
-
);
|
|
269
|
-
if (varientSchema.type === "object") {
|
|
270
|
-
expandSpec(spec, { [refName]: varientSchema }, refs);
|
|
271
|
-
schema[kind][varient.position] = {
|
|
272
|
-
$ref: `#/components/schemas/${refName}`
|
|
273
|
-
};
|
|
274
|
-
} else {
|
|
275
|
-
expandSpec(spec, { [refName]: varientSchema }, refs);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
function coerceTypes(schema, excludeNull = true) {
|
|
280
|
-
const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
|
|
281
|
-
if (excludeNull) {
|
|
282
|
-
return types.filter((type) => type !== "null");
|
|
283
|
-
}
|
|
284
|
-
return types;
|
|
285
|
-
}
|
|
286
|
-
export {
|
|
287
|
-
coerceTypes,
|
|
288
|
-
expandSpec,
|
|
289
|
-
fixSpec
|
|
290
|
-
};
|
|
291
|
-
//# sourceMappingURL=tune.js.map
|
package/dist/lib/tune.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/lib/tune.ts"],
|
|
4
|
-
"sourcesContent": ["import { merge, uniq } from 'lodash-es';\nimport assert from 'node:assert';\nimport type {\n ReferenceObject,\n SchemaObject,\n SchemaObjectType,\n} from 'openapi3-ts/oas31';\n\nimport {\n isEmpty,\n isRef,\n joinSkipDigits,\n notRef,\n pascalcase,\n resolveRef,\n snakecase,\n} from '@sdk-it/core';\n\nimport { type Varient, findVarients } from './find-polymorphic-varients.js';\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport { formatName } from './format-name.js';\nimport { isPrimitiveSchema } from './is-primitive-schema.js';\nimport type { IR } from './types.js';\n\nexport function fixSpec(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n visited = new Set<string>(),\n) {\n for (const schema of schemas) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n schema.type = 'object';\n delete schema.oneOf;\n delete schema.anyOf;\n fixSpec(spec, Object.values(schema.properties), visited);\n // path param are required and if it happens to have\n // body with defaults then zod would break off. so flat the defaults from object itself to properties\n for (const [key, value] of Object.entries(schema.properties)) {\n if (notRef(value) && isPrimitiveSchema(value)) {\n value.default ??= schema.default?.[key];\n delete schema.default?.[key];\n }\n }\n delete schema.default; // default should not be in properties\n }\n\n if (!isEmpty(schema['x-properties'])) {\n fixSpec(spec, Object.values(schema['x-properties']), visited);\n }\n\n if (!isEmpty(schema.items)) {\n delete schema.oneOf;\n delete schema.anyOf;\n schema.type = 'array';\n fixSpec(spec, [schema.items], visited);\n const items = resolveRef<SchemaObject>(spec, schema.items);\n if (Array.isArray(items.default)) {\n schema.default ??= structuredClone(items.default);\n }\n delete items.default; // default should not be in items\n }\n\n if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {\n delete schema.anyOf;\n }\n\n if (isEmpty(schema.enum)) {\n delete schema.enum;\n }\n\n if (!isEmpty(schema.enum)) {\n if (schema.enum.length === 1) {\n schema.const = schema.enum[0];\n delete schema.enum;\n } else {\n const valuesSet = new Set<string>();\n const valuesList = [];\n for (const it of schema.enum) {\n const formattedValue = formatName(snakecase(formatName(it)));\n if (!valuesSet.has(formattedValue)) {\n valuesSet.add(formattedValue);\n valuesList.push(it);\n }\n }\n schema.enum = valuesList;\n }\n delete schema.allOf;\n }\n\n if (schema.const !== undefined) {\n schema.default = schema.const;\n }\n\n if (!isEmpty(schema.allOf)) {\n const schemas = schema.allOf;\n // if (schemas.length === 1) {\n // fixSpec(spec, [schemas[0]], visited);\n // Object.assign(schema, schemas[0]);\n // delete schema.allOf;\n // } else {\n // }\n const resolved = schemas.map((it) => resolveRef<SchemaObject>(spec, it));\n const hasObjects = resolved.some((it) => it.type === 'object');\n const hasOtherTypes = resolved.some(\n (it) => it.type && it.type !== 'object',\n );\n if (hasObjects && hasOtherTypes) {\n assert(false, `allOf must be an object`);\n }\n merge(\n schema,\n ...resolved.map((it) => {\n fixSpec(spec, [it], visited);\n return it;\n }),\n );\n delete schema.allOf;\n } else {\n delete schema.allOf;\n }\n\n if (\n schema.type === 'object' &&\n isEmpty(schema.properties) &&\n typeof schema.additionalProperties === 'object' &&\n !isEmpty(schema.additionalProperties) &&\n notRef(schema.additionalProperties) &&\n !isEmpty(schema.additionalProperties.properties)\n ) {\n // additionalProperties is of type object and properties is empty\n fixSpec(\n spec,\n Object.values(schema.additionalProperties.properties),\n visited,\n );\n Object.assign(schema, schema.additionalProperties);\n delete schema.additionalProperties;\n }\n\n for (const kind of ['oneOf', 'anyOf'] as const) {\n if (!isEmpty(schema[kind])) {\n delete schema.type; // type is not allowed with oneOf or anyOf\n fixSpec(spec, schema[kind], visited);\n if (isEmpty(schema[kind])) {\n // fixSpec can remove oneOf or anyOf if it has no items so we need to check again\n // after fixing\n continue;\n }\n\n let enumSchemaIndex = -1;\n const enumValues: string[] = [];\n for (let idx = 0; idx < schema[kind].length; idx++) {\n const item = schema[kind][idx];\n // just handle non ref for now\n if (notRef(item) && item.type === 'string') {\n // if enum equal one it'd already have been converted to const so check for more than one\n if (item.enum && item.enum.length > 1) {\n // foundEnum = true;\n enumValues.push(...item.enum);\n if (enumSchemaIndex === -1) {\n enumSchemaIndex = idx;\n }\n }\n }\n }\n if (enumSchemaIndex !== -1) {\n const enumSchema = schema[kind][enumSchemaIndex];\n if (notRef(enumSchema)) {\n enumSchema.enum = uniq(enumValues);\n }\n // delete the other schemas that have enum\n schema[kind] = schema[kind].filter(\n (it, idx) => idx === enumSchemaIndex || isRef(it),\n );\n }\n const otherTypes = schema[kind].filter(\n (it) => resolveRef<SchemaObject>(spec, it).type !== 'null',\n );\n if (otherTypes.length === 1) {\n Object.assign(schema, otherTypes[0]);\n delete schema[kind];\n continue;\n }\n\n schema['x-varients'] = findVarients(spec, schema[kind]);\n } else {\n delete schema[kind];\n }\n }\n }\n}\n\ntype Refs = { name: string; value: SchemaObject }[];\n\nexport function expandSpec(\n spec: IR,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n refs: Refs,\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIdx in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIdx];\n if (isRef(oneOf)) continue;\n for (const key of ['properties', 'x-properties'] as const) {\n if (!isEmpty(oneOf.required) && schema[key]) {\n schema.oneOf[oneOfIdx] = schema[key][oneOf.required[0]];\n }\n }\n }\n delete schema.type;\n expandSpec(spec, schemas, refs);\n continue;\n }\n if (schema.additionalProperties) {\n continue;\n }\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n const properties = schema.properties as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n\n continue;\n }\n if (!isEmpty(schema['x-properties'])) {\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n\n const properties = schema['x-properties'] as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n continue;\n }\n\n if (schema.type === 'array') {\n if (isRef(schema.items)) continue;\n if (isEmpty(schema.items)) continue;\n const refName = findUniqueSchemaName(spec, name, ['Item', 'Entry']);\n if (schema.items.type === 'object') {\n // const refName = findUniqueSchemaName(spec, name, ['Object']);\n // refs.push({ name: refName, value: schema.items });\n spec.components.schemas[refName] = schema.items;\n expandSpec(spec, { [refName]: schema.items }, refs);\n schema.items = { $ref: `#/components/schemas/${refName}` };\n continue;\n }\n if (schema.items.type === 'array') {\n // for nested arrays, we need to move the last nested items only\n // so {type: 'array', items: { type: 'array', items: { type: 'object', properties: ... } }}\n // only object schema is moved while the array hirarchy is intact.\n expandSpec(spec, { [refName]: schema.items }, refs);\n continue;\n }\n if (!isEmpty(schema.items.oneOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.items.anyOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'anyOf');\n continue;\n }\n }\n if (!isEmpty(schema.oneOf)) {\n expandOneOf(spec, name, schema, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.anyOf)) {\n expandOneOf(spec, name, schema, refs, 'anyOf');\n continue;\n }\n }\n}\n\nfunction expandOneOf(\n spec: IR,\n name: string,\n schema: SchemaObject,\n refs: Refs,\n kind: 'oneOf' | 'anyOf',\n) {\n const varients = schema['x-varients'] as Varient[];\n if (!varients || varients.length === 0) {\n console.warn(\n `No varients found for ${name}. This might be an error in the OpenAPI spec.`,\n );\n }\n varients.forEach((varient) => {\n const varientSchema = schema[kind]![varient.position];\n if (isRef(varientSchema)) return;\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(`${name} ${varient.name}`),\n ['Varient'],\n );\n\n if (varientSchema.type === 'object') {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n schema[kind]![varient.position] = {\n $ref: `#/components/schemas/${refName}`,\n };\n } else {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n }\n\n // const referable = (['array', 'object'] as SchemaObjectType[]).some((type) =>\n // coerceTypes(varientSchema).includes(type),\n // );\n // if (!referable) {\n // return;\n // }\n });\n}\n\nexport function coerceTypes(\n schema: SchemaObject,\n excludeNull = true,\n): SchemaObjectType[] {\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n if (excludeNull) {\n return types.filter((type) => type !== 'null');\n }\n return types;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,OAAO,YAAY;AAC5B,OAAO,YAAY;AAOnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAuB,oBAAoB;AAC3C,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAG3B,SAAS,QACd,MACA,SACA,UAAU,oBAAI,IAAY,GAC1B;AACA,aAAW,UAAU,SAAS;AAC5B,QAAI,MAAM,MAAM,EAAG;AAEnB,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AAC/B,aAAO,OAAO;AACd,aAAO,OAAO;AACd,aAAO,OAAO;AACd,cAAQ,MAAM,OAAO,OAAO,OAAO,UAAU,GAAG,OAAO;AAGvD,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,UAAU,GAAG;AAC5D,YAAI,OAAO,KAAK,KAAK,kBAAkB,KAAK,GAAG;AAC7C,gBAAM,YAAY,OAAO,UAAU,GAAG;AACtC,iBAAO,OAAO,UAAU,GAAG;AAAA,QAC7B;AAAA,MACF;AACA,aAAO,OAAO;AAAA,IAChB;AAEA,QAAI,CAAC,QAAQ,OAAO,cAAc,CAAC,GAAG;AACpC,cAAQ,MAAM,OAAO,OAAO,OAAO,cAAc,CAAC,GAAG,OAAO;AAAA,IAC9D;AAEA,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO,OAAO;AACd,aAAO,OAAO;AACd,aAAO,OAAO;AACd,cAAQ,MAAM,CAAC,OAAO,KAAK,GAAG,OAAO;AACrC,YAAM,QAAQ,WAAyB,MAAM,OAAO,KAAK;AACzD,UAAI,MAAM,Q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