@kubb/oas
Advanced tools
Comparing version 0.0.0-canary-20240423195307 to 0.0.0-canary-20240423212734
import { O as Oas } from './Oas-BEe7KZDj.js'; | ||
import * as OasTypes from 'oas/types'; | ||
import { OASDocument } from 'oas/types'; | ||
import 'oas'; | ||
import 'oas/operation'; | ||
declare function parse(pathOrApi: string | OasTypes.OASDocument): Promise<Oas>; | ||
declare function parse(pathOrApi: string | OASDocument): Promise<Oas>; | ||
export { parse }; |
@@ -14,3 +14,8 @@ import { | ||
}); | ||
const document = await oasNormalize.load(); | ||
let document; | ||
try { | ||
document = await oasNormalize.bundle(); | ||
} catch (e) { | ||
document = await oasNormalize.load(); | ||
} | ||
if (isOpenApiV2Document(document)) { | ||
@@ -17,0 +22,0 @@ const { openapi: oas } = await swagger2openapi.convertObj(document, { anchors: true }); |
{ | ||
"name": "@kubb/oas", | ||
"version": "0.0.0-canary-20240423195307", | ||
"version": "0.0.0-canary-20240423212734", | ||
"description": "Oas helpers", | ||
@@ -51,2 +51,4 @@ "keywords": [ | ||
"dependencies": { | ||
"hotscript": "^1.0.13", | ||
"json-schema-to-ts": "^3.0.1", | ||
"oas": "^24.2.2", | ||
@@ -57,4 +59,2 @@ "oas-normalize": "^11.0.4", | ||
"swagger2openapi": "^7.0.8", | ||
"hotscript": "^1.0.13", | ||
"json-schema-to-ts": "^3.0.1", | ||
"ts-toolbelt": "^9.6.0" | ||
@@ -61,0 +61,0 @@ }, |
import OASNormalize from 'oas-normalize' | ||
import swagger2openapi from 'swagger2openapi' | ||
import type { OpenAPIV2 } from 'openapi-types' | ||
import { Oas } from '../Oas.ts' | ||
import type { OasTypes } from '../types.ts' | ||
import { isOpenApiV2Document } from '../utils.ts' | ||
export async function parse(pathOrApi: string | OasTypes.OASDocument): Promise<Oas> { | ||
import type { OASDocument } from 'oas/types' | ||
import type { OpenAPI } from 'openapi-types' | ||
export async function parse(pathOrApi: string | OASDocument): Promise<Oas> { | ||
const oasNormalize = new OASNormalize(pathOrApi, { | ||
@@ -14,4 +15,10 @@ enablePaths: true, | ||
}) | ||
let document: OpenAPI.Document | ||
const document = (await oasNormalize.load()) as unknown as OpenAPIV2.Document | ||
try { | ||
// resolve external refs | ||
document = await oasNormalize.bundle() | ||
} catch (e) { | ||
document = (await oasNormalize.load()) as OpenAPI.Document | ||
} | ||
@@ -21,3 +28,3 @@ if (isOpenApiV2Document(document)) { | ||
return new Oas({ oas: oas as OasTypes.OASDocument }) | ||
return new Oas({ oas: oas as OASDocument }) | ||
} | ||
@@ -24,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
113106
1597