@kubb/oas 3.2.0 → 3.3.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.
@@ -1,35 +0,0 @@
1
- import { bundle, loadConfig } from '@redocly/openapi-core'
2
- import OASNormalize from 'oas-normalize'
3
- import swagger2openapi from 'swagger2openapi'
4
-
5
- import { Oas } from '../Oas.ts'
6
- import { isOpenApiV2Document } from '../utils.ts'
7
-
8
- import type { OASDocument } from 'oas/types'
9
- import type { OpenAPI } from 'openapi-types'
10
-
11
- export async function parse(pathOrApi: string | OASDocument, oasClass: typeof Oas = Oas): Promise<Oas> {
12
- if (typeof pathOrApi === 'string') {
13
- // resolve external refs
14
- const config = await loadConfig()
15
- const bundleResults = await bundle({ ref: pathOrApi, config, base: pathOrApi })
16
-
17
- return parse(bundleResults.bundle.parsed)
18
- }
19
-
20
- const oasNormalize = new OASNormalize(pathOrApi, {
21
- enablePaths: true,
22
- colorizeErrors: true,
23
- })
24
- const document = (await oasNormalize.load()) as OpenAPI.Document
25
-
26
- if (isOpenApiV2Document(document)) {
27
- const { openapi } = await swagger2openapi.convertObj(document, {
28
- anchors: true,
29
- })
30
-
31
- return new oasClass({ oas: openapi as OASDocument })
32
- }
33
-
34
- return new oasClass({ oas: document })
35
- }