@kubb/adapter-oas 5.0.0-beta.50 → 5.0.0-beta.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/adapter-oas",
3
- "version": "5.0.0-beta.50",
3
+ "version": "5.0.0-beta.51",
4
4
  "description": "OpenAPI and Swagger adapter for Kubb. Parses and validates OAS 2.0/3.x specifications into a @kubb/ast RootNode for downstream code generation plugins.",
5
5
  "keywords": [
6
6
  "adapter",
@@ -43,12 +43,12 @@
43
43
  "registry": "https://registry.npmjs.org/"
44
44
  },
45
45
  "dependencies": {
46
- "@redocly/openapi-core": "^2.31.6",
46
+ "@apidevtools/json-schema-ref-parser": "^14.2.1",
47
47
  "oas": "^32.1.18",
48
48
  "oas-normalize": "^16.0.5",
49
49
  "swagger2openapi": "^7.0.8",
50
- "@kubb/ast": "5.0.0-beta.50",
51
- "@kubb/core": "5.0.0-beta.50"
50
+ "@kubb/ast": "5.0.0-beta.51",
51
+ "@kubb/core": "5.0.0-beta.51"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/swagger2openapi": "^7.0.4",
package/src/factory.ts CHANGED
@@ -2,9 +2,7 @@ import path from 'node:path'
2
2
  import { exists, mergeDeep, URLPath } from '@internals/utils'
3
3
  import { Diagnostics } from '@kubb/core'
4
4
  import type { AdapterSource } from '@kubb/core'
5
- import { bundle, loadConfig } from '@redocly/openapi-core'
6
5
  import OASNormalize from 'oas-normalize'
7
- import swagger2openapi from 'swagger2openapi'
8
6
  import { MERGE_DEFAULT_TITLE, MERGE_DEFAULT_VERSION, MERGE_OPENAPI_VERSION } from './constants.ts'
9
7
  import { isOpenApiV2Document } from './guards.ts'
10
8
  import type { Document } from './types.ts'
@@ -22,8 +20,8 @@ export type ValidateDocumentOptions = {
22
20
  * Loads and dereferences an OpenAPI document, returning the raw `Document`.
23
21
  *
24
22
  * Accepts a file path string or an already-parsed document object. File paths are bundled via
25
- * Redocly to resolve external `$ref`s. Swagger 2.0 documents are automatically up-converted
26
- * to OpenAPI 3.0 via `swagger2openapi`.
23
+ * `@apidevtools/json-schema-ref-parser` to resolve external `$ref`s. Swagger 2.0 documents are
24
+ * automatically up-converted to OpenAPI 3.0 via `swagger2openapi`.
27
25
  *
28
26
  * @example
29
27
  * ```ts
@@ -33,17 +31,10 @@ export type ValidateDocumentOptions = {
33
31
  */
34
32
  export async function parseDocument(pathOrApi: string | Document, { canBundle = true, enablePaths = true }: ParseOptions = {}): Promise<Document> {
35
33
  if (typeof pathOrApi === 'string' && canBundle) {
36
- const config = await loadConfig()
37
- const bundleResults = await bundle({
38
- ref: pathOrApi,
39
- config,
40
- base: pathOrApi,
41
- })
34
+ const { $RefParser } = await import('@apidevtools/json-schema-ref-parser')
35
+ const bundled = await $RefParser.bundle(pathOrApi)
42
36
 
43
- return parseDocument(bundleResults.bundle.parsed as string, {
44
- canBundle,
45
- enablePaths,
46
- })
37
+ return parseDocument(bundled as Document, { canBundle: false, enablePaths })
47
38
  }
48
39
 
49
40
  const oasNormalize = new OASNormalize(pathOrApi, {
@@ -53,6 +44,7 @@ export async function parseDocument(pathOrApi: string | Document, { canBundle =
53
44
  const document = (await oasNormalize.load()) as Document
54
45
 
55
46
  if (isOpenApiV2Document(document)) {
47
+ const { default: swagger2openapi } = await import('swagger2openapi')
56
48
  const { openapi } = await swagger2openapi.convertObj(document, {
57
49
  anchors: true,
58
50
  })
package/src/index.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  export { adapterOas, adapterOasName } from './adapter.ts'
2
- export type { ValidateDocumentOptions } from './factory.ts'
3
- export { mergeDocuments } from './factory.ts'
4
2
  export type {
5
3
  AdapterOas,
6
4
  AdapterOasOptions,
@@ -15,4 +13,3 @@ export type {
15
13
  ResponseObject,
16
14
  SchemaObject,
17
15
  } from './types.ts'
18
- export { HttpMethods } from './types.ts'