mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 13:05:36 +03:00
fix generator api parameters
This commit is contained in:
parent
59a3045615
commit
46698078a0
1 changed files with 8 additions and 2 deletions
|
@ -52,20 +52,26 @@ class ApiGenerator {
|
||||||
|
|
||||||
apis: morph.SourceFile[] = [];
|
apis: morph.SourceFile[] = [];
|
||||||
|
|
||||||
|
methods = ['patch', 'delete', 'post', 'get', 'put', 'head', 'options', 'trace'];
|
||||||
|
|
||||||
constructor(openapi: OpenApi) {
|
constructor(openapi: OpenApi) {
|
||||||
this.openapi = openapi;
|
this.openapi = openapi;
|
||||||
this.paths = openapi.paths;
|
this.paths = openapi.paths;
|
||||||
this.serverUrl = openapi.servers[0].url;
|
this.serverUrl = openapi.servers[0].url;
|
||||||
|
|
||||||
Object.keys(this.paths).forEach((pathKey) => {
|
Object.keys(this.paths).forEach((pathKey) => {
|
||||||
Object.keys(this.paths[pathKey]).forEach((method) => {
|
Object.keys(this.paths[pathKey]).filter((method) => this.methods.includes(method)).forEach((method) => {
|
||||||
const {
|
const {
|
||||||
tags, operationId, parameters, responses, requestBody, security, "x-skip-web-api": skip
|
tags, operationId, responses, requestBody, security, "x-skip-web-api": skip
|
||||||
} = this.paths[pathKey][method];
|
} = this.paths[pathKey][method];
|
||||||
|
const parameters = this.paths[pathKey][method].parameters || this.paths[pathKey].parameters;
|
||||||
const controller = toCamel((tags ? tags[0] : pathKey.split('/')[1]));
|
const controller = toCamel((tags ? tags[0] : pathKey.split('/')[1]));
|
||||||
if (skip) {
|
if (skip) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!operationId) {
|
||||||
|
console.log(pathKey);
|
||||||
|
}
|
||||||
if (this.controllers[controller]) {
|
if (this.controllers[controller]) {
|
||||||
this.controllers[controller][uncapitalize(operationId)] = {
|
this.controllers[controller][uncapitalize(operationId)] = {
|
||||||
parameters,
|
parameters,
|
||||||
|
|
Loading…
Reference in a new issue