@kubb/adapter-oas 5.0.0-beta.4 → 5.0.0-beta.41
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/README.md +100 -0
- package/dist/index.cjs +900 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +52 -69
- package/dist/index.js +902 -310
- package/dist/index.js.map +1 -1
- package/extension.yaml +144 -57
- package/package.json +6 -4
- package/src/adapter.bench.ts +64 -0
- package/src/adapter.ts +143 -48
- package/src/constants.ts +8 -0
- package/src/dialect.ts +38 -0
- package/src/discriminator.ts +31 -47
- package/src/factory.ts +38 -12
- package/src/index.ts +2 -2
- package/src/parser.ts +233 -137
- package/src/refs.ts +31 -5
- package/src/resolvers.ts +77 -38
- package/src/schemaDiagnostics.ts +76 -0
- package/src/stream.ts +278 -0
- package/src/types.ts +34 -11
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/src/types.ts
CHANGED
|
@@ -123,8 +123,9 @@ export type ResponseObject = OASResponseObject
|
|
|
123
123
|
export type MediaTypeObject = OASMediaTypeObject
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* Configuration options for the OpenAPI adapter.
|
|
127
|
-
*
|
|
126
|
+
* Configuration options for the OpenAPI adapter. Controls spec validation,
|
|
127
|
+
* content-type selection, server URL resolution, and how types are derived
|
|
128
|
+
* from the spec.
|
|
128
129
|
*
|
|
129
130
|
* @example
|
|
130
131
|
* ```ts
|
|
@@ -138,23 +139,28 @@ export type MediaTypeObject = OASMediaTypeObject
|
|
|
138
139
|
*/
|
|
139
140
|
export type AdapterOasOptions = {
|
|
140
141
|
/**
|
|
141
|
-
* Validate the OpenAPI spec before parsing.
|
|
142
|
+
* Validate the OpenAPI spec with `@readme/openapi-parser` before parsing.
|
|
143
|
+
* Set to `false` only when you have a known-invalid spec you still want to
|
|
144
|
+
* generate from.
|
|
145
|
+
*
|
|
142
146
|
* @default true
|
|
143
147
|
*/
|
|
144
148
|
validate?: boolean
|
|
145
149
|
/**
|
|
146
|
-
* Preferred
|
|
147
|
-
*
|
|
150
|
+
* Preferred media type when an operation defines several. Defaults to the
|
|
151
|
+
* first JSON-compatible media type found in the spec.
|
|
148
152
|
*/
|
|
149
153
|
contentType?: ContentType
|
|
150
154
|
/**
|
|
151
|
-
* Index into `
|
|
152
|
-
*
|
|
155
|
+
* Index into the `servers` array from your OpenAPI spec. Used to compute the
|
|
156
|
+
* base URL for plugins that need it. Most projects pick `0` for the primary
|
|
157
|
+
* server. Omit to leave `baseURL` undefined.
|
|
153
158
|
*/
|
|
154
159
|
serverIndex?: number
|
|
155
160
|
/**
|
|
156
161
|
* Override values for `{variable}` placeholders in the selected server URL.
|
|
157
|
-
* Only used when `serverIndex` is set.
|
|
162
|
+
* Only used when `serverIndex` is set. Variables you do not provide use
|
|
163
|
+
* their `default` value from the spec.
|
|
158
164
|
*
|
|
159
165
|
* @example
|
|
160
166
|
* ```ts
|
|
@@ -165,12 +171,28 @@ export type AdapterOasOptions = {
|
|
|
165
171
|
*/
|
|
166
172
|
serverVariables?: Record<string, string>
|
|
167
173
|
/**
|
|
168
|
-
* How the discriminator field is interpreted.
|
|
169
|
-
* - `'strict'`
|
|
170
|
-
*
|
|
174
|
+
* How the `discriminator` field on `oneOf`/`anyOf` schemas is interpreted.
|
|
175
|
+
* - `'strict'` child schemas stay exactly as written. The discriminator
|
|
176
|
+
* narrows types at the call site but child shapes are not modified.
|
|
177
|
+
* - `'inherit'` Kubb propagates the discriminator property as a literal
|
|
178
|
+
* value into each child schema, so each branch's discriminator field is
|
|
179
|
+
* precisely typed.
|
|
180
|
+
*
|
|
171
181
|
* @default 'strict'
|
|
172
182
|
*/
|
|
173
183
|
discriminator?: 'strict' | 'inherit'
|
|
184
|
+
/**
|
|
185
|
+
* Collapse structurally identical schemas and enums into a single shared definition.
|
|
186
|
+
*
|
|
187
|
+
* Duplicated inline shapes (especially enums repeated across many properties) are hoisted
|
|
188
|
+
* into one named schema. Every other occurrence, and any structurally identical top-level
|
|
189
|
+
* component, becomes a `ref` to it. Equality is shape-only: documentation such as
|
|
190
|
+
* `description` and `example` is ignored. Enabled by default. Set to `false` to keep every
|
|
191
|
+
* occurrence inline and produce byte-for-byte identical output to earlier versions.
|
|
192
|
+
*
|
|
193
|
+
* @default true
|
|
194
|
+
*/
|
|
195
|
+
dedupe?: boolean
|
|
174
196
|
} & Partial<ast.ParserOptions>
|
|
175
197
|
|
|
176
198
|
/**
|
|
@@ -182,6 +204,7 @@ export type AdapterOasResolvedOptions = {
|
|
|
182
204
|
serverIndex: AdapterOasOptions['serverIndex']
|
|
183
205
|
serverVariables: AdapterOasOptions['serverVariables']
|
|
184
206
|
discriminator: NonNullable<AdapterOasOptions['discriminator']>
|
|
207
|
+
dedupe: NonNullable<AdapterOasOptions['dedupe']>
|
|
185
208
|
dateType: NonNullable<AdapterOasOptions['dateType']>
|
|
186
209
|
integerType: NonNullable<AdapterOasOptions['integerType']>
|
|
187
210
|
unknownType: NonNullable<AdapterOasOptions['unknownType']>
|
|
File without changes
|