@kubb/adapter-oas 5.0.0-alpha.11 → 5.0.0-alpha.12
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 +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/parser.ts +21 -1
package/dist/index.js
CHANGED
|
@@ -157,9 +157,12 @@ function toCamelOrPascal(text, pascal) {
|
|
|
157
157
|
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
158
158
|
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
159
159
|
* Segments are joined with `/` to form a file path.
|
|
160
|
+
*
|
|
161
|
+
* Only splits on dots followed by a letter so that version numbers
|
|
162
|
+
* embedded in operationIds (e.g. `v2025.0`) are kept intact.
|
|
160
163
|
*/
|
|
161
164
|
function applyToFileParts(text, transformPart) {
|
|
162
|
-
const parts = text.split(
|
|
165
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
163
166
|
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
164
167
|
}
|
|
165
168
|
/**
|
|
@@ -1794,18 +1797,26 @@ function createOasParser(oas, { contentType, collisionDetection } = {}) {
|
|
|
1794
1797
|
function parseOperation(options, oas, operation) {
|
|
1795
1798
|
const parameters = oas.getParameters(operation).map((param) => parseParameter(options, param));
|
|
1796
1799
|
const requestBodySchema = oas.getRequestSchema(operation);
|
|
1797
|
-
const
|
|
1800
|
+
const requestBodySchemaNode = requestBodySchema ? convertSchema({ schema: requestBodySchema }, options) : void 0;
|
|
1801
|
+
const requestBodyKeysToOmit = requestBodySchema?.properties ? Object.entries(requestBodySchema.properties).filter(([, prop]) => !isReference(prop) && prop.readOnly).map(([key]) => key) : void 0;
|
|
1802
|
+
const requestBody = requestBodySchemaNode ? {
|
|
1803
|
+
schema: requestBodySchemaNode,
|
|
1804
|
+
keysToOmit: requestBodyKeysToOmit?.length ? requestBodyKeysToOmit : void 0
|
|
1805
|
+
} : void 0;
|
|
1798
1806
|
const responses = operation.getResponseStatusCodes().map((statusCode) => {
|
|
1799
1807
|
const responseObj = operation.getResponseByStatusCode(statusCode);
|
|
1800
1808
|
const responseSchema = oas.getResponseSchema(operation, statusCode);
|
|
1801
1809
|
const schema = responseSchema && Object.keys(responseSchema).length > 0 ? convertSchema({ schema: responseSchema }, options) : createSchema({ type: resolveTypeOption(options.emptySchemaType) });
|
|
1802
1810
|
const description = typeof responseObj === "object" && responseObj !== null && !Array.isArray(responseObj) ? responseObj.description : void 0;
|
|
1803
1811
|
const rawContent = typeof responseObj === "object" && responseObj !== null && !Array.isArray(responseObj) ? responseObj.content : void 0;
|
|
1812
|
+
const mediaType = rawContent ? toMediaType(Object.keys(rawContent)[0] ?? "") : toMediaType(operation.contentType ?? "");
|
|
1813
|
+
const keysToOmit = responseSchema?.properties ? Object.entries(responseSchema.properties).filter(([, prop]) => !isReference(prop) && prop.writeOnly).map(([key]) => key) : void 0;
|
|
1804
1814
|
return createResponse({
|
|
1805
1815
|
statusCode,
|
|
1806
1816
|
description,
|
|
1807
1817
|
schema,
|
|
1808
|
-
mediaType
|
|
1818
|
+
mediaType,
|
|
1819
|
+
keysToOmit: keysToOmit?.length ? keysToOmit : void 0
|
|
1809
1820
|
});
|
|
1810
1821
|
});
|
|
1811
1822
|
return createOperation({
|