Swagger nswag生成的代理破坏了URL
Swagger nswag生成的代理破坏了URL,swagger,swagger-ui,swagger-2.0,swagger-codegen,nswag,Swagger,Swagger Ui,Swagger 2.0,Swagger Codegen,Nswag,nswag软件的总体构思令人惊叹 不过,那些家伙已经彻底毁了这一切 我现在真的想放弃它,原因如下: 过度复杂 有问题的 记录极其贫乏 不得人心 关于我的版本——”nswag@11.17.19“ 我的服务应该传递复合结构(例如嵌套数组)——但在最近的版本中,它通过URL传递所有内容,我的意思是: 此外,它的最新版本不生成输入类-例如,我的API控制器具有actionImportEntries(ImportEntriesInput input) nswag不再生成输入类(我的意思是import
nswag
软件的总体构思令人惊叹
不过,那些家伙已经彻底毁了这一切
我现在真的想放弃它,原因如下:
- 过度复杂
- 有问题的
- 记录极其贫乏
- 不得人心
”nswag@11.17.19“
我的服务应该传递复合结构(例如嵌套数组)——但在最近的版本中,它通过URL传递所有内容,我的意思是:
此外,它的最新版本不生成输入类-例如,我的API控制器具有actionImportEntries(ImportEntriesInput input)
nswag
不再生成输入类(我的意思是importentiesinput
)-而是只列出其所有成员:
例如比较
importEntries(input: ImportEntriesInput | null | undefined): Observable<VocabularyDto> {
这解决了我上面帖子中提到的URL问题。 这没有文档记录,但为了使
nswag
能够与ASP.NET Core正常工作,您需要将[FromBody]
属性应用于每个接受数据的操作
e、 g
公共异步任务导入([FromBody]导入输入)
我可能会将此添加为注释-实际上,nswag
甚至无法包含用于JWT身份验证的附加头,但我已在Startup.cs
中指定了它new-SwaggerSecurityScheme{Type=SwaggerSecuritySchemeType.ApiKey,Name=“Authorization”,Description=“Copy'Bearer'+localStorage.getItem('token'),In=SwaggerSecurityApiKeyLocation.Header…
importEntries(entries: CrawlerEntryDto[] | null | undefined, vocabularyId: number | undefined, newVocabulary: boolean | undefined, typeId: number | undefined, name: string | null | undefined, notes: string | null | undefined): Observable<VocabularyDto | null> {
importEntries(entries: CrawlerEntryDto[] | null | undefined, vocabularyId: number | undefined, newVocabulary: boolean | undefined, typeId: number | undefined, name: string | null | undefined, notes: string | null | undefined): Observable<VocabularyDto | null> {
let url_ = this.baseUrl + "/api/Import/ImportEntries?";
if (entries !== undefined)
entries && entries.forEach((item, index) => {
for (let attr in item)
url_ += "entries[" + index + "]." + attr + "=" + encodeURIComponent("" + item[attr]) + "&";
});
if (vocabularyId === null)
throw new Error("The parameter 'vocabularyId' cannot be null.");
else if (vocabularyId !== undefined)
url_ += "vocabularyId=" + encodeURIComponent("" + vocabularyId) + "&";
if (newVocabulary === null)
throw new Error("The parameter 'newVocabulary' cannot be null.");
else if (newVocabulary !== undefined)
url_ += "newVocabulary=" + encodeURIComponent("" + newVocabulary) + "&";
if (typeId === null)
throw new Error("The parameter 'typeId' cannot be null.");
else if (typeId !== undefined)
url_ += "typeId=" + encodeURIComponent("" + typeId) + "&";
if (name !== undefined)
url_ += "name=" + encodeURIComponent("" + name) + "&";
if (notes !== undefined)
url_ += "notes=" + encodeURIComponent("" + notes) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ : any = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Content-Type": "application/json",
"Accept": "application/json",
'Authorization': 'Bearer ' + localStorage.getItem('token')
})
};
return this.http.request("post", url_, options_).flatMap((response_ : any) => {
return this.processImportEntries(response_);
}).catch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processImportEntries(<any>response_);
} catch (e) {
return <Observable<VocabularyDto | null>><any>Observable.throw(e);
}
} else
return <Observable<VocabularyDto | null>><any>Observable.throw(response_);
});
}
"codeGenerators": {
"swaggerToTypeScriptClient": {
"className": "{controller}ServiceProxy",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 2.0,
"template": "Angular",
"promiseType": "Promise",
"httpClass": "HttpClient",
"dateTimeType": "MomentJS",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": false,
"wrapDtoExceptions": false,
"wrapResponses": false,
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"useTransformOptionsMethod": false,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromPathSegments"
"markOptionalProperties": false,
"generateCloneMethod": true,
"typeStyle": "Class",
"extensionCode": "service.extensions.ts",
"generateDefaultValues": true,
"excludedTypeNames": [],
"handleReferences": false,
"generateConstructorInterface": true,
"importRequiredTypes": true,
"useGetBaseUrlMethod": false,
"baseUrlTokenName": "API_BASE_URL",
"injectionTokenType": "InjectionToken",
"output": "../src/shared/service-proxies/service-proxies.ts"
},
public async Task<VocabularyDto> ImportEntries([FromBody] ImportEntriesInput input)