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

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.52",
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.52",
51
+ "@kubb/core": "5.0.0-beta.52"
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'
package/src/resolvers.ts CHANGED
@@ -223,7 +223,7 @@ type SchemaSourceMode = 'schemas' | 'responses' | 'requestBodies'
223
223
  /**
224
224
  * A schema annotated with its component section source and original name. Used by `resolveNameCollisions` for cross-source collision resolution.
225
225
  */
226
- export type SchemaWithMetadata = {
226
+ type SchemaWithMetadata = {
227
227
  schema: SchemaObject
228
228
  source: SchemaSourceMode
229
229
  originalName: string
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // external packages
2
2
 
3
3
  import type { AdapterFactoryOptions } from '@kubb/core'
4
- import { ast } from '@kubb/core'
4
+ import type { ast } from '@kubb/core'
5
5
  import type { Operation as OASOperation } from 'oas/operation'
6
6
  import type {
7
7
  DiscriminatorObject as OASDiscriminatorObject,
@@ -12,11 +12,6 @@ import type {
12
12
  } from 'oas/types'
13
13
  import type { OpenAPIV3 } from 'openapi-types'
14
14
 
15
- /**
16
- * Re-exports of `openapi-types` for use by adapter consumers.
17
- */
18
- export type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'
19
-
20
15
  /**
21
16
  * Content-type string for selecting request/response schemas from an OpenAPI spec.
22
17
  * Supports `'application/json'` or any other media type.
@@ -73,20 +68,6 @@ export type SchemaObject = OASSchemaObject & {
73
68
  enum?: Array<string | number | boolean | null>
74
69
  }
75
70
 
76
- /**
77
- * Maps uppercase HTTP method names to lowercase for backwards compatibility.
78
- *
79
- * @example
80
- * ```ts
81
- * HttpMethods['GET'] // 'get'
82
- * HttpMethods['POST'] // 'post'
83
- * ```
84
- */
85
- export const HttpMethods = Object.fromEntries(Object.entries(ast.httpMethods).map(([lower, upper]) => [upper, lower])) as Record<
86
- Uppercase<ast.HttpMethod>,
87
- Lowercase<ast.HttpMethod>
88
- >
89
-
90
71
  /**
91
72
  * HTTP method as a lowercase string (`'get' | 'post' | ...`).
92
73
  */