@kubb/adapter-oas 5.8.3 → 5.9.0

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
@@ -7,12 +7,12 @@ let _scalar_openapi_upgrader = require("@scalar/openapi-upgrader");
7
7
  let api_ref_bundler = require("api-ref-bundler");
8
8
  //#region kubb-extension.json
9
9
  var compatibility = {
10
- "kubb": ">=5.8.0",
10
+ "kubb": ">=5.8.3",
11
11
  "node": ">=22"
12
12
  };
13
13
  //#endregion
14
14
  //#region package.json
15
- var version = "5.8.3";
15
+ var version = "5.9.0";
16
16
  //#endregion
17
17
  //#region src/constants.ts
18
18
  /**
package/dist/index.d.ts CHANGED
@@ -1194,8 +1194,8 @@ type AdapterOasOptions = {
1194
1194
  */
1195
1195
  validate?: boolean;
1196
1196
  /**
1197
- * Preferred media type when an operation defines several. Defaults to the
1198
- * first JSON-compatible media type found in the spec.
1197
+ * Media type to keep for request bodies and responses. Omit to keep every
1198
+ * media type an operation declares.
1199
1199
  */
1200
1200
  contentType?: ContentType;
1201
1201
  /**
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ import { upgrade } from "@scalar/openapi-upgrader";
6
6
  import { bundle } from "api-ref-bundler";
7
7
  //#region kubb-extension.json
8
8
  var compatibility = {
9
- "kubb": ">=5.8.0",
9
+ "kubb": ">=5.8.3",
10
10
  "node": ">=22"
11
11
  };
12
12
  //#endregion
13
13
  //#region package.json
14
- var version = "5.8.3";
14
+ var version = "5.9.0";
15
15
  //#endregion
16
16
  //#region src/constants.ts
17
17
  /**
package/docs/options.md CHANGED
@@ -12,7 +12,7 @@ Pass these options to `adapterOas()`. All of them are optional.
12
12
  | [`discriminator`](#discriminator) | How `discriminator` fields are interpreted. |
13
13
  | [`enums`](#enums) | Where inline enums live. |
14
14
  | [`dateType`](#datetype) | How `date-time`, `date`, and `time` schemas are represented. |
15
- | [`integerType`](#integertype) | How integers map to TypeScript. |
15
+ | [`integerType`](#integertype) | How `int64` and `uint64` integers map to TypeScript. |
16
16
  | [`unknownType`](#unknowntype) | Type for schemas Kubb cannot infer. |
17
17
  | [`emptySchemaType`](#emptyschematype) | Type for empty schemas. |
18
18
  | [`enumSuffix`](#enumsuffix) | Suffix for derived enum names. |
@@ -205,7 +205,7 @@ adapterOas({
205
205
 
206
206
  ### integerType
207
207
 
208
- How `type: integer` (and `format: int64`) maps to TypeScript.
208
+ 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`.
209
209
 
210
210
  | | |
211
211
  | -------- | ---------------------- |
package/docs/overview.md CHANGED
@@ -1,22 +1,30 @@
1
- # OpenAPI adapter
1
+ # OpenAPI
2
2
 
3
- The OpenAPI adapter reads an OpenAPI 2.0, 3.0, or 3.1 document and converts every schema and operation into Kubb's AST. Every plugin in the build generates code from that AST.
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.
4
4
 
5
- Kubb uses `adapterOas()` by default. Set it on `defineConfig.adapter` only to change its [options](https://kubb.dev/extensions/kubb-labs/adapter-oas/options). The options apply to every plugin in the build.
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.
6
+
7
+ ## Setup
8
+
9
+ Kubb uses `adapterOas()` by default, so no setup is needed. Set `adapter` in `defineConfig` only to change its options.
6
10
 
7
11
  ## Options worth knowing
8
12
 
9
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.
10
- - `dateType` sets how `date-time`, `date`, and `time` schemas are represented: ISO strings (the default), strings with or without a timezone offset, or JavaScript `Date` objects. Pass an object to set each format on its own.
11
- - `integerType` defaults to `'bigint'`, which is exact for 64-bit IDs but does not survive `JSON.stringify`. Choose `'number'` for most JSON APIs.
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.
12
16
  - `unknownType` and `emptySchemaType` set the type for schemas Kubb cannot infer and for empty schemas (`{}`).
13
17
  - `discriminator: 'propagate'` writes the discriminator's literal value into each child schema, so each branch is typed precisely.
14
18
  - `enums: 'root'` lifts inline enums to reusable top-level schemas, named with `enumSuffix` (`PetStatusEnum`).
15
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.
16
- - `contentType` picks the media type when an operation defines several. Without it, Kubb uses the first JSON media type.
20
+ - `contentType` picks one media type when an operation declares several. Without it, Kubb keeps every media type the operation declares.
21
+
22
+ See [Options](https://kubb.dev/extensions/kubb-labs/adapter-oas/options) for every option and its default.
17
23
 
18
24
  ## Example
19
25
 
26
+ The config below types dates as `Date` objects and 64-bit integers as numbers.
27
+
20
28
  ```typescript [kubb.config.ts]
21
29
  import { defineConfig } from 'kubb/config'
22
30
  import { adapterOas } from '@kubb/adapter-oas'
@@ -26,6 +34,8 @@ export default defineConfig({
26
34
  input: './petStore.yaml',
27
35
  output: { path: './src/gen' },
28
36
  adapter: adapterOas({ dateType: 'date', integerType: 'number' }),
29
- plugins: [pluginTs()],
37
+ plugins: [
38
+ pluginTs(),
39
+ ],
30
40
  })
31
41
  ```
@@ -13,7 +13,7 @@
13
13
  "docs": "https://kubb.dev/extensions/kubb-labs/adapter-oas",
14
14
  "maintainers": [{ "name": "Stijn Van Hulle", "github": "stijnvanhulle" }],
15
15
  "compatibility": {
16
- "kubb": ">=5.8.0",
16
+ "kubb": ">=5.8.3",
17
17
  "node": ">=22"
18
18
  },
19
19
  "options": [
@@ -59,7 +59,7 @@
59
59
  "key": "integerType",
60
60
  "path": ["integerType"],
61
61
  "label": "Integer Type",
62
- "description": "How integer and int64 schemas map to TypeScript.",
62
+ "description": "How int64 and uint64 schemas map to TypeScript. Other integers stay numbers.",
63
63
  "type": "select",
64
64
  "default": "bigint",
65
65
  "choices": [
@@ -132,7 +132,7 @@
132
132
  "key": "contentType",
133
133
  "path": ["contentType"],
134
134
  "label": "Content Type",
135
- "description": "Preferred media type when an operation defines several. Defaults to the first JSON media type in the spec.",
135
+ "description": "Media type to keep for request bodies and responses. Leave empty to keep every media type an operation declares.",
136
136
  "type": "text"
137
137
  },
138
138
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/adapter-oas",
3
- "version": "5.8.3",
3
+ "version": "5.9.0",
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",
@@ -61,7 +61,7 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@kubb/kit": "5.8.3",
64
+ "@kubb/kit": "5.9.0",
65
65
  "@readme/openapi-parser": "^9.1.0",
66
66
  "@scalar/openapi-upgrader": "^0.4.3",
67
67
  "api-ref-bundler": "0.5.1",