@kubb/adapter-oas 5.0.0-beta.31 → 5.0.0-beta.32

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.31",
3
+ "version": "5.0.0-beta.32",
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",
@@ -47,7 +47,7 @@
47
47
  "oas": "^32.1.18",
48
48
  "oas-normalize": "^16.0.4",
49
49
  "swagger2openapi": "^7.0.8",
50
- "@kubb/core": "5.0.0-beta.31"
50
+ "@kubb/core": "5.0.0-beta.32"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/swagger2openapi": "^7.0.4",
@@ -10,9 +10,8 @@ export type DiscriminatorTarget = {
10
10
  * Builds a map of child schema names → discriminator patch data by scanning the given
11
11
  * top-level AST schema nodes for union schemas that carry a `discriminatorPropertyName`.
12
12
  *
13
- * Extracted from `applyDiscriminatorInheritance` so the streaming path can call it on a
14
- * small pre-parsed subset of schemas (only the discriminator parents) rather than on all
15
- * schemas at once.
13
+ * The streaming path calls this on a small pre-parsed subset of schemas (only the
14
+ * discriminator parents) rather than on all schemas at once.
16
15
  */
17
16
  export function buildDiscriminatorChildMap(schemas: Array<ast.SchemaNode>): Map<string, DiscriminatorTarget> {
18
17
  const childMap = new Map<string, DiscriminatorTarget>()
@@ -91,35 +90,3 @@ export function patchDiscriminatorNode(node: ast.SchemaNode, entry: { propertyNa
91
90
 
92
91
  return { ...objectNode, properties: newProperties }
93
92
  }
94
-
95
- /**
96
- * Injects discriminator enum values into child schemas so they know which value identifies them.
97
- *
98
- * Finds every union schema in `input.schemas` that has a `discriminatorPropertyName`, collects the
99
- * enum value each union member is mapped to, then adds (or replaces) that property on the matching
100
- * child object schema.
101
- *
102
- * Returns a new `InputNode` — the original is never mutated.
103
- *
104
- * @example
105
- * ```ts
106
- * const { root } = parseOas(document, options)
107
- * const next = applyDiscriminatorInheritance(root)
108
- * ```
109
- */
110
- export function applyDiscriminatorInheritance(root: ast.InputNode): ast.InputNode {
111
- const childMap = buildDiscriminatorChildMap(root.schemas)
112
-
113
- if (childMap.size === 0) return root
114
-
115
- return ast.transform(root, {
116
- schema(node, { parent }) {
117
- if (parent?.kind !== 'Input' || !node.name) return
118
-
119
- const entry = childMap.get(node.name)
120
- if (!entry) return
121
-
122
- return patchDiscriminatorNode(node, entry)
123
- },
124
- })
125
- }
package/src/resolvers.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { pascalCase } from '@internals/utils'
2
- import { ast } from '@kubb/core'
2
+ import type { ast } from '@kubb/core'
3
3
  import type { ParameterObject, ServerObject } from 'oas/types'
4
4
  import { isRef } from 'oas/types'
5
5
  import { matchesMimeType } from 'oas/utils'
@@ -63,13 +63,6 @@ export function getPrimitiveType(type: string | undefined): ast.PrimitiveSchemaT
63
63
  return 'string'
64
64
  }
65
65
 
66
- /**
67
- * Narrows a content-type string to the `MediaType` union Kubb recognizes, or returns `null`.
68
- */
69
- export function getMediaType(contentType: string): ast.MediaType | null {
70
- return Object.values(ast.mediaTypes).includes(contentType as ast.MediaType) ? (contentType as ast.MediaType) : null
71
- }
72
-
73
66
  export type OperationsOptions = {
74
67
  contentType?: ContentType
75
68
  }
File without changes