@crombolo/contracts 0.25.0 → 0.26.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/spec.ts +15 -2
package/package.json
CHANGED
package/src/spec.ts
CHANGED
|
@@ -55,11 +55,24 @@ export function loadSpec(): OpenApiSpec {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** The contract as `GET …/openapi.json` serves it. */
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* The contract as a site serves it. With `prefix`, its paths are moved from
|
|
60
|
+
* Umbraco's `/umbraco/management/api/` to where this site serves the API.
|
|
61
|
+
*/
|
|
62
|
+
export function servedContract(prefix?: string): string {
|
|
59
63
|
if (!served) served = JSON.stringify(loadSpec())
|
|
60
|
-
return served
|
|
64
|
+
if (!prefix || prefix === UMBRACO_PREFIX) return served
|
|
65
|
+
let moved = servedAt.get(prefix)
|
|
66
|
+
if (!moved) {
|
|
67
|
+
moved = served.replaceAll(`"${UMBRACO_PREFIX}`, `"${prefix}`)
|
|
68
|
+
servedAt.set(prefix, moved)
|
|
69
|
+
}
|
|
70
|
+
return moved
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
const UMBRACO_PREFIX = '/umbraco/management/api/'
|
|
74
|
+
const servedAt = new Map<string, string>()
|
|
75
|
+
|
|
63
76
|
let deliveryCached: OpenApiSpec | undefined
|
|
64
77
|
|
|
65
78
|
export function loadDeliverySpec(): OpenApiSpec {
|