@onlineapps/service-wrapper 2.2.9 → 2.3.0
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/package.json +1 -1
- package/src/ServiceWrapper.js +22 -0
package/package.json
CHANGED
package/src/ServiceWrapper.js
CHANGED
|
@@ -1814,6 +1814,28 @@ class ServiceWrapper {
|
|
|
1814
1814
|
}
|
|
1815
1815
|
}
|
|
1816
1816
|
|
|
1817
|
+
// Extension 1: specificationEndpoint must match an Express route
|
|
1818
|
+
// See: docs/standards/api-versioning-contract.md
|
|
1819
|
+
const specEndpoint = this.config.service?.specificationEndpoint;
|
|
1820
|
+
if (specEndpoint && !routeSet.has(`GET:${specEndpoint}`)) {
|
|
1821
|
+
errors.push(
|
|
1822
|
+
`specificationEndpoint '${specEndpoint}' not found in Express routes — ` +
|
|
1823
|
+
`config claims this path but no GET route is registered`
|
|
1824
|
+
);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
// Extension 3: operations.json endpoints under /api/ must be versioned
|
|
1828
|
+
// See: docs/standards/api-versioning-contract.md
|
|
1829
|
+
const versionPattern = /^\/api\/v\d+\//;
|
|
1830
|
+
for (const [opName, opDef] of Object.entries(ops)) {
|
|
1831
|
+
if (opDef.endpoint?.startsWith('/api') && !versionPattern.test(opDef.endpoint)) {
|
|
1832
|
+
errors.push(
|
|
1833
|
+
`Operation '${opName}' endpoint '${opDef.endpoint}' missing version — ` +
|
|
1834
|
+
`expected /api/v{N}/... (see docs/standards/api-versioning-contract.md)`
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1817
1839
|
if (errors.length > 0) {
|
|
1818
1840
|
throw new Error(
|
|
1819
1841
|
`[ServiceWrapper] Operations-Routes alignment failed (${errors.length} issue${errors.length > 1 ? 's' : ''}):\n` +
|