@kubb/oas 2.18.1 → 2.18.3
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/parser.cjs +7 -6
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.js +7 -6
- package/dist/parser.js.map +1 -1
- package/package.json +5 -4
- package/src/parser/index.ts +10 -8
package/dist/parser.cjs
CHANGED
|
@@ -7,17 +7,18 @@ var _chunkCERX23AMcjs = require('./chunk-CERX23AM.cjs');
|
|
|
7
7
|
// src/parser/index.ts
|
|
8
8
|
var _oasnormalize = require('oas-normalize'); var _oasnormalize2 = _interopRequireDefault(_oasnormalize);
|
|
9
9
|
var _swagger2openapi = require('swagger2openapi'); var _swagger2openapi2 = _interopRequireDefault(_swagger2openapi);
|
|
10
|
+
var _openapicore = require('@redocly/openapi-core');
|
|
10
11
|
async function parse(pathOrApi, options = {}) {
|
|
12
|
+
if (typeof pathOrApi === "string") {
|
|
13
|
+
const config = await _openapicore.loadConfig.call(void 0, );
|
|
14
|
+
const bundleResults = await _openapicore.bundle.call(void 0, { ref: pathOrApi, config, base: pathOrApi });
|
|
15
|
+
return parse(bundleResults.bundle.parsed, options);
|
|
16
|
+
}
|
|
11
17
|
const oasNormalize = new (0, _oasnormalize2.default)(pathOrApi, {
|
|
12
18
|
enablePaths: true,
|
|
13
19
|
colorizeErrors: true
|
|
14
20
|
});
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
document = await oasNormalize.bundle();
|
|
18
|
-
} catch (e) {
|
|
19
|
-
document = await oasNormalize.load();
|
|
20
|
-
}
|
|
21
|
+
const document = await oasNormalize.load();
|
|
21
22
|
if (_chunkCERX23AMcjs.isOpenApiV2Document.call(void 0, document)) {
|
|
22
23
|
const { openapi } = await _swagger2openapi2.default.convertObj(document, {
|
|
23
24
|
anchors: true
|
package/dist/parser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parser/index.ts"],"names":["oas"],"mappings":";;;;;;;AAAA,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;
|
|
1
|
+
{"version":3,"sources":["../src/parser/index.ts"],"names":["oas"],"mappings":";;;;;;;AAAA,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,SAAS,QAAQ,kBAAkB;AAkDnC,eAAsB,MAAM,WAAiC,UAAyB,CAAC,GAAiB;AACtG,MAAI,OAAO,cAAc,UAAU;AAEjC,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,gBAAgB,MAAM,OAAO,EAAE,KAAK,WAAW,QAAQ,MAAM,UAAU,CAAC;AAE9E,WAAO,MAAM,cAAc,OAAO,QAAQ,OAAO;AAAA,EACnD;AAEA,QAAM,eAAe,IAAI,aAAa,WAAW;AAAA,IAC/C,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB,CAAC;AACD,QAAM,WAAY,MAAM,aAAa,KAAK;AAE1C,MAAI,oBAAoB,QAAQ,GAAG;AACjC,UAAM,EAAE,QAAQ,IAAI,MAAM,gBAAgB,WAAW,UAAU;AAAA,MAC7D,SAAS;AAAA,IACX,CAAC;AAED,UAAMA,OAAM,MAAM,cAAc,SAAwB,OAAO;AAE/D,WAAO,IAAI,IAAI,EAAE,KAAKA,KAAmB,CAAC;AAAA,EAC5C;AAEA,QAAM,MAAM,MAAM,cAAc,UAAyB,OAAO;AAEhE,SAAO,IAAI,IAAI,EAAE,IAAI,CAAC;AACxB","sourcesContent":["import OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new Oas({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new Oas({ oas })\n}\n"]}
|
package/dist/parser.js
CHANGED
|
@@ -7,17 +7,18 @@ import {
|
|
|
7
7
|
// src/parser/index.ts
|
|
8
8
|
import OASNormalize from "oas-normalize";
|
|
9
9
|
import swagger2openapi from "swagger2openapi";
|
|
10
|
+
import { bundle, loadConfig } from "@redocly/openapi-core";
|
|
10
11
|
async function parse(pathOrApi, options = {}) {
|
|
12
|
+
if (typeof pathOrApi === "string") {
|
|
13
|
+
const config = await loadConfig();
|
|
14
|
+
const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi });
|
|
15
|
+
return parse(bundleResults.bundle.parsed, options);
|
|
16
|
+
}
|
|
11
17
|
const oasNormalize = new OASNormalize(pathOrApi, {
|
|
12
18
|
enablePaths: true,
|
|
13
19
|
colorizeErrors: true
|
|
14
20
|
});
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
document = await oasNormalize.bundle();
|
|
18
|
-
} catch (e) {
|
|
19
|
-
document = await oasNormalize.load();
|
|
20
|
-
}
|
|
21
|
+
const document = await oasNormalize.load();
|
|
21
22
|
if (isOpenApiV2Document(document)) {
|
|
22
23
|
const { openapi } = await swagger2openapi.convertObj(document, {
|
|
23
24
|
anchors: true
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parser/index.ts"],"sourcesContent":["import OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}): Promise<Oas> {\n
|
|
1
|
+
{"version":3,"sources":["../src/parser/index.ts"],"sourcesContent":["import OASNormalize from 'oas-normalize'\nimport swagger2openapi from 'swagger2openapi'\nimport { bundle, loadConfig } from '@redocly/openapi-core'\n\nimport { Oas } from '../Oas.ts'\nimport { filterAndSort, isOpenApiV2Document } from '../utils.ts'\n\nimport type { OASDocument } from 'oas/types'\nimport type { OpenAPI } from 'openapi-types'\n\nexport type FormatOptions = {\n verbose?: boolean\n 'no-sort'?: boolean\n sort?: boolean\n output?: string\n sortSet?: {\n root?: Array<'openapi' | 'info' | 'servers' | 'paths' | 'components' | 'tags' | 'x-tagGroups' | 'externalDocs'>\n get?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n post?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n put?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n patch?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n delete?: Array<'operationId' | 'summary' | 'description' | 'parameters' | 'requestBody' | 'responses'>\n parameters?: Array<'name' | 'in' | 'description' | 'required' | 'schema'>\n requestBody?: Array<'description' | 'required' | 'content'>\n responses?: Array<'description' | 'headers' | 'content' | 'links'>\n content?: Array<string>\n components?: Array<'parameters' | 'schemas'>\n schema?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n schemas?: Array<'description' | 'type' | 'items' | 'properties' | 'format' | 'example' | 'default'>\n properties?: Array<'description' | 'type' | 'items' | 'format' | 'example' | 'default' | 'enum'>\n }\n filterSet?: {\n methods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n inverseMethods?: Array<'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'trace' | 'head' | 'parameters'>\n tags?: Array<string>\n inverseTags?: Array<string>\n operationIds?: Array<string>\n inverseOperationIds?: Array<string>\n operations?: Array<string>\n flags?: Array<string>\n inverseFlags?: Array<string>\n flagValues?: Array<string>\n inverseFlagValues?: Array<string>\n stripFlags?: Array<string>\n responseContent?: Array<string>\n inverseResponseContent?: Array<string>\n unusedComponents?: Array<'requestBodies' | 'schemas' | 'parameters' | 'responses'>\n }\n sortComponentsSet?: {}\n casingSet?: {}\n}\n\nexport async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}): Promise<Oas> {\n if (typeof pathOrApi === 'string') {\n // resolve external refs\n const config = await loadConfig()\n const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })\n\n return parse(bundleResults.bundle.parsed, options)\n }\n\n const oasNormalize = new OASNormalize(pathOrApi, {\n enablePaths: true,\n colorizeErrors: true,\n })\n const document = (await oasNormalize.load()) as OpenAPI.Document\n\n if (isOpenApiV2Document(document)) {\n const { openapi } = await swagger2openapi.convertObj(document, {\n anchors: true,\n })\n\n const oas = await filterAndSort(openapi as OASDocument, options)\n\n return new Oas({ oas: oas as OASDocument })\n }\n\n const oas = await filterAndSort(document as OASDocument, options)\n\n return new Oas({ oas })\n}\n"],"mappings":";;;;;;;AAAA,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,SAAS,QAAQ,kBAAkB;AAkDnC,eAAsB,MAAM,WAAiC,UAAyB,CAAC,GAAiB;AACtG,MAAI,OAAO,cAAc,UAAU;AAEjC,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,gBAAgB,MAAM,OAAO,EAAE,KAAK,WAAW,QAAQ,MAAM,UAAU,CAAC;AAE9E,WAAO,MAAM,cAAc,OAAO,QAAQ,OAAO;AAAA,EACnD;AAEA,QAAM,eAAe,IAAI,aAAa,WAAW;AAAA,IAC/C,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB,CAAC;AACD,QAAM,WAAY,MAAM,aAAa,KAAK;AAE1C,MAAI,oBAAoB,QAAQ,GAAG;AACjC,UAAM,EAAE,QAAQ,IAAI,MAAM,gBAAgB,WAAW,UAAU;AAAA,MAC7D,SAAS;AAAA,IACX,CAAC;AAED,UAAMA,OAAM,MAAM,cAAc,SAAwB,OAAO;AAE/D,WAAO,IAAI,IAAI,EAAE,KAAKA,KAAmB,CAAC;AAAA,EAC5C;AAEA,QAAM,MAAM,MAAM,cAAc,UAAyB,OAAO;AAEhE,SAAO,IAAI,IAAI,EAAE,IAAI,CAAC;AACxB;","names":["oas"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/oas",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.3",
|
|
4
4
|
"description": "Oas helpers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"!/**/__tests__/**"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"@redocly/openapi-core": "^1.12.2",
|
|
51
52
|
"hotscript": "^1.0.13",
|
|
52
53
|
"json-schema-to-ts": "^3.1.0",
|
|
53
54
|
"oas": "^24.3.1",
|
|
@@ -64,9 +65,9 @@
|
|
|
64
65
|
"expect-type": "^0.19.0",
|
|
65
66
|
"tsup": "^8.0.2",
|
|
66
67
|
"typescript": "^5.4.5",
|
|
67
|
-
"@kubb/config-biome": "2.18.
|
|
68
|
-
"@kubb/config-ts": "2.18.
|
|
69
|
-
"@kubb/config-tsup": "2.18.
|
|
68
|
+
"@kubb/config-biome": "2.18.3",
|
|
69
|
+
"@kubb/config-ts": "2.18.3",
|
|
70
|
+
"@kubb/config-tsup": "2.18.3"
|
|
70
71
|
},
|
|
71
72
|
"engines": {
|
|
72
73
|
"node": ">=18",
|
package/src/parser/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import OASNormalize from 'oas-normalize'
|
|
2
2
|
import swagger2openapi from 'swagger2openapi'
|
|
3
|
+
import { bundle, loadConfig } from '@redocly/openapi-core'
|
|
3
4
|
|
|
4
5
|
import { Oas } from '../Oas.ts'
|
|
5
6
|
import { filterAndSort, isOpenApiV2Document } from '../utils.ts'
|
|
@@ -50,18 +51,19 @@ export type FormatOptions = {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export async function parse(pathOrApi: string | OASDocument, options: FormatOptions = {}): Promise<Oas> {
|
|
54
|
+
if (typeof pathOrApi === 'string') {
|
|
55
|
+
// resolve external refs
|
|
56
|
+
const config = await loadConfig()
|
|
57
|
+
const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })
|
|
58
|
+
|
|
59
|
+
return parse(bundleResults.bundle.parsed, options)
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
const oasNormalize = new OASNormalize(pathOrApi, {
|
|
54
63
|
enablePaths: true,
|
|
55
64
|
colorizeErrors: true,
|
|
56
65
|
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
// resolve external refs
|
|
61
|
-
document = await oasNormalize.bundle()
|
|
62
|
-
} catch (e) {
|
|
63
|
-
document = (await oasNormalize.load()) as OpenAPI.Document
|
|
64
|
-
}
|
|
66
|
+
const document = (await oasNormalize.load()) as OpenAPI.Document
|
|
65
67
|
|
|
66
68
|
if (isOpenApiV2Document(document)) {
|
|
67
69
|
const { openapi } = await swagger2openapi.convertObj(document, {
|