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 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.replace(/\:[a-z0-9]+\w/i, (param) => `{${param.replace(':', '')}}`);
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.replace(/\:[a-z0-9]+\w/i, (param) => `{${param.replace(':', '')}}`);
919
+ normalizePathParamForOpenAPI(info.path);
910
920
  if (!swagger.paths[path]) {
911
921
  swagger.paths[path] = {};
912
922
  }
@@ -1,2 +1,3 @@
1
1
  export declare function mapToPrimitive(type: string): any;
2
2
  export declare function mapToRef(type: string): string;
3
+ export declare function normalizePathParamForOpenAPI(path: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sofa-api",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Create REST APIs with GraphQL",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {