如何解决Swagger CodeGen,使代理删除某些元素并进行简化
有没有办法使用 Swagger Io Codegen Editor 自动生成代理,同时删除某些元素?我们正在将 C# API 转换为 Angular Typescript 代理。
原始代理:
public getUserDepartment(departmentId: number,observe?: 'body',reportProgress?: boolean): Observable<GetUserResponse>;
public getUserDepartment(departmentId: number,observe?: 'response',reportProgress?: boolean): Observable<HttpResponse<GetUserResponse>>;
public getUserDepartment(departmentId: number,observe?: 'events',reportProgress?: boolean): Observable<HttpEvent<GetUserResponse>>;
public getUserDepartment(departmentId: number,observe: any = 'body',reportProgress: boolean = false ): Observable<any> {
if (departmentId === null || departmentId === undefined) {
throw new Error('required parameter departmentId was null or undefined when calling getUserDepartment.');
}
let headers = this.defaultHeaders;
// authentication (Token) required
if (this.configuration.apiKeys && this.configuration.apiKeys["Authorization"]) {
headers = headers.set('Authorization',this.configuration.apiKeys["Authorization"]);
}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
'application/json;odata.Metadata=minimal;odata.streaming=true','application/json;odata.Metadata=minimal;odata.streaming=false','application/json;odata.Metadata=minimal','application/json;odata.Metadata=full;odata.streaming=true','application/json;odata.Metadata=full;odata.streaming=false','application/json;odata.Metadata=full','application/json;odata.Metadata=none;odata.streaming=true','application/json;odata.Metadata=none;odata.streaming=false','application/json;odata.Metadata=none','application/json;odata.streaming=true','application/json;odata.streaming=false','application/json','application/xml','application/prs.odatatestxx-odata','text/plain','text/json'
];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers = headers.set('Accept',httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [
];
return this.httpClient.request<GetUserResponse>('get',`${this.basePath}/api/Users/department/${encodeURIComponent(String(departmentId))}`,{
withCredentials: this.configuration.withCredentials,headers: headers,observe: observe,reportProgress: reportProgress
}
);
}
最终预期结果:
public getUserDepartment(departmentId: number) {
if (departmentId === null || departmentId === undefined) {
throw new Error('required parameter departmentId was null or undefined when calling getUserDepartment.');
}
return this.httpClient.request<GetUserResponse>('get',{}
);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。