@terreno/api 0.8.0 → 0.8.2

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.
@@ -63,13 +63,20 @@ module.exports = function generateDocument(baseDocument, router, basePath) {
63
63
  .filter(function (e) { return e; });
64
64
  if (schema.parameters) {
65
65
  schema.parameters.forEach(function (p) {
66
- if (!params_1.find(function (pp) { return p.name === pp.name; })) {
66
+ if (p.name && !params_1.find(function (pp) { return p.name === pp.name; })) {
67
67
  params_1.push(p);
68
68
  }
69
69
  });
70
70
  }
71
- operation.parameters = params_1;
72
- path = pathToRegexp.compile(path.replace(/\*|\(\*\)/g, '(.*)'))(keys_1, { encode: function (value) { return value; } });
71
+ operation.parameters = params_1.filter(function (p) { return typeof p.name === 'string' && p.name; });
72
+ try {
73
+ path = pathToRegexp.compile(path.replace(/\*|\(\*\)/g, '(.*)'))(keys_1, { encode: function (value) { return value; } });
74
+ }
75
+ catch (_e) {
76
+ // Express 5 stores path params in matchers instead of layer.keys, so keys
77
+ // may be incomplete. Fall back to simple regex replacement of :param → {param}.
78
+ path = path.replace(/:([a-zA-Z0-9_]+)/g, '{$1}');
79
+ }
73
80
  }
74
81
  doc.paths[path] = doc.paths[path] || {};
75
82
  doc.paths[path][layer.method] = operation;
package/package.json CHANGED
@@ -100,5 +100,5 @@
100
100
  "updateSnapshot": "bun test --update-snapshots"
101
101
  },
102
102
  "types": "dist/index.d.ts",
103
- "version": "0.8.0"
103
+ "version": "0.8.2"
104
104
  }
@@ -60,14 +60,20 @@ module.exports = function generateDocument (baseDocument, router, basePath) {
60
60
 
61
61
  if (schema.parameters) {
62
62
  schema.parameters.forEach((p) => {
63
- if (!params.find((pp) => p.name === pp.name)) {
63
+ if (p.name && !params.find((pp) => p.name === pp.name)) {
64
64
  params.push(p)
65
65
  }
66
66
  })
67
67
  }
68
68
 
69
- operation.parameters = params
70
- path = pathToRegexp.compile(path.replace(/\*|\(\*\)/g, '(.*)'))(keys, { encode: (value) => value })
69
+ operation.parameters = params.filter((p) => typeof p.name === 'string' && p.name)
70
+ try {
71
+ path = pathToRegexp.compile(path.replace(/\*|\(\*\)/g, '(.*)'))(keys, { encode: (value) => value })
72
+ } catch (_e) {
73
+ // Express 5 stores path params in matchers instead of layer.keys, so keys
74
+ // may be incomplete. Fall back to simple regex replacement of :param → {param}.
75
+ path = path.replace(/:([a-zA-Z0-9_]+)/g, '{$1}')
76
+ }
71
77
  }
72
78
 
73
79
  doc.paths[path] = doc.paths[path] || {}