@kubb/adapter-oas 5.19.2 → 5.20.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 +28 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +29 -12
- package/dist/index.js.map +1 -1
- package/docs/options.md +39 -12
- package/kubb-extension.json +17 -0
- package/package.json +3 -3
package/docs/options.md
CHANGED
|
@@ -4,18 +4,19 @@ Pass these options to `adapterOas()`. All of them are optional.
|
|
|
4
4
|
|
|
5
5
|
## Options overview
|
|
6
6
|
|
|
7
|
-
| Option
|
|
8
|
-
|
|
|
9
|
-
| [`validate`](#validate)
|
|
10
|
-
| [`contentType`](#contenttype)
|
|
11
|
-
| [`server`](#server)
|
|
12
|
-
| [`discriminator`](#discriminator)
|
|
13
|
-
| [`enums`](#enums)
|
|
14
|
-
| [`
|
|
15
|
-
| [`
|
|
16
|
-
| [`
|
|
17
|
-
| [`
|
|
18
|
-
| [`
|
|
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. |
|
|
19
20
|
|
|
20
21
|
## Option details
|
|
21
22
|
|
|
@@ -197,6 +198,32 @@ export type Pet = {
|
|
|
197
198
|
|
|
198
199
|
::
|
|
199
200
|
|
|
201
|
+
### pathParamsCasing
|
|
202
|
+
|
|
203
|
+
Renames `path` parameters and their `{placeholder}` in the operation path. Omit it to keep the names from the spec.
|
|
204
|
+
|
|
205
|
+
| | |
|
|
206
|
+
| -------- | ------------- |
|
|
207
|
+
| Type | `'camelcase'` |
|
|
208
|
+
| Required | `false` |
|
|
209
|
+
| Default | `undefined` |
|
|
210
|
+
|
|
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
|
+
For `GET /stores/{store-id}/pets/{pet-id}`, `@kubb/plugin-client` generates:
|
|
214
|
+
|
|
215
|
+
::code-group
|
|
216
|
+
|
|
217
|
+
```typescript [default]
|
|
218
|
+
await getPet({ path: { 'store-id': storeId, 'pet-id': petId } })
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
```typescript ['camelcase']
|
|
222
|
+
await getPet({ path: { storeId, petId } })
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
::
|
|
226
|
+
|
|
200
227
|
### dateType
|
|
201
228
|
|
|
202
229
|
How `date-time`, `date`, and `time` schemas are represented downstream.
|
package/kubb-extension.json
CHANGED
|
@@ -177,6 +177,23 @@
|
|
|
177
177
|
"value": "root"
|
|
178
178
|
}
|
|
179
179
|
]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"key": "pathParamsCasing",
|
|
183
|
+
"path": ["pathParamsCasing"],
|
|
184
|
+
"label": "Path Params Casing",
|
|
185
|
+
"description": "Rename path parameters and their {placeholder} to camelCase, such as {pet-id} or {pet_id} to petId. The HTTP request stays the same.",
|
|
186
|
+
"type": "select",
|
|
187
|
+
"choices": [
|
|
188
|
+
{
|
|
189
|
+
"label": "as in the spec",
|
|
190
|
+
"value": null
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"label": "camelcase",
|
|
194
|
+
"value": "camelcase"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
180
197
|
}
|
|
181
198
|
]
|
|
182
199
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/adapter-oas",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.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",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"registry": "https://registry.npmjs.org/"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@kubb/core": "^5.
|
|
70
|
-
"@kubb/kit": "5.
|
|
69
|
+
"@kubb/core": "^5.20.0",
|
|
70
|
+
"@kubb/kit": "5.20.0",
|
|
71
71
|
"@readme/openapi-parser": "^10.0.0",
|
|
72
72
|
"@scalar/openapi-upgrader": "^0.4.7",
|
|
73
73
|
"api-ref-bundler": "0.5.1",
|