@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/dist/index.d.cts
CHANGED
|
@@ -1257,6 +1257,11 @@ type AdapterOasOptions = {
|
|
|
1257
1257
|
* @default 'inline'
|
|
1258
1258
|
*/
|
|
1259
1259
|
enums?: 'inline' | 'root';
|
|
1260
|
+
/**
|
|
1261
|
+
* `'camelcase'` renames path parameters and their `{placeholder}` to camelCase (`{pet-id}` and
|
|
1262
|
+
* `{pet_id}` to `petId`). The HTTP request stays the same. Omit to keep the names from the spec.
|
|
1263
|
+
*/
|
|
1264
|
+
pathParamsCasing?: 'camelcase';
|
|
1260
1265
|
} & Partial<ast.ParserOptions>;
|
|
1261
1266
|
/**
|
|
1262
1267
|
* Adapter options after defaults have been applied.
|
|
@@ -1267,6 +1272,7 @@ type AdapterOasResolvedOptions = {
|
|
|
1267
1272
|
server: AdapterOasOptions['server'];
|
|
1268
1273
|
discriminator: NonNullable<AdapterOasOptions['discriminator']>;
|
|
1269
1274
|
enums: NonNullable<AdapterOasOptions['enums']>;
|
|
1275
|
+
pathParamsCasing: AdapterOasOptions['pathParamsCasing'];
|
|
1270
1276
|
dateType: NonNullable<AdapterOasOptions['dateType']>;
|
|
1271
1277
|
integerType: NonNullable<AdapterOasOptions['integerType']>;
|
|
1272
1278
|
unknownType: NonNullable<AdapterOasOptions['unknownType']>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1257,6 +1257,11 @@ type AdapterOasOptions = {
|
|
|
1257
1257
|
* @default 'inline'
|
|
1258
1258
|
*/
|
|
1259
1259
|
enums?: 'inline' | 'root';
|
|
1260
|
+
/**
|
|
1261
|
+
* `'camelcase'` renames path parameters and their `{placeholder}` to camelCase (`{pet-id}` and
|
|
1262
|
+
* `{pet_id}` to `petId`). The HTTP request stays the same. Omit to keep the names from the spec.
|
|
1263
|
+
*/
|
|
1264
|
+
pathParamsCasing?: 'camelcase';
|
|
1260
1265
|
} & Partial<ast.ParserOptions>;
|
|
1261
1266
|
/**
|
|
1262
1267
|
* Adapter options after defaults have been applied.
|
|
@@ -1267,6 +1272,7 @@ type AdapterOasResolvedOptions = {
|
|
|
1267
1272
|
server: AdapterOasOptions['server'];
|
|
1268
1273
|
discriminator: NonNullable<AdapterOasOptions['discriminator']>;
|
|
1269
1274
|
enums: NonNullable<AdapterOasOptions['enums']>;
|
|
1275
|
+
pathParamsCasing: AdapterOasOptions['pathParamsCasing'];
|
|
1270
1276
|
dateType: NonNullable<AdapterOasOptions['dateType']>;
|
|
1271
1277
|
integerType: NonNullable<AdapterOasOptions['integerType']>;
|
|
1272
1278
|
unknownType: NonNullable<AdapterOasOptions['unknownType']>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineExtension } from "@kubb/core";
|
|
2
|
-
import { Diagnostics, ast, childName, enumPrimitive, enumPropName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
|
|
2
|
+
import { Diagnostics, Url, ast, childName, enumPrimitive, enumPropName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
|
|
3
3
|
import { access, realpath } from "node:fs/promises";
|
|
4
4
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -14,7 +14,7 @@ var compatibility = {
|
|
|
14
14
|
"node": ">=22.22"
|
|
15
15
|
};
|
|
16
16
|
// package.json
|
|
17
|
-
var version = "5.
|
|
17
|
+
var version = "5.20.0";
|
|
18
18
|
// src/constants.ts
|
|
19
19
|
/**
|
|
20
20
|
* Default parser options applied when no explicit options are provided.
|
|
@@ -2488,6 +2488,19 @@ function parseOperation({ operation, ...ctx }) {
|
|
|
2488
2488
|
...auth && { auth }
|
|
2489
2489
|
});
|
|
2490
2490
|
}
|
|
2491
|
+
/** Renames path parameters and their `{placeholder}` to the camelCase names from {@link Url.toParamNames}. */
|
|
2492
|
+
function camelCasePathParams(node) {
|
|
2493
|
+
if (!node.path || node.parameters.some((param) => param.in === "path" && param.style === "matrix")) return node;
|
|
2494
|
+
const names = Url.toParamNames(node.path);
|
|
2495
|
+
return {
|
|
2496
|
+
...node,
|
|
2497
|
+
path: node.path.replace(/\{([^}]+)\}/g, (_match, name) => `{${names.get(name) ?? name}}`),
|
|
2498
|
+
parameters: node.parameters.map((param) => param.in === "path" && names.has(param.name) ? {
|
|
2499
|
+
...param,
|
|
2500
|
+
name: names.get(param.name)
|
|
2501
|
+
} : param)
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2491
2504
|
// src/emit/createNode.ts
|
|
2492
2505
|
/**
|
|
2493
2506
|
* Builds a schema node from a converter's base context plus its type-specific fields. Every
|
|
@@ -3937,19 +3950,20 @@ const adapterOas = defineExtension({
|
|
|
3937
3950
|
compatibility,
|
|
3938
3951
|
issues: "https://github.com/kubb-labs/kubb/issues"
|
|
3939
3952
|
},
|
|
3940
|
-
setup: ({ validate = true, contentType, server, discriminator = "preserve", enums = "inline", dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
|
|
3953
|
+
setup: ({ validate = true, contentType, server, discriminator = "preserve", enums = "inline", pathParamsCasing, dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
|
|
3941
3954
|
validate,
|
|
3942
3955
|
contentType,
|
|
3943
3956
|
server,
|
|
3944
3957
|
discriminator,
|
|
3945
3958
|
enums,
|
|
3959
|
+
pathParamsCasing,
|
|
3946
3960
|
dateType,
|
|
3947
3961
|
integerType,
|
|
3948
3962
|
unknownType,
|
|
3949
3963
|
emptySchemaType,
|
|
3950
3964
|
enumSuffix
|
|
3951
3965
|
}),
|
|
3952
|
-
build({ validate, contentType, server, discriminator, enums, ...parserOptions }) {
|
|
3966
|
+
build({ validate, contentType, server, discriminator, enums, pathParamsCasing, ...parserOptions }) {
|
|
3953
3967
|
let parsedDocument = null;
|
|
3954
3968
|
let sources = [];
|
|
3955
3969
|
const pendingValidations = [];
|
|
@@ -3975,14 +3989,17 @@ const adapterOas = defineExtension({
|
|
|
3975
3989
|
if (discriminator === "propagate" && (schema.oneOf ?? schema.anyOf) && schema.discriminator?.propertyName) discriminatorParentNodes.push(node);
|
|
3976
3990
|
}
|
|
3977
3991
|
const discriminatorChildMap = discriminatorParentNodes.length > 0 ? buildDiscriminatorChildMap(discriminatorParentNodes) : null;
|
|
3978
|
-
const operationNodes = getOperations(document, refs).map((operation) =>
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3992
|
+
const operationNodes = getOperations(document, refs).map((operation) => {
|
|
3993
|
+
const node = parseOperation({
|
|
3994
|
+
operation,
|
|
3995
|
+
document,
|
|
3996
|
+
refs,
|
|
3997
|
+
contentType,
|
|
3998
|
+
options: parserOptions,
|
|
3999
|
+
parseSchema
|
|
4000
|
+
});
|
|
4001
|
+
return pathParamsCasing === "camelcase" ? camelCasePathParams(node) : node;
|
|
4002
|
+
});
|
|
3986
4003
|
const promotedEnums = enums === "root" ? collectInlineEnums([...parsedByName.values(), ...operationNodes], new Set(Object.keys(schemas))) : null;
|
|
3987
4004
|
const aliasTargetOf = (name) => {
|
|
3988
4005
|
const node = refAliasMap.get(name);
|