@kubb/adapter-oas 5.20.1 → 5.20.2

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/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var compatibility = {
21
21
  "node": ">=22.22"
22
22
  };
23
23
  // package.json
24
- var version = "5.20.1";
24
+ var version = "5.20.2";
25
25
  // src/constants.ts
26
26
  /**
27
27
  * Default parser options applied when no explicit options are provided.
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var compatibility = {
14
14
  "node": ">=22.22"
15
15
  };
16
16
  // package.json
17
- var version = "5.20.1";
17
+ var version = "5.20.2";
18
18
  // src/constants.ts
19
19
  /**
20
20
  * Default parser options applied when no explicit options are provided.
package/docs/options.md CHANGED
@@ -4,25 +4,30 @@ Pass these options to `adapterOas()`. All of them are optional.
4
4
 
5
5
  ## Options overview
6
6
 
7
- | Option | Purpose |
8
- | --------------------------------------- | ------------------------------------------------------------ |
9
- | [`validate`](#validate) | Validate the spec before parsing. |
10
- | [`contentType`](#contenttype) | Preferred media type for request and response schemas. |
11
- | [`server`](#server) | Which spec server Kubb resolves into the document `baseURL`. |
12
- | [`discriminator`](#discriminator) | How `discriminator` fields are interpreted. |
13
- | [`enums`](#enums) | Where inline enums live. |
14
- | [`pathParamsCasing`](#pathparamscasing) | Rename path parameters to camelCase. |
15
- | [`dateType`](#datetype) | How `date-time`, `date`, and `time` schemas are represented. |
16
- | [`integerType`](#integertype) | How `int64` and `uint64` integers map to TypeScript. |
17
- | [`unknownType`](#unknowntype) | Type for open map values and parameters without a schema. |
18
- | [`emptySchemaType`](#emptyschematype) | Type for schemas with no type to infer. |
19
- | [`enumSuffix`](#enumsuffix) | Suffix for derived enum names. |
7
+ | Option | Purpose | Default |
8
+ | --------------------------------------- | ------------------------------------ | --------------------- |
9
+ | **Reading the spec** | | |
10
+ | [`validate`](#validate) | Validate the spec. | `true` |
11
+ | [`contentType`](#contenttype) | Media type to keep. | Every media type |
12
+ | [`server`](#server) | Server that sets `baseURL`. | None |
13
+ | **Schema shape** | | |
14
+ | [`discriminator`](#discriminator) | How discriminators apply. | `'preserve'` |
15
+ | [`enums`](#enums) | Where inline enums live. | `'inline'` |
16
+ | [`enumSuffix`](#enumsuffix) | Suffix of enum names. | `'enum'` |
17
+ | [`pathParamsCasing`](#pathparamscasing) | Rename path parameters to camelCase. | None |
18
+ | **Type mapping** | | |
19
+ | [`dateType`](#datetype) | Type of date and time fields. | `'string'` |
20
+ | [`integerType`](#integertype) | Type of `int64` and `uint64` fields. | `'bigint'` |
21
+ | [`unknownType`](#unknowntype) | Type of open values. | `'unknown'` |
22
+ | [`emptySchemaType`](#emptyschematype) | Type of empty schemas. | Same as `unknownType` |
20
23
 
21
24
  ## Option details
22
25
 
23
- ### validate
26
+ ### Reading the spec
24
27
 
25
- Validates the OpenAPI spec with `@readme/openapi-parser` before parsing. Each problem is reported as a [`KUBB_INVALID_SPEC`](https://kubb.dev/docs/5.x/reference/diagnostics#kubb-invalid-spec) warning, and generation continues. Set it to `false` to skip the check, which makes generation faster on a large spec. Run [`kubb validate`](https://kubb.dev/docs/5.x/reference/commands/validate) to list every error. An OpenAPI 3.2 document is not validated yet, because `@readme/openapi-parser` does not support 3.2. Kubb reports one warning that says so.
28
+ #### validate
29
+
30
+ Reports each spec problem as a [`KUBB_INVALID_SPEC`](https://kubb.dev/docs/5.x/reference/diagnostics#kubb-invalid-spec) warning, and generation continues. Set it to `false` to speed up a large spec. [`kubb validate`](https://kubb.dev/docs/5.x/reference/commands/validate) lists every error.
26
31
 
27
32
  | | |
28
33
  | -------- | --------- |
@@ -30,31 +35,46 @@ Validates the OpenAPI spec with `@readme/openapi-parser` before parsing. Each pr
30
35
  | Required | `false` |
31
36
  | Default | `true` |
32
37
 
33
- ### contentType
38
+ > [!NOTE]
39
+ > OpenAPI 3.2 documents are not validated yet, and get one warning that says so.
40
+
41
+ #### contentType
34
42
 
35
- Media type to keep when an operation declares several, for both request bodies and responses. Without a value, Kubb keeps every media type the operation declares.
43
+ Media type to keep for request bodies and responses, also when an operation declares only one. A request body in another media type is dropped. A response in another media type gets [`emptySchemaType`](#emptyschematype).
36
44
 
37
45
  | | |
38
46
  | -------- | ------------------------------ |
39
47
  | Type | `'application/json' \| string` |
40
48
  | Required | `false` |
49
+ | Default | Every media type |
41
50
 
42
- ### server
51
+ #### server
43
52
 
44
- Selects which entry in the spec's `servers` array Kubb resolves into the document `baseURL`, filling in any `{variable}` placeholders. `server.index` points at one of the spec's servers, usually `0` for the primary one. `server.variables` supplies placeholder values, falling back to each variable's `default` from the spec. When `server` or `server.index` is omitted, `baseURL` resolves to `null`.
53
+ Picks the `servers` entry that becomes the document `baseURL`, and fills in its `{variable}` placeholders.
45
54
 
46
55
  | | |
47
56
  | -------- | -------------------------------------------------------- |
48
57
  | Type | `{ index?: number, variables?: Record<string, string> }` |
49
58
  | Required | `false` |
59
+ | Default | None, so `baseURL` is `null` |
50
60
 
51
- The resolved `baseURL` reaches banner functions through `BannerMeta.baseURL` but does not set request URLs on its own. To change where a generated client sends requests, use that plugin's own `baseURL` option ([`@kubb/plugin-fetch`](https://kubb.dev/extensions/kubb-labs/plugin-fetch), [`@kubb/plugin-axios`](https://kubb.dev/extensions/kubb-labs/plugin-axios), [`@kubb/plugin-msw`](https://kubb.dev/extensions/kubb-labs/plugin-msw)).
61
+ - `index`: position in the `servers` array, usually `0`.
62
+ - `variables`: placeholder values. A variable you leave out uses its spec `default`.
63
+
64
+ ```typescript
65
+ // spec server: https://api.{env}.example.com
66
+ adapterOas({ server: { index: 0, variables: { env: 'prod' } } })
67
+ // baseURL: https://api.prod.example.com
68
+ ```
52
69
 
53
- With a spec server of `https://api.{env}.example.com`, `server: { index: 0, variables: { env: 'prod' } }` resolves `baseURL` to `https://api.prod.example.com`.
70
+ > [!WARNING]
71
+ > Banners read this `baseURL` as `BannerMeta.baseURL`, but it does not set request URLs. For those, set `baseURL` on `@kubb/plugin-fetch`, `@kubb/plugin-axios`, or `@kubb/plugin-msw`.
54
72
 
55
- ### discriminator
73
+ ### Schema shape
56
74
 
57
- How `discriminator` fields on `oneOf`/`anyOf` schemas are interpreted.
75
+ #### discriminator
76
+
77
+ How `discriminator` fields on `oneOf` and `anyOf` schemas apply.
58
78
 
59
79
  | | |
60
80
  | -------- | --------------------------- |
@@ -65,83 +85,18 @@ How `discriminator` fields on `oneOf`/`anyOf` schemas are interpreted.
65
85
  ::field-group
66
86
 
67
87
  :::field{name="'preserve'"}
68
- Keeps child schemas exactly as written. The parent union still narrows each branch by its discriminator value.
88
+ Keeps child schemas as written. The parent union still narrows each branch.
69
89
  :::
70
90
 
71
91
  :::field{name="'propagate'"}
72
- Also writes the discriminator property with its literal value into each child schema, so `Cat` and `Dog` are narrowed when used on their own.
92
+ Also writes the discriminator literal into each child schema, so a child is narrowed on its own too.
73
93
  :::
74
94
 
75
95
  ::
76
96
 
77
- ::code-group
78
-
79
- ```yaml [OpenAPI spec]
80
- openapi: 3.0.3
81
- components:
82
- schemas:
83
- Animal:
84
- oneOf:
85
- - $ref: '#/components/schemas/Cat'
86
- - $ref: '#/components/schemas/Dog'
87
- discriminator:
88
- propertyName: type
89
- mapping:
90
- cat: '#/components/schemas/Cat'
91
- dog: '#/components/schemas/Dog'
92
- Cat:
93
- type: object
94
- properties:
95
- type: { type: string }
96
- indoor: { type: boolean }
97
- Dog:
98
- type: object
99
- properties:
100
- type: { type: string }
101
- name: { type: string }
102
- ```
103
-
104
- ```typescript ['preserve' (default)]
105
- export type Cat = {
106
- type?: string;
107
- indoor?: boolean;
108
- };
97
+ #### enums
109
98
 
110
- export type Dog = {
111
- type?: string;
112
- name?: string;
113
- };
114
-
115
- export type Animal = Cat & {
116
- type: 'cat';
117
- } | Dog & {
118
- type: 'dog';
119
- };
120
- ```
121
-
122
- ```typescript ['propagate']
123
- export type Cat = {
124
- type: 'cat';
125
- indoor?: boolean;
126
- };
127
-
128
- export type Dog = {
129
- type: 'dog';
130
- name?: string;
131
- };
132
-
133
- export type Animal = Cat & {
134
- type: 'cat';
135
- } | Dog & {
136
- type: 'dog';
137
- };
138
- ```
139
-
140
- ::
141
-
142
- ### enums
143
-
144
- Where inline enums live.
99
+ Where inline enums live. Names are the same in both modes.
145
100
 
146
101
  | | |
147
102
  | -------- | -------------------- |
@@ -156,12 +111,12 @@ Keeps each enum on the property that declares it.
156
111
  :::
157
112
 
158
113
  :::field{name="'root'"}
159
- Lifts every inline enum to a top-level schema named after its context (for example `PetStatusEnum`) and references it wherever it appears.
114
+ Lifts every inline enum to a referenced top-level schema, such as `PetStatusEnum`. A plugin that writes one file per schema gives it its own file.
160
115
  :::
161
116
 
162
117
  ::
163
118
 
164
- The names are the same in both modes. With `'root'`, the enum is a schema of its own, so a plugin that writes one file per schema gives it its own file. For an enum with values `active` and `inactive` on `Pet.status`, `@kubb/plugin-ts` writes:
119
+ For a `Pet.status` enum, `@kubb/plugin-ts` writes:
165
120
 
166
121
  ::code-group
167
122
 
@@ -198,9 +153,19 @@ export type Pet = {
198
153
 
199
154
  ::
200
155
 
201
- ### pathParamsCasing
156
+ #### enumSuffix
202
157
 
203
- Renames `path` parameters and their `{placeholder}` in the operation path. Omit it to keep the names from the spec.
158
+ Suffix of inline enum names. The `status` enum on `Pet` becomes `PetStatusEnum`, or `PetStatusType` with `enumSuffix: 'type'`.
159
+
160
+ | | |
161
+ | -------- | -------- |
162
+ | Type | `string` |
163
+ | Required | `false` |
164
+ | Default | `'enum'` |
165
+
166
+ #### pathParamsCasing
167
+
168
+ Renames `path` parameters and their `{placeholder}` to camelCase, so `{pet-id}`, `{pet_id}`, and `{PetId}` become `petId` in clients, MSW routes, and query keys. The HTTP request and other parameters stay the same.
204
169
 
205
170
  | | |
206
171
  | -------- | ------------- |
@@ -208,8 +173,6 @@ Renames `path` parameters and their `{placeholder}` in the operation path. Omit
208
173
  | Required | `false` |
209
174
  | Default | `undefined` |
210
175
 
211
- With `'camelcase'`, `{pet-id}`, `{pet_id}`, and `{PetId}` all become `petId`, and MSW routes and query keys use the same name. Names that collide get a counter suffix, so `{group-id}` and `{group.id}` become `groupId` and `groupId2`. Path parameter names never reach the wire, so the HTTP request stays the same. The one exception is the `matrix` style, which sends the name (`;group-id=42`), so an operation with a matrix path parameter keeps its spec names. Query, header, cookie, and body names are not changed.
212
-
213
176
  For `GET /stores/{store-id}/pets/{pet-id}`, `@kubb/plugin-client` generates:
214
177
 
215
178
  ::code-group
@@ -224,9 +187,13 @@ await getPet({ path: { storeId, petId } })
224
187
 
225
188
  ::
226
189
 
227
- ### dateType
190
+ An operation with a `matrix` path parameter keeps all its path parameter names, because a matrix value sends the name.
228
191
 
229
- How `date-time`, `date`, and `time` schemas are represented downstream.
192
+ ### Type mapping
193
+
194
+ #### dateType
195
+
196
+ How `date-time`, `date`, and `time` schemas are typed. One value sets all three.
230
197
 
231
198
  | | |
232
199
  | -------- | ----------------------------------------------------------------------------------------------- |
@@ -234,49 +201,35 @@ How `date-time`, `date`, and `time` schemas are represented downstream.
234
201
  | Required | `false` |
235
202
  | Default | `'string'` |
236
203
 
237
- Pass a single value to apply it to all three formats:
238
-
239
204
  ::field-group
240
205
 
241
- :::field{name="false"}
242
- Represents date and time values as plain strings without format validation.
206
+ :::field{name="'string'"}
207
+ Types all three as ISO 8601 strings.
243
208
  :::
244
209
 
245
- :::field{name="'string'"}
246
- Represents `date-time`, `date`, and `time` as ISO 8601 strings. The generated TypeScript type is `string`.
210
+ :::field{name="false"}
211
+ Types all three as plain strings, with no format check.
247
212
  :::
248
213
 
249
214
  :::field{name="'stringOffset'"}
250
- Represents `date-time` as a string with a timezone offset. The `date` and `time` formats fall back to `'string'`.
215
+ Like `'string'`, with a timezone offset on `date-time`.
251
216
  :::
252
217
 
253
218
  :::field{name="'stringLocal'"}
254
- Represents `date-time` as a local string without a timezone. The `date` and `time` formats fall back to `'string'`.
219
+ Like `'string'`, with no timezone on `date-time`.
255
220
  :::
256
221
 
257
222
  :::field{name="'date'"}
258
- Represents date and time values as JavaScript `Date` objects. JSON values need parsing to revive them as `Date` objects.
223
+ Types all three as a JavaScript `Date`, which needs parsing to revive from JSON.
259
224
  :::
260
225
 
261
226
  ::
262
227
 
263
- The string variants all emit `string` at the TypeScript type level. Schema plugins such as `@kubb/plugin-zod` validate the offset or local format.
264
-
265
- Pass an object to set `dateTime`, `date`, and `time` independently. A key that is left out defaults to `'string'`, regardless of the other keys.
266
-
267
- ```ts
268
- adapterOas({
269
- dateType: {
270
- dateTime: 'date', // Date object for timestamps
271
- date: 'string',
272
- time: 'string',
273
- },
274
- })
275
- ```
228
+ To type each format on its own, pass an object. `dateTime` takes every value above, `date` and `time` take `false`, `'string'`, or `'date'`, and a key you leave out is `'string'`.
276
229
 
277
- ### integerType
230
+ #### integerType
278
231
 
279
- How a schema with `format: int64` or `format: uint64` maps to TypeScript. Other integers, such as `type: integer` without a format or with `format: int32`, always map to `number`.
232
+ How `format: int64` and `format: uint64` integers are typed. Other integers are always `number`.
280
233
 
281
234
  | | |
282
235
  | -------- | ---------------------- |
@@ -287,20 +240,18 @@ How a schema with `format: int64` or `format: uint64` maps to TypeScript. Other
287
240
  ::field-group
288
241
 
289
242
  :::field{name="'bigint'"}
290
- Represents 64-bit IDs exactly, but `JSON.stringify` and `JSON.parse` cannot round-trip it. Use it only when the application handles bigint serialization itself.
243
+ Keeps 64-bit IDs exact. `JSON.stringify` and `JSON.parse` cannot round-trip a bigint, so use it only when the app handles bigint serialization.
291
244
  :::
292
245
 
293
246
  :::field{name="'number'"}
294
- Fits most JSON APIs. It loses precision above `Number.MAX_SAFE_INTEGER`.
247
+ Fits most JSON APIs. Loses precision above `Number.MAX_SAFE_INTEGER`.
295
248
  :::
296
249
 
297
250
  ::
298
251
 
299
- A schema with `type: string` stays a `string` whatever its `format`, so the [ProtoJSON](https://protobuf.dev/programming-guides/json/#int64-strings) `int64` strings that gRPC-gateway emits stay strings. `@kubb/plugin-zod` validates them with a digits regex, and `@kubb/plugin-faker` mocks them as numeric strings.
252
+ #### unknownType
300
253
 
301
- ### unknownType
302
-
303
- AST type used where the spec allows any value but gives no schema for it: the values of `additionalProperties: {}`, a `patternProperties` entry set to `true` or `{}`, the extra items of an open `prefixItems` tuple, and a parameter without a `schema`. `additionalProperties: true` is not affected, and `@kubb/plugin-ts` always types its values as `unknown`.
254
+ Type of a value the spec leaves open, such as the values of `additionalProperties: {}` or a parameter without a `schema`.
304
255
 
305
256
  | | |
306
257
  | -------- | ------------------------------ |
@@ -311,38 +262,28 @@ AST type used where the spec allows any value but gives no schema for it: the va
311
262
  ::field-group
312
263
 
313
264
  :::field{name="'unknown'"}
314
- Requires callers to narrow the value before using it.
265
+ Callers must narrow the value before they use it.
315
266
  :::
316
267
 
317
268
  :::field{name="'any'"}
318
- Allows callers to use the value without type checking.
269
+ Callers can use the value without type checks.
319
270
  :::
320
271
 
321
272
  :::field{name="'void'"}
322
- Represents a value callers should not use. Choose it when matching a legacy API that uses `void`.
273
+ Marks a value callers should not use, to match a legacy API.
323
274
  :::
324
275
 
325
276
  ::
326
277
 
327
- ### emptySchemaType
278
+ #### emptySchemaType
328
279
 
329
- AST type used for a schema with nothing to infer a type from: an empty schema (`{}`), a schema without a `type` such as one that holds only a `description`, and a response without a schema. `emptySchemaType` takes the same values as [`unknownType`](#unknowntype) and follows it when unset.
280
+ Type of a schema with nothing to infer a type from, such as `{}` or a response without a schema. It takes the [`unknownType`](#unknowntype) values.
330
281
 
331
- | | |
332
- | -------- | -------------------------------------- |
333
- | Type | `'any' \| 'unknown' \| 'void'` |
334
- | Required | `false` |
335
- | Default | `unknownType` (`'unknown'` by default) |
282
+ | | |
283
+ | -------- | ---------------------------------------- |
284
+ | Type | `'any' \| 'unknown' \| 'void'` |
285
+ | Required | `false` |
286
+ | Default | `unknownType`, so `'unknown'` by default |
336
287
 
337
288
  > [!TIP]
338
- > A common pairing sets `unknownType: 'unknown'` for safety and `emptySchemaType: 'any'` so empty 204 response bodies stay easy to use.
339
-
340
- ### enumSuffix
341
-
342
- Suffix for the names Kubb gives inline enums: schema name, property name, and suffix, in PascalCase. The `status` enum on `Pet` becomes `PetStatusEnum`, or `PetStatusType` with `enumSuffix: 'type'`. Plugins derive their own names from it, such as `petStatusEnum` and `PetStatusEnumKey` in `@kubb/plugin-ts`.
343
-
344
- | | |
345
- | -------- | -------- |
346
- | Type | `string` |
347
- | Required | `false` |
348
- | Default | `'enum'` |
289
+ > Pair `unknownType: 'unknown'` with `emptySchemaType: 'any'` to keep empty 204 bodies easy to use.
package/docs/overview.md CHANGED
@@ -1,29 +1,35 @@
1
1
  # OpenAPI
2
2
 
3
- The OpenAPI adapter is the first step of every build. It converts your spec into Kubb's AST, and every plugin generates code from that AST, so the adapter's options apply to all of them.
3
+ The OpenAPI adapter reads an OpenAPI 2.0, 3.0, 3.1, or 3.2 spec and converts it into the AST that every plugin generates code from.
4
4
 
5
- The adapter downloads a remote `input` URL and any remote `$ref`s with a plain GET request, without credentials. It also reads the local files that external `$ref`s point to, even outside the spec's folder, and never writes files.
5
+ - It is the first step of every build, so its options apply to all plugins.
6
+ - It downloads a remote `input` URL and any remote `$ref` with a plain GET request, without credentials.
7
+ - It reads the local files that external `$ref`s point to, even outside the spec's folder, unless the host limits them, as a Kubb Studio agent does. See [External refs](https://kubb.dev/docs/5.x/reference/configuration#external-refs). It never writes files.
6
8
 
7
9
  ## Setup
8
10
 
9
- Kubb uses `adapterOas()` by default, so no setup is needed. Set `adapter` in `defineConfig` only to change its options.
11
+ No setup is needed. `defineConfig` uses `adapterOas()` by default. Set `adapter` only to change its options.
10
12
 
11
13
  ## Options worth knowing
12
14
 
13
- - `validate` checks the spec before parsing and reports each problem as a warning. Turn it off to speed up a large spec. Run `kubb validate` to list every error.
14
- - `dateType` sets how `date-time`, `date`, and `time` schemas are typed. Choose ISO strings (the default), `date-time` strings with or without a timezone offset, or JavaScript `Date` objects. Pass an object to set each format on its own.
15
- - `integerType` sets how `int64` and `uint64` schemas are typed. The default `'bigint'` is exact for 64-bit IDs but does not survive `JSON.stringify`. Choose `'number'` for most JSON APIs.
16
- - `unknownType` sets the type for open map values and parameters without a schema. `emptySchemaType` sets the type for empty schemas (`{}`) and schemas without a `type`.
17
- - `discriminator: 'propagate'` writes the discriminator's literal value into each child schema, so a child is narrowed when used on its own.
18
- - `enums: 'root'` lifts inline enums to top-level schemas, named with `enumSuffix` (`PetStatusEnum`).
19
- - `server` picks the entry in the spec's `servers` array that becomes the base URL and fills in its variables. It does not change where a generated client sends requests. Use the client plugin's own `baseURL` for that.
20
- - `contentType` picks one media type when an operation declares several. Without it, Kubb keeps every media type the operation declares.
15
+ | Option | Default | What it does |
16
+ | ------------------------------------------------------------------------------------------------ | ---------------- | ---------------------------------------------------------------------------------------------------------------- |
17
+ | [`validate`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#validate) | `true` | Checks the spec and reports each problem as a warning. Turn it off to speed up a large spec. |
18
+ | [`dateType`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#datetype) | `'string'` | Types `date-time`, `date`, and `time` as strings or as `Date` objects. |
19
+ | [`integerType`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#integertype) | `'bigint'` | Types `int64` and `uint64` as `bigint` or `number`. Choose `'number'` for most JSON APIs. |
20
+ | [`enums`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#enums) | `'inline'` | `'root'` lifts inline enums to top-level schemas, such as `PetStatusEnum`. |
21
+ | [`discriminator`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#discriminator) | `'preserve'` | `'propagate'` writes the discriminator value into each child schema. |
22
+ | [`pathParamsCasing`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#pathparamscasing) | None | `'camelcase'` renames path parameters, such as `{pet-id}` to `petId`. |
23
+ | [`server`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#server) | None | Picks the `servers` entry that becomes the document `baseURL`. It does not change where a client sends requests. |
24
+ | [`contentType`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#contenttype) | Every media type | Keeps one media type when an operation declares several. |
21
25
 
22
- See [Options](https://kubb.dev/extensions/kubb-labs/adapter-oas/options) for every option and its default.
26
+ Run [`kubb validate`](https://kubb.dev/docs/5.x/reference/commands/validate) to list every spec error.
23
27
 
24
28
  ## Example
25
29
 
26
- The config below types dates as `Date` objects and 64-bit integers as numbers.
30
+ This config types dates as `Date` objects and 64-bit integers as numbers, so `@kubb/plugin-ts` writes this `Order` type:
31
+
32
+ ::code-group
27
33
 
28
34
  ```typescript [kubb.config.ts]
29
35
  import { defineConfig } from 'kubb/config'
@@ -34,8 +40,19 @@ export default defineConfig({
34
40
  input: './petStore.yaml',
35
41
  output: { path: './src/gen' },
36
42
  adapter: adapterOas({ dateType: 'date', integerType: 'number' }),
37
- plugins: [
38
- pluginTs(),
39
- ],
43
+ plugins: [pluginTs()],
40
44
  })
41
45
  ```
46
+
47
+ ```typescript [src/gen/types/Order.ts]
48
+ // excerpt, without JSDoc
49
+ export type Order = {
50
+ id?: number // int64, `bigint` by default
51
+ petId?: number
52
+ quantity?: number // int32
53
+ shipDate?: Date // date-time, `string` by default
54
+ complete?: boolean
55
+ }
56
+ ```
57
+
58
+ ::
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/adapter-oas",
3
- "version": "5.20.1",
3
+ "version": "5.20.2",
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",
@@ -66,8 +66,8 @@
66
66
  "registry": "https://registry.npmjs.org/"
67
67
  },
68
68
  "dependencies": {
69
- "@kubb/core": "^5.20.1",
70
- "@kubb/kit": "5.20.1",
69
+ "@kubb/core": "^5.20.2",
70
+ "@kubb/kit": "5.20.2",
71
71
  "@readme/openapi-parser": "^10.0.0",
72
72
  "@scalar/openapi-upgrader": "^0.4.7",
73
73
  "api-ref-bundler": "0.5.1",