forked from FoundKeyGang/FoundKey
generate OpenAPI spec for v2 endpoints
This commit is contained in:
parent
fad8dad5d8
commit
aefe15e8ed
1 changed files with 12 additions and 0 deletions
|
@ -203,6 +203,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;
|
||||
|
|
Loading…
Reference in a new issue