sofa-api 0.16.0 → 0.16.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/index.js +11 -1
- package/index.mjs +11 -1
- package/open-api/utils.d.ts +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -678,6 +678,16 @@ function mapToPrimitive(type) {
|
|
|
678
678
|
}
|
|
679
679
|
function mapToRef(type) {
|
|
680
680
|
return `#/components/schemas/${type}`;
|
|
681
|
+
}
|
|
682
|
+
function normalizePathParamForOpenAPI(path) {
|
|
683
|
+
const pathParts = path.split('/');
|
|
684
|
+
const normalizedPathParts = pathParts.map((part) => {
|
|
685
|
+
if (part.startsWith(':')) {
|
|
686
|
+
return `{${part.slice(1)}}`;
|
|
687
|
+
}
|
|
688
|
+
return part;
|
|
689
|
+
});
|
|
690
|
+
return normalizedPathParts.join('/');
|
|
681
691
|
}
|
|
682
692
|
|
|
683
693
|
function buildSchemaObjectFromType(type, opts) {
|
|
@@ -912,7 +922,7 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
|
|
|
912
922
|
addRoute(info, config) {
|
|
913
923
|
const basePath = (config === null || config === void 0 ? void 0 : config.basePath) || '';
|
|
914
924
|
const path = basePath +
|
|
915
|
-
info.path
|
|
925
|
+
normalizePathParamForOpenAPI(info.path);
|
|
916
926
|
if (!swagger.paths[path]) {
|
|
917
927
|
swagger.paths[path] = {};
|
|
918
928
|
}
|
package/index.mjs
CHANGED
|
@@ -672,6 +672,16 @@ function mapToPrimitive(type) {
|
|
|
672
672
|
}
|
|
673
673
|
function mapToRef(type) {
|
|
674
674
|
return `#/components/schemas/${type}`;
|
|
675
|
+
}
|
|
676
|
+
function normalizePathParamForOpenAPI(path) {
|
|
677
|
+
const pathParts = path.split('/');
|
|
678
|
+
const normalizedPathParts = pathParts.map((part) => {
|
|
679
|
+
if (part.startsWith(':')) {
|
|
680
|
+
return `{${part.slice(1)}}`;
|
|
681
|
+
}
|
|
682
|
+
return part;
|
|
683
|
+
});
|
|
684
|
+
return normalizedPathParts.join('/');
|
|
675
685
|
}
|
|
676
686
|
|
|
677
687
|
function buildSchemaObjectFromType(type, opts) {
|
|
@@ -906,7 +916,7 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
|
|
|
906
916
|
addRoute(info, config) {
|
|
907
917
|
const basePath = (config === null || config === void 0 ? void 0 : config.basePath) || '';
|
|
908
918
|
const path = basePath +
|
|
909
|
-
info.path
|
|
919
|
+
normalizePathParamForOpenAPI(info.path);
|
|
910
920
|
if (!swagger.paths[path]) {
|
|
911
921
|
swagger.paths[path] = {};
|
|
912
922
|
}
|
package/open-api/utils.d.ts
CHANGED