@sdk-it/spec 0.45.0 → 0.46.1
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/README.md +65 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
- package/dist/lib/find-polymorphic-varients.js +6 -11
- package/dist/lib/find-polymorphic-varients.js.map +2 -2
- package/dist/lib/for-each-operation.d.ts +11 -3
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +23 -15
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/format-name.d.ts.map +1 -1
- package/dist/lib/format-name.js +0 -1
- package/dist/lib/format-name.js.map +2 -2
- package/dist/lib/ir.d.ts +2 -2
- package/dist/lib/ir.d.ts.map +1 -1
- package/dist/lib/ir.js +6 -120
- package/dist/lib/ir.js.map +2 -2
- package/dist/lib/is-primitive-schema.js +1 -1
- package/dist/lib/is-primitive-schema.js.map +1 -1
- package/dist/lib/is.d.ts +2 -0
- package/dist/lib/is.d.ts.map +1 -1
- package/dist/lib/is.js +6 -3
- package/dist/lib/is.js.map +2 -2
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.js +1 -11
- package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
- package/dist/lib/options.d.ts +7 -45
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +26 -28
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/overview-pagination.d.ts +1 -1
- package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-pagination.js +1 -1
- package/dist/lib/overview-docs/overview-pagination.js.map +2 -2
- package/dist/lib/pagination/guess-pagination.d.ts.map +1 -1
- package/dist/lib/pagination/guess-pagination.js +1 -1
- package/dist/lib/pagination/guess-pagination.js.map +2 -2
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.js +15 -5
- package/dist/lib/pagination/pagination-result.js.map +2 -2
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +7 -6
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts +3 -0
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js +29 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js.map +7 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +5 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js +30 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +7 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts +25 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -0
- package/dist/lib/processing-plugins/enrich-examples.js +93 -0
- package/dist/lib/processing-plugins/enrich-examples.js.map +7 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js +165 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js +13 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js.map +7 -0
- package/dist/lib/processing-plugins/index.d.ts +14 -0
- package/dist/lib/processing-plugins/index.d.ts.map +1 -0
- package/dist/lib/processing-plugins/index.js +14 -0
- package/dist/lib/processing-plugins/index.js.map +7 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts +3 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -0
- package/dist/lib/processing-plugins/infer-pagination.js +21 -0
- package/dist/lib/processing-plugins/infer-pagination.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js +74 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-parameters.js +29 -0
- package/dist/lib/processing-plugins/normalize-parameters.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-paths.js +67 -0
- package/dist/lib/processing-plugins/normalize-paths.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +6 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js +139 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -0
- package/dist/lib/{tune-response.js → processing-plugins/normalize-responses.js} +55 -25
- package/dist/lib/processing-plugins/normalize-responses.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-schemas.js +170 -0
- package/dist/lib/processing-plugins/normalize-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-tags.js +18 -0
- package/dist/lib/processing-plugins/normalize-tags.js.map +7 -0
- package/dist/lib/processing.d.ts +33 -0
- package/dist/lib/processing.d.ts.map +1 -0
- package/dist/lib/processing.js +41 -0
- package/dist/lib/processing.js.map +7 -0
- package/dist/lib/reserved-keywords.d.ts.map +1 -1
- package/dist/lib/reserved-keywords.js +18 -1
- package/dist/lib/reserved-keywords.js.map +2 -2
- package/dist/lib/tag.js +2 -2
- package/dist/lib/tag.js.map +2 -2
- package/dist/lib/types.d.ts +4 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/walk-schemas.d.ts +8 -0
- package/dist/lib/walk-schemas.d.ts.map +1 -0
- package/dist/lib/walk-schemas.js +51 -0
- package/dist/lib/walk-schemas.js.map +7 -0
- package/package.json +2 -2
- package/dist/lib/tune-request-body.d.ts +0 -5
- package/dist/lib/tune-request-body.d.ts.map +0 -1
- package/dist/lib/tune-request-body.js +0 -91
- package/dist/lib/tune-request-body.js.map +0 -7
- package/dist/lib/tune-response.d.ts +0 -5
- package/dist/lib/tune-response.d.ts.map +0 -1
- package/dist/lib/tune-response.js.map +0 -7
- package/dist/lib/tune.d.ts +0 -11
- package/dist/lib/tune.d.ts.map +0 -1
- package/dist/lib/tune.js +0 -291
- package/dist/lib/tune.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/extract-inline-schemas.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { isEmpty, isRef, joinSkipDigits, pascalcase } from '@sdk-it/core';\n\nimport type { Varient } from '../find-polymorphic-varients.js';\nimport { findUniqueSchemaName } from '../find-unique-schema-name.js';\nimport type { ProcessingPlugin } from '../processing.js';\nimport type { IR } from '../types.js';\n\nfunction extractInlineSchemaComponents(\n spec: IR,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIndex in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIndex];\n if (isRef(oneOf)) continue;\n for (const key of ['properties', 'x-properties'] as const) {\n if (!isEmpty(oneOf.required) && schema[key]) {\n schema.oneOf[oneOfIndex] = schema[key][oneOf.required[0]];\n }\n }\n }\n delete schema.type;\n extractInlineSchemaComponents(spec, schemas);\n continue;\n }\n if (schema.additionalProperties) {\n continue;\n }\n spec.components.schemas[name] = schema;\n const properties = schema.properties as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propertyName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropertyName = propertyName.replace('[]', '');\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(joinSkipDigits([name, fixedPropertyName], ' ')),\n ['Property', 'Field', 'Attribute'],\n );\n\n if (!isEmpty(value.properties)) {\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else if (!isEmpty(value.oneOf)) {\n extractInlineUnion(spec, name, value, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else if (!isEmpty(value.anyOf)) {\n extractInlineUnion(spec, name, value, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else {\n extractInlineSchemaComponents(spec, { [refName]: value });\n }\n }\n\n continue;\n }\n if (!isEmpty(schema['x-properties'])) {\n spec.components.schemas[name] = schema;\n\n const properties = schema['x-properties'] as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propertyName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropertyName = propertyName.replace('[]', '');\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(joinSkipDigits([name, fixedPropertyName], ' ')),\n ['Property', 'Field', 'Attribute'],\n );\n\n if (!isEmpty(value.properties)) {\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else if (!isEmpty(value.oneOf)) {\n extractInlineUnion(spec, name, value, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else if (!isEmpty(value.anyOf)) {\n extractInlineUnion(spec, name, value, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propertyName] = {\n $ref: `#/components/schemas/${refName}`,\n };\n extractInlineSchemaComponents(spec, { [refName]: value });\n } else {\n extractInlineSchemaComponents(spec, { [refName]: value });\n }\n }\n continue;\n }\n\n if (schema.type === 'array') {\n if (isRef(schema.items) || isEmpty(schema.items)) continue;\n const refName = findUniqueSchemaName(spec, name, ['Item', 'Entry']);\n if (schema.items.type === 'object') {\n spec.components.schemas[refName] = schema.items;\n extractInlineSchemaComponents(spec, { [refName]: schema.items });\n schema.items = { $ref: `#/components/schemas/${refName}` };\n continue;\n }\n if (schema.items.type === 'array') {\n extractInlineSchemaComponents(spec, { [refName]: schema.items });\n continue;\n }\n if (!isEmpty(schema.items.oneOf)) {\n extractInlineUnion(spec, refName, schema.items, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.items.anyOf)) {\n extractInlineUnion(spec, refName, schema.items, 'anyOf');\n continue;\n }\n }\n if (!isEmpty(schema.oneOf)) {\n extractInlineUnion(spec, name, schema, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.anyOf)) {\n extractInlineUnion(spec, name, schema, 'anyOf');\n }\n }\n}\n\nfunction extractInlineUnion(\n spec: IR,\n name: string,\n schema: SchemaObject,\n kind: 'oneOf' | 'anyOf',\n) {\n const varients = schema['x-varients'] as Varient[];\n if (!varients || varients.length === 0) {\n console.warn(\n `No varients found for ${name}. This might be an error in the OpenAPI spec.`,\n );\n }\n varients.forEach((varient) => {\n const varientSchema = schema[kind]![varient.position];\n if (isRef(varientSchema)) return;\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(`${name} ${varient.name}`),\n ['Varient'],\n );\n\n if (varientSchema.type === 'object') {\n spec.components.schemas[refName] = varientSchema;\n extractInlineSchemaComponents(spec, { [refName]: varientSchema });\n schema[kind]![varient.position] = {\n $ref: `#/components/schemas/${refName}`,\n };\n } else {\n extractInlineSchemaComponents(spec, { [refName]: varientSchema });\n }\n });\n}\n\nexport function extractInlineSchemas(): ProcessingPlugin {\n return {\n name: 'extract-inline-schemas',\n process({ spec }) {\n extractInlineSchemaComponents(spec, spec.components.schemas);\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,SAAS,OAAO,gBAAgB,kBAAkB;AAG3D,SAAS,4BAA4B;AAIrC,SAAS,8BACP,MACA,SACA;AACA,aAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AACpD,QAAI,MAAM,MAAM,EAAG;AAEnB,QAAI,CAAC,QAAQ,OAAO,UAAU,GAAG;AAC/B,UAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,mBAAW,cAAc,OAAO,OAAO;AACrC,gBAAM,QAAQ,OAAO,MAAM,UAAU;AACrC,cAAI,MAAM,KAAK,EAAG;AAClB,qBAAW,OAAO,CAAC,cAAc,cAAc,GAAY;AACzD,gBAAI,CAAC,QAAQ,MAAM,QAAQ,KAAK,OAAO,GAAG,GAAG;AAC3C,qBAAO,MAAM,UAAU,IAAI,OAAO,GAAG,EAAE,MAAM,SAAS,CAAC,CAAC;AAAA,YAC1D;AAAA,UACF;AAAA,QACF;AACA,eAAO,OAAO;AACd,sCAA8B,MAAM,OAAO;AAC3C;AAAA,MACF;AACA,UAAI,OAAO,sBAAsB;AAC/B;AAAA,MACF;AACA,WAAK,W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;AAAA,IACZ;AAEA,QAAI,cAAc,SAAS,UAAU;AACnC,WAAK,WAAW,QAAQ,OAAO,IAAI;AACnC,oCAA8B,MAAM,EAAE,CAAC,OAAO,GAAG,cAAc,CAAC;AAChE,aAAO,IAAI,EAAG,QAAQ,QAAQ,IAAI;AAAA,QAChC,MAAM,wBAAwB,OAAO;AAAA,MACvC;AAAA,IACF,OAAO;AACL,oCAA8B,MAAM,EAAE,CAAC,OAAO,GAAG,cAAc,CAAC;AAAA,IAClE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,uBAAyC;AACvD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,oCAA8B,MAAM,KAAK,WAAW,OAAO;AAAA,IAC7D;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-overview-docs.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/extract-overview-docs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,yBAAyB,IAAI,gBAAgB,CAO5D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { extractOverviewDocs } from "../overview-docs/overview-docs.js";
|
|
2
|
+
function extractOverviewDocsPlugin() {
|
|
3
|
+
return {
|
|
4
|
+
name: "extract-overview-docs",
|
|
5
|
+
process({ spec }) {
|
|
6
|
+
spec["x-docs"] = extractOverviewDocs(spec);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
extractOverviewDocsPlugin
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=extract-overview-docs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/extract-overview-docs.ts"],
|
|
4
|
+
"sourcesContent": ["import { extractOverviewDocs } from '../overview-docs/overview-docs.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nexport function extractOverviewDocsPlugin(): ProcessingPlugin {\n return {\n name: 'extract-overview-docs',\n process({ spec }) {\n spec['x-docs'] = extractOverviewDocs(spec);\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,2BAA2B;AAG7B,SAAS,4BAA8C;AAC5D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,WAAK,QAAQ,IAAI,oBAAoB,IAAI;AAAA,IAC3C;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './canonicalize-spec.js';
|
|
2
|
+
export * from './create-default-processing-plugins.js';
|
|
3
|
+
export * from './enrich-examples.js';
|
|
4
|
+
export * from './extract-inline-schemas.js';
|
|
5
|
+
export * from './extract-overview-docs.js';
|
|
6
|
+
export * from './infer-pagination.js';
|
|
7
|
+
export * from './normalize-operation-ids.js';
|
|
8
|
+
export * from './normalize-parameters.js';
|
|
9
|
+
export * from './normalize-paths.js';
|
|
10
|
+
export * from './normalize-request-bodies.js';
|
|
11
|
+
export * from './normalize-responses.js';
|
|
12
|
+
export * from './normalize-schemas.js';
|
|
13
|
+
export * from './normalize-tags.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wCAAwC,CAAC;AACvD,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./canonicalize-spec.js";
|
|
2
|
+
export * from "./create-default-processing-plugins.js";
|
|
3
|
+
export * from "./enrich-examples.js";
|
|
4
|
+
export * from "./extract-inline-schemas.js";
|
|
5
|
+
export * from "./extract-overview-docs.js";
|
|
6
|
+
export * from "./infer-pagination.js";
|
|
7
|
+
export * from "./normalize-operation-ids.js";
|
|
8
|
+
export * from "./normalize-parameters.js";
|
|
9
|
+
export * from "./normalize-paths.js";
|
|
10
|
+
export * from "./normalize-request-bodies.js";
|
|
11
|
+
export * from "./normalize-responses.js";
|
|
12
|
+
export * from "./normalize-schemas.js";
|
|
13
|
+
export * from "./normalize-tags.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './canonicalize-spec.js';\nexport * from './create-default-processing-plugins.js';\nexport * from './enrich-examples.js';\nexport * from './extract-inline-schemas.js';\nexport * from './extract-overview-docs.js';\nexport * from './infer-pagination.js';\nexport * from './normalize-operation-ids.js';\nexport * from './normalize-parameters.js';\nexport * from './normalize-paths.js';\nexport * from './normalize-request-bodies.js';\nexport * from './normalize-responses.js';\nexport * from './normalize-schemas.js';\nexport * from './normalize-tags.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infer-pagination.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/infer-pagination.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,wBAAgB,eAAe,IAAI,gBAAgB,CAclD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { iterateOperations } from "../for-each-operation.js";
|
|
2
|
+
import { toPagination } from "../pagination/pagination.js";
|
|
3
|
+
function inferPagination() {
|
|
4
|
+
return {
|
|
5
|
+
name: "infer-pagination",
|
|
6
|
+
process({ spec, options }) {
|
|
7
|
+
for (const { operation } of iterateOperations(spec)) {
|
|
8
|
+
const tunedOperation = operation;
|
|
9
|
+
if (options.pagination.enabled && options.pagination.guess) {
|
|
10
|
+
tunedOperation["x-pagination"] = toPagination(spec, tunedOperation);
|
|
11
|
+
} else {
|
|
12
|
+
delete tunedOperation["x-pagination"];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
inferPagination
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=infer-pagination.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/infer-pagination.ts"],
|
|
4
|
+
"sourcesContent": ["import { iterateOperations } from '../for-each-operation.js';\nimport { toPagination } from '../pagination/pagination.js';\nimport type { ProcessingPlugin } from '../processing.js';\nimport type { TunedOperationObject } from '../types.js';\n\nexport function inferPagination(): ProcessingPlugin {\n return {\n name: 'infer-pagination',\n process({ spec, options }) {\n for (const { operation } of iterateOperations(spec)) {\n const tunedOperation = operation as TunedOperationObject;\n if (options.pagination.enabled && options.pagination.guess) {\n tunedOperation['x-pagination'] = toPagination(spec, tunedOperation);\n } else {\n delete tunedOperation['x-pagination'];\n }\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAItB,SAAS,kBAAoC;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,MAAM,QAAQ,GAAG;AACzB,iBAAW,EAAE,UAAU,KAAK,kBAAkB,IAAI,GAAG;AACnD,cAAM,iBAAiB;AACvB,YAAI,QAAQ,WAAW,WAAW,QAAQ,WAAW,OAAO;AAC1D,yBAAe,cAAc,IAAI,aAAa,MAAM,cAAc;AAAA,QACpE,OAAO;AACL,iBAAO,eAAe,cAAc;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-operation-ids.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-operation-ids.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA2CzD,wBAAgB,qBAAqB,IAAI,gBAAgB,CA0CxD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { iterateOperations } from "../for-each-operation.js";
|
|
2
|
+
import { toResource } from "../guess/guess-resource.js";
|
|
3
|
+
function findUniqueOperationId(usedOperationIds, initialId, choices, formatter) {
|
|
4
|
+
let counter = 1;
|
|
5
|
+
let uniqueOperationId = formatter(initialId);
|
|
6
|
+
while (usedOperationIds.has(uniqueOperationId)) {
|
|
7
|
+
const prependIndex = Math.min(counter - 1, choices.length - 1);
|
|
8
|
+
const prefix = choices[prependIndex];
|
|
9
|
+
uniqueOperationId = formatter(
|
|
10
|
+
prependIndex < choices.length - 1 ? `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}` : `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`
|
|
11
|
+
);
|
|
12
|
+
counter++;
|
|
13
|
+
}
|
|
14
|
+
return uniqueOperationId;
|
|
15
|
+
}
|
|
16
|
+
function normalizeOperationIdentifier(value) {
|
|
17
|
+
const normalized = value.trim().replace(/[^A-Za-z0-9]+/g, " ").replace(
|
|
18
|
+
/(?:^|\s+)([A-Za-z0-9])/g,
|
|
19
|
+
(_, character) => character.toUpperCase()
|
|
20
|
+
).replace(/^([A-Z])/, (character) => character.toLowerCase());
|
|
21
|
+
if (!normalized) {
|
|
22
|
+
return "operation";
|
|
23
|
+
}
|
|
24
|
+
if (/^[A-Za-z]/.test(normalized)) {
|
|
25
|
+
return normalized;
|
|
26
|
+
}
|
|
27
|
+
return `operation${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`;
|
|
28
|
+
}
|
|
29
|
+
function normalizeOperationIds() {
|
|
30
|
+
return {
|
|
31
|
+
name: "normalize-operation-ids",
|
|
32
|
+
process({ spec, options, report }) {
|
|
33
|
+
const usedOperationIds = /* @__PURE__ */ new Set();
|
|
34
|
+
for (const { entry, operation } of iterateOperations(spec)) {
|
|
35
|
+
const originalOperationId = operation.operationId;
|
|
36
|
+
const { name } = toResource(operation, entry.path, entry.method);
|
|
37
|
+
const operationTag = options.tag(operation, entry.path);
|
|
38
|
+
const operationId = findUniqueOperationId(
|
|
39
|
+
usedOperationIds,
|
|
40
|
+
normalizeOperationIdentifier(
|
|
41
|
+
options.operationId(operation, entry.path, entry.method)
|
|
42
|
+
),
|
|
43
|
+
[
|
|
44
|
+
operationTag,
|
|
45
|
+
entry.method,
|
|
46
|
+
entry.path.split("/").filter(Boolean).join("")
|
|
47
|
+
],
|
|
48
|
+
(candidate) => normalizeOperationIdentifier(
|
|
49
|
+
options.operationId(
|
|
50
|
+
{ ...operation, operationId: candidate },
|
|
51
|
+
entry.path,
|
|
52
|
+
entry.method
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
usedOperationIds.add(operationId);
|
|
57
|
+
operation.operationId = operationId;
|
|
58
|
+
operation["x-fn-name"] = name;
|
|
59
|
+
if (operationId !== originalOperationId) {
|
|
60
|
+
report({
|
|
61
|
+
severity: "info",
|
|
62
|
+
code: "operation-id-normalized",
|
|
63
|
+
message: `Normalized operation ID ${originalOperationId ?? "<missing>"} to ${operationId}`,
|
|
64
|
+
path: `${entry.method.toUpperCase()} ${entry.path}`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
normalizeOperationIds
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=normalize-operation-ids.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/normalize-operation-ids.ts"],
|
|
4
|
+
"sourcesContent": ["import { iterateOperations } from '../for-each-operation.js';\nimport { toResource } from '../guess/guess-resource.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nfunction findUniqueOperationId(\n usedOperationIds: Set<string>,\n initialId: string,\n choices: string[],\n formatter: (id: string) => string,\n) {\n let counter = 1;\n let uniqueOperationId = formatter(initialId);\n\n while (usedOperationIds.has(uniqueOperationId)) {\n const prependIndex = Math.min(counter - 1, choices.length - 1);\n const prefix = choices[prependIndex];\n uniqueOperationId = formatter(\n prependIndex < choices.length - 1\n ? `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}`\n : `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`,\n );\n counter++;\n }\n\n return uniqueOperationId;\n}\n\nfunction normalizeOperationIdentifier(value: string): string {\n const normalized = value\n .trim()\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .replace(/(?:^|\\s+)([A-Za-z0-9])/g, (_, character: string) =>\n character.toUpperCase(),\n )\n .replace(/^([A-Z])/, (character) => character.toLowerCase());\n\n if (!normalized) {\n return 'operation';\n }\n if (/^[A-Za-z]/.test(normalized)) {\n return normalized;\n }\n return `operation${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`;\n}\n\nexport function normalizeOperationIds(): ProcessingPlugin {\n return {\n name: 'normalize-operation-ids',\n process({ spec, options, report }) {\n const usedOperationIds = new Set<string>();\n for (const { entry, operation } of iterateOperations(spec)) {\n const originalOperationId = operation.operationId;\n const { name } = toResource(operation, entry.path, entry.method);\n const operationTag = options.tag(operation, entry.path);\n const operationId = findUniqueOperationId(\n usedOperationIds,\n normalizeOperationIdentifier(\n options.operationId(operation, entry.path, entry.method),\n ),\n [\n operationTag,\n entry.method,\n entry.path.split('/').filter(Boolean).join(''),\n ],\n (candidate) =>\n normalizeOperationIdentifier(\n options.operationId(\n { ...operation, operationId: candidate },\n entry.path,\n entry.method,\n ),\n ),\n );\n usedOperationIds.add(operationId);\n operation.operationId = operationId;\n operation['x-fn-name'] = name;\n if (operationId !== originalOperationId) {\n report({\n severity: 'info',\n code: 'operation-id-normalized',\n message: `Normalized operation ID ${originalOperationId ?? '<missing>'} to ${operationId}`,\n path: `${entry.method.toUpperCase()} ${entry.path}`,\n });\n }\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAG3B,SAAS,sBACP,kBACA,WACA,SACA,WACA;AACA,MAAI,UAAU;AACd,MAAI,oBAAoB,UAAU,SAAS;AAE3C,SAAO,iBAAiB,IAAI,iBAAiB,GAAG;AAC9C,UAAM,eAAe,KAAK,IAAI,UAAU,GAAG,QAAQ,SAAS,CAAC;AAC7D,UAAM,SAAS,QAAQ,YAAY;AACnC,wBAAoB;AAAA,MAClB,eAAe,QAAQ,SAAS,IAC5B,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,KAClE,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,GAAG,UAAU,QAAQ,SAAS,CAAC;AAAA,IACvG;AACA;AA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qBAAqB;AACvC,iBAAO;AAAA,YACL,UAAU;AAAA,YACV,MAAM;AAAA,YACN,SAAS,2BAA2B,uBAAuB,WAAW,OAAO,WAAW;AAAA,YACxF,MAAM,GAAG,MAAM,OAAO,YAAY,CAAC,IAAI,MAAM,IAAI;AAAA,UACnD,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-parameters.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-parameters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAsBtD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { resolveRef } from "@sdk-it/core/ref.js";
|
|
2
|
+
import { iterateOperations } from "../for-each-operation.js";
|
|
3
|
+
function normalizeParameters() {
|
|
4
|
+
return {
|
|
5
|
+
name: "normalize-parameters",
|
|
6
|
+
process({ spec }) {
|
|
7
|
+
const pathItems = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const { operation, pathItem } of iterateOperations(spec)) {
|
|
9
|
+
pathItems.add(pathItem);
|
|
10
|
+
const parameters = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const parameterOrRef of [
|
|
12
|
+
...pathItem.parameters ?? [],
|
|
13
|
+
...operation.parameters ?? []
|
|
14
|
+
]) {
|
|
15
|
+
const parameter = resolveRef(spec, parameterOrRef);
|
|
16
|
+
parameters.set(`${parameter.in}:${parameter.name}`, parameter);
|
|
17
|
+
}
|
|
18
|
+
operation.parameters = [...parameters.values()];
|
|
19
|
+
}
|
|
20
|
+
for (const pathItem of pathItems) {
|
|
21
|
+
delete pathItem.parameters;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
normalizeParameters
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=normalize-parameters.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/normalize-parameters.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ParameterObject, PathItemObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core/ref.js';\n\nimport { iterateOperations } from '../for-each-operation.js';\nimport type { ProcessingPlugin } from '../processing.js';\n\nexport function normalizeParameters(): ProcessingPlugin {\n return {\n name: 'normalize-parameters',\n process({ spec }) {\n const pathItems = new Set<PathItemObject>();\n for (const { operation, pathItem } of iterateOperations(spec)) {\n pathItems.add(pathItem);\n const parameters = new Map<string, ParameterObject>();\n for (const parameterOrRef of [\n ...(pathItem.parameters ?? []),\n ...(operation.parameters ?? []),\n ]) {\n const parameter = resolveRef<ParameterObject>(spec, parameterOrRef);\n parameters.set(`${parameter.in}:${parameter.name}`, parameter);\n }\n operation.parameters = [...parameters.values()];\n }\n for (const pathItem of pathItems) {\n delete pathItem.parameters;\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAG3B,SAAS,sBAAwC;AACtD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,KAAK,GAAG;AAChB,YAAM,YAAY,oBAAI,IAAoB;AAC1C,iBAAW,EAAE,WAAW,SAAS,KAAK,kBAAkB,IAAI,GAAG;AAC7D,kBAAU,IAAI,QAAQ;AACtB,cAAM,aAAa,oBAAI,IAA6B;AACpD,mBAAW,kBAAkB;AAAA,UAC3B,GAAI,SAAS,cAAc,CAAC;AAAA,UAC5B,GAAI,UAAU,cAAc,CAAC;AAAA,QAC/B,GAAG;AACD,gBAAM,YAAY,WAA4B,MAAM,cAAc;AAClE,qBAAW,IAAI,GAAG,UAAU,EAAE,IAAI,UAAU,IAAI,IAAI,SAAS;AAAA,QAC/D;AACA,kBAAU,aAAa,CAAC,GAAG,WAAW,OAAO,CAAC;AAAA,MAChD;AACA,iBAAW,YAAY,WAAW;AAChC,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-paths.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-paths.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,cAAc,IAAI,gBAAgB,CAgEjD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { methods } from "@sdk-it/core/paths.js";
|
|
2
|
+
import { followRef } from "@sdk-it/core/ref.js";
|
|
3
|
+
function normalizePaths() {
|
|
4
|
+
return {
|
|
5
|
+
name: "normalize-paths",
|
|
6
|
+
process({ spec, report }) {
|
|
7
|
+
const paths = {};
|
|
8
|
+
const operationSources = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
10
|
+
const normalizedPath = path.replace(/:([^/]+)/g, "{$1}");
|
|
11
|
+
const target = paths[normalizedPath] ??= {};
|
|
12
|
+
const source = pathItem.$ref ? {
|
|
13
|
+
...followRef(spec, pathItem.$ref),
|
|
14
|
+
...pathItem
|
|
15
|
+
} : pathItem;
|
|
16
|
+
delete source.$ref;
|
|
17
|
+
Object.assign(
|
|
18
|
+
target,
|
|
19
|
+
Object.fromEntries(
|
|
20
|
+
Object.entries(source).filter(
|
|
21
|
+
([key]) => key !== "parameters" && !methods.some((method) => method === key)
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
for (const method of methods) {
|
|
26
|
+
const operation = source[method];
|
|
27
|
+
if (operation) {
|
|
28
|
+
const operationKey = `${normalizedPath}:${method}`;
|
|
29
|
+
const previousPath = operationSources.get(operationKey);
|
|
30
|
+
if (previousPath) {
|
|
31
|
+
const message = `Both ${previousPath} and ${path} define ${method.toUpperCase()} after path normalization`;
|
|
32
|
+
report({
|
|
33
|
+
severity: "error",
|
|
34
|
+
code: "path-operation-collision",
|
|
35
|
+
message,
|
|
36
|
+
path: `${method.toUpperCase()} ${normalizedPath}`
|
|
37
|
+
});
|
|
38
|
+
throw new Error(message);
|
|
39
|
+
}
|
|
40
|
+
const parameters = [
|
|
41
|
+
...source.parameters ?? [],
|
|
42
|
+
...operation.parameters ?? []
|
|
43
|
+
];
|
|
44
|
+
target[method] = {
|
|
45
|
+
...operation,
|
|
46
|
+
...parameters.length > 0 ? { parameters } : {}
|
|
47
|
+
};
|
|
48
|
+
operationSources.set(operationKey, path);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (normalizedPath !== path) {
|
|
52
|
+
report({
|
|
53
|
+
severity: "info",
|
|
54
|
+
code: "path-normalized",
|
|
55
|
+
message: `Normalized path ${path} to ${normalizedPath}`,
|
|
56
|
+
path
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
spec.paths = paths;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
normalizePaths
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=normalize-paths.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/normalize-paths.ts"],
|
|
4
|
+
"sourcesContent": ["import type { PathItemObject, PathsObject } from 'openapi3-ts/oas31';\n\nimport { methods } from '@sdk-it/core/paths.js';\nimport { followRef } from '@sdk-it/core/ref.js';\n\nimport type { ProcessingPlugin } from '../processing.js';\n\nexport function normalizePaths(): ProcessingPlugin {\n return {\n name: 'normalize-paths',\n process({ spec, report }) {\n const paths: PathsObject = {};\n const operationSources = new Map<string, string>();\n for (const [path, pathItem] of Object.entries(spec.paths)) {\n const normalizedPath = path.replace(/:([^/]+)/g, '{$1}');\n const target = (paths[normalizedPath] ??= {});\n const source = pathItem.$ref\n ? {\n ...followRef<PathItemObject>(spec, pathItem.$ref),\n ...pathItem,\n }\n : pathItem;\n delete source.$ref;\n Object.assign(\n target,\n Object.fromEntries(\n Object.entries(source).filter(\n ([key]) =>\n key !== 'parameters' &&\n !methods.some((method) => method === key),\n ),\n ),\n );\n for (const method of methods) {\n const operation = source[method];\n if (operation) {\n const operationKey = `${normalizedPath}:${method}`;\n const previousPath = operationSources.get(operationKey);\n if (previousPath) {\n const message = `Both ${previousPath} and ${path} define ${method.toUpperCase()} after path normalization`;\n report({\n severity: 'error',\n code: 'path-operation-collision',\n message,\n path: `${method.toUpperCase()} ${normalizedPath}`,\n });\n throw new Error(message);\n }\n const parameters = [\n ...(source.parameters ?? []),\n ...(operation.parameters ?? []),\n ];\n target[method] = {\n ...operation,\n ...(parameters.length > 0 ? { parameters } : {}),\n };\n operationSources.set(operationKey, path);\n }\n }\n if (normalizedPath !== path) {\n report({\n severity: 'info',\n code: 'path-normalized',\n message: `Normalized path ${path} to ${normalizedPath}`,\n path,\n });\n }\n }\n spec.paths = paths;\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAInB,SAAS,iBAAmC;AACjD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAE,MAAM,OAAO,GAAG;AACxB,YAAM,QAAqB,CAAC;AAC5B,YAAM,mBAAmB,oBAAI,IAAoB;AACjD,iBAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,KAAK,KAAK,GAAG;AACzD,cAAM,iBAAiB,KAAK,QAAQ,aAAa,MAAM;AACvD,cAAM,SAAU,MAAM,cAAc,MAAM,CAAC;AAC3C,cAAM,SAAS,SAAS,OACpB;AAAA,UACE,GAAG,UAA0B,MAAM,SAAS,IAAI;AA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{ ParameterObject, SchemaObject, SecurityRequirementObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import type { ProcessingPlugin } from '../processing.js';
|
|
3
|
+
import type { IR } from '../types.js';
|
|
4
|
+
export declare function patchParameters(spec: IR, schema: SchemaObject, parameters: ParameterObject[], security: SecurityRequirementObject[]): void;
|
|
5
|
+
export declare function normalizeRequestBodies(): ProcessingPlugin;
|
|
6
|
+
//# sourceMappingURL=normalize-request-bodies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-request-bodies.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-request-bodies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEf,YAAY,EACZ,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAO3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EACV,EAAE,EAGH,MAAM,aAAa,CAAC;AAErB,wBAAgB,eAAe,CAC7B,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,eAAe,EAAE,EAC7B,QAAQ,EAAE,yBAAyB,EAAE,QAiCtC;AA+ED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAwCzD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { followRef, isRef, resolveRef } from "@sdk-it/core/ref.js";
|
|
2
|
+
import { isEmpty } from "@sdk-it/core/utils.js";
|
|
3
|
+
import { findUniqueSchemaName } from "../find-unique-schema-name.js";
|
|
4
|
+
import { iterateOperations } from "../for-each-operation.js";
|
|
5
|
+
import { securityToOptions } from "../security.js";
|
|
6
|
+
function patchParameters(spec, schema, parameters, security) {
|
|
7
|
+
const securityOptions = securityToOptions(
|
|
8
|
+
spec,
|
|
9
|
+
security,
|
|
10
|
+
spec.components.securitySchemes
|
|
11
|
+
);
|
|
12
|
+
const required = new Set(
|
|
13
|
+
Array.isArray(schema.required) ? schema.required : []
|
|
14
|
+
);
|
|
15
|
+
schema["x-properties"] ??= {};
|
|
16
|
+
for (const param of parameters) {
|
|
17
|
+
if (param.required) {
|
|
18
|
+
required.add(param.name);
|
|
19
|
+
}
|
|
20
|
+
schema["x-properties"][param.name] = {
|
|
21
|
+
"x-in": param.in,
|
|
22
|
+
...isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" }
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
for (const param of securityOptions) {
|
|
26
|
+
required.delete(param.name);
|
|
27
|
+
schema["x-properties"][param.name] = {
|
|
28
|
+
"x-in": "header",
|
|
29
|
+
...isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
schema["x-required"] = [...required];
|
|
33
|
+
}
|
|
34
|
+
function normalizeRequestBody(spec, operationId, operation, parameters, security) {
|
|
35
|
+
const requestBodySource = isRef(operation.requestBody) ? followRef(spec, operation.requestBody.$ref) : operation.requestBody ?? {
|
|
36
|
+
content: {},
|
|
37
|
+
required: false
|
|
38
|
+
};
|
|
39
|
+
const requestBody = structuredClone(requestBodySource);
|
|
40
|
+
if (isEmpty(requestBody.content)) {
|
|
41
|
+
const inputName = findUniqueSchemaName(spec, operationId, [
|
|
42
|
+
"input",
|
|
43
|
+
"payload",
|
|
44
|
+
"request"
|
|
45
|
+
]);
|
|
46
|
+
const schema = {
|
|
47
|
+
"x-inputname": inputName,
|
|
48
|
+
"x-requestbody": true
|
|
49
|
+
};
|
|
50
|
+
patchParameters(spec, schema, parameters, security);
|
|
51
|
+
const normalized = {
|
|
52
|
+
...requestBody,
|
|
53
|
+
content: {
|
|
54
|
+
"application/empty": {
|
|
55
|
+
schema: { $ref: `#/components/schemas/${inputName}` }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
spec.components.schemas[inputName] = schema;
|
|
60
|
+
return normalized;
|
|
61
|
+
}
|
|
62
|
+
for (const contentType in requestBody.content) {
|
|
63
|
+
const mediaType = requestBody.content[contentType];
|
|
64
|
+
const inputName = findUniqueSchemaName(spec, operationId, [
|
|
65
|
+
"input",
|
|
66
|
+
"payload",
|
|
67
|
+
"request"
|
|
68
|
+
]);
|
|
69
|
+
let schema;
|
|
70
|
+
switch (true) {
|
|
71
|
+
case isRef(mediaType.schema):
|
|
72
|
+
schema = structuredClone(
|
|
73
|
+
followRef(spec, mediaType.schema.$ref)
|
|
74
|
+
);
|
|
75
|
+
break;
|
|
76
|
+
case isEmpty(mediaType.schema):
|
|
77
|
+
schema ??= {};
|
|
78
|
+
console.warn(
|
|
79
|
+
`Request body schema for content type "${contentType}" is empty.`
|
|
80
|
+
);
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
schema = structuredClone(mediaType.schema);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
patchParameters(spec, schema, parameters, security);
|
|
87
|
+
spec.components.schemas[inputName] = {
|
|
88
|
+
...schema,
|
|
89
|
+
"x-requestbody": true,
|
|
90
|
+
"x-inputname": inputName
|
|
91
|
+
};
|
|
92
|
+
requestBody.content[contentType].schema = {
|
|
93
|
+
$ref: `#/components/schemas/${inputName}`
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return requestBody;
|
|
97
|
+
}
|
|
98
|
+
function normalizeRequestBodies() {
|
|
99
|
+
return {
|
|
100
|
+
name: "normalize-request-bodies",
|
|
101
|
+
process({ spec }) {
|
|
102
|
+
for (const { operation } of iterateOperations(spec)) {
|
|
103
|
+
const tunedOperation = operation;
|
|
104
|
+
if (operation.requestBody) {
|
|
105
|
+
const requestBody = resolveRef(
|
|
106
|
+
spec,
|
|
107
|
+
operation.requestBody
|
|
108
|
+
);
|
|
109
|
+
const schemas = Object.values(requestBody.content).map(
|
|
110
|
+
({ schema }) => schema ? resolveRef(spec, schema) : void 0
|
|
111
|
+
);
|
|
112
|
+
if (schemas.length > 0 && schemas.every((schema) => schema?.["x-requestbody"])) {
|
|
113
|
+
for (const schema of new Set(schemas)) {
|
|
114
|
+
patchParameters(
|
|
115
|
+
spec,
|
|
116
|
+
schema,
|
|
117
|
+
tunedOperation.parameters,
|
|
118
|
+
operation.security ?? []
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
tunedOperation.requestBody = normalizeRequestBody(
|
|
125
|
+
spec,
|
|
126
|
+
tunedOperation.operationId,
|
|
127
|
+
operation,
|
|
128
|
+
tunedOperation.parameters,
|
|
129
|
+
operation.security ?? []
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
normalizeRequestBodies,
|
|
137
|
+
patchParameters
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=normalize-request-bodies.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/processing-plugins/normalize-request-bodies.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n OperationObject,\n ParameterObject,\n RequestBodyObject,\n SchemaObject,\n SecurityRequirementObject,\n} from 'openapi3-ts/oas31';\n\nimport { followRef, isRef, resolveRef } from '@sdk-it/core/ref.js';\nimport { isEmpty } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from '../find-unique-schema-name.js';\nimport { iterateOperations } from '../for-each-operation.js';\nimport type { ProcessingPlugin } from '../processing.js';\nimport { securityToOptions } from '../security.js';\nimport type {\n IR,\n OurRequestBodyObject,\n TunedOperationObject,\n} from '../types.js';\n\nexport function patchParameters(\n spec: IR,\n schema: SchemaObject,\n parameters: ParameterObject[],\n security: SecurityRequirementObject[],\n) {\n const securityOptions = securityToOptions(\n spec,\n security,\n spec.components.securitySchemes,\n );\n\n const required = new Set(\n Array.isArray(schema.required) ? schema.required : [],\n );\n schema['x-properties'] ??= {};\n for (const param of parameters) {\n if (param.required) {\n required.add(param.name);\n }\n schema['x-properties'][param.name] = {\n 'x-in': param.in,\n ...(isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' })),\n };\n }\n for (const param of securityOptions) {\n required.delete(param.name);\n schema['x-properties'][param.name] = {\n 'x-in': 'header',\n ...(isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' })),\n };\n }\n schema['x-required'] = [...required];\n}\n\nfunction normalizeRequestBody(\n spec: IR,\n operationId: string,\n operation: OperationObject,\n parameters: ParameterObject[],\n security: SecurityRequirementObject[],\n): OurRequestBodyObject {\n const requestBodySource = isRef(operation.requestBody)\n ? followRef<RequestBodyObject>(spec, operation.requestBody.$ref)\n : (operation.requestBody ?? {\n content: {},\n required: false,\n });\n const requestBody = structuredClone(requestBodySource);\n if (isEmpty(requestBody.content)) {\n const inputName = findUniqueSchemaName(spec, operationId, [\n 'input',\n 'payload',\n 'request',\n ]);\n const schema: SchemaObject = {\n 'x-inputname': inputName,\n 'x-requestbody': true,\n };\n patchParameters(spec, schema, parameters, security);\n const normalized: OurRequestBodyObject = {\n ...requestBody,\n content: {\n 'application/empty': {\n schema: { $ref: `#/components/schemas/${inputName}` },\n },\n },\n };\n\n spec.components.schemas[inputName] = schema;\n return normalized;\n }\n for (const contentType in requestBody.content) {\n const mediaType = requestBody.content[contentType];\n const inputName = findUniqueSchemaName(spec, operationId, [\n 'input',\n 'payload',\n 'request',\n ]);\n let schema: SchemaObject | undefined;\n\n switch (true) {\n case isRef(mediaType.schema):\n schema = structuredClone(\n followRef<SchemaObject>(spec, mediaType.schema.$ref),\n );\n break;\n case isEmpty(mediaType.schema):\n schema ??= {};\n console.warn(\n `Request body schema for content type \"${contentType}\" is empty.`,\n );\n break;\n default:\n schema = structuredClone(mediaType.schema);\n break;\n }\n\n patchParameters(spec, schema, parameters, security);\n spec.components.schemas[inputName] = {\n ...schema,\n 'x-requestbody': true,\n 'x-inputname': inputName,\n };\n\n requestBody.content[contentType].schema = {\n $ref: `#/components/schemas/${inputName}`,\n };\n }\n return requestBody as OurRequestBodyObject;\n}\n\nexport function normalizeRequestBodies(): ProcessingPlugin {\n return {\n name: 'normalize-request-bodies',\n process({ spec }) {\n for (const { operation } of iterateOperations(spec)) {\n const tunedOperation = operation as TunedOperationObject;\n if (operation.requestBody) {\n const requestBody = resolveRef<RequestBodyObject>(\n spec,\n operation.requestBody,\n );\n const schemas = Object.values(requestBody.content).map(\n ({ schema }) =>\n schema ? resolveRef<SchemaObject>(spec, schema) : undefined,\n );\n if (\n schemas.length > 0 &&\n schemas.every((schema) => schema?.['x-requestbody'])\n ) {\n for (const schema of new Set(schemas)) {\n patchParameters(\n spec,\n schema as SchemaObject,\n tunedOperation.parameters,\n operation.security ?? [],\n );\n }\n continue;\n }\n }\n tunedOperation.requestBody = normalizeRequestBody(\n spec,\n tunedOperation.operationId,\n operation,\n tunedOperation.parameters,\n operation.security ?? [],\n );\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,WAAW,OAAO,kBAAkB;AAC7C,SAAS,eAAe;AAExB,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAElC,SAAS,yBAAyB;AAO3B,SAAS,gBACd,MACA,QACA,YACA,UACA;AACA,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,KAAK,WAAW;AAAA,EAClB;AAEA,QAAM,WAAW,IAAI;AAAA,IACnB,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;AAAA,EACtD;AACA,SAAO,cAAc,MAAM,CAAC;AAC5B,aAAW,SAAS,YAAY;AAC9B,QAAI,MAAM,UAAU;AAClB,eAAS,IAAI,MAAM,IAAI;AAAA,IACzB;AACA,WAAO,cAAc,EAAE,MAAM,IAAI,IAAI;AAAA,MACnC,QAAQ,MAAM;AAAA,MACd,GAAI,MAAM,M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,UACA,eAAe;AAAA,UACf;AAAA,UACA,eAAe;AAAA,UACf,UAAU,YAAY,CAAC;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-responses.d.ts","sourceRoot":"","sources":["../../../src/lib/processing-plugins/normalize-responses.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA8IzD,wBAAgB,kBAAkB,IAAI,gBAAgB,CA+BrD"}
|