generate OpenAPI spec for v2 endpoints

This commit is contained in:
Andy 2022-09-25 17:31:32 +02:00 committed by Johann150
parent 5c0cf99b59
commit b5b5dd51af
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -207,6 +207,18 @@ export function genOpenapiSpec() {
}
spec.paths['/' + endpoint.name] = path;
if (endpoint.meta.v2) {
// we need a clone of the API endpoint info because otherwise we change it by reference
const infoClone = JSON.parse(JSON.stringify(info));
const route = `/v2/${endpoint.meta.v2.alias ?? endpoint.name.replace(/-/g, '_')}`;
infoClone['operationId'] = infoClone['summary'] = route;
spec.paths[route] = {
[endpoint.meta.v2.method]: infoClone,
};
}
}
return spec;