Open viveknuna opened 6 years ago
What methods are generated / which method is generated twice?
Its giving errors in for these methods in service-proxies.ts file.
export class AppServiceProxy {
private http: Http;
private baseUrl: string;
protected jsonParseReviver: (key: string, value: any) => any = undefined;
constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "";
}
/**
* @return Success
*/
Test(id: number): Observable<TestDetailsDto> {
let url_ = this.baseUrl + "/api/services/app/Test?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined and cannot be null.");
else
url_ += "Id=" + encodeURIComponent("" + id) + "&";
url_ = url_.replace(/[?&]$/, "");
const content_ = "";
let options_ = {
body: content_,
method: "get",
headers: new Headers({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json; charset=UTF-8"
})
};
return this.http.request(url_, options_).flatMap((response_) => {
return this.processTest(response_);
}).catch((response_: any) => {
if (response_ instanceof Response) {
try {
return this.processTest(response_);
} catch (e) {
return <Observable<TestDetailsDto>><any>Observable.throw(e);
}
} else
return <Observable<TestDetailsDto>><any>Observable.throw(response_);
});
}
protected processTest(response: Response): Observable<TestDetailsDto> {
const status = response.status;
if (status === 200) {
const responseText = response.text();
let result200: TestDetailsDto = null;
let resultData200 = responseText === "" ? null : JSON.parse(responseText, this.jsonParseReviver);
result200 = resultData200 ? TestDetailsDto.fromJS(resultData200) : new TestDetailsDto();
return Observable.of(result200);
} else if (status === 401) {
const responseText = response.text();
return throwException("A server error occurred.", status, responseText);
} else if (status !== 200 && status !== 204) {
const responseText = response.text();
return throwException("An unexpected server error occurred.", status, responseText);
}
return Observable.of<TestDetailsDto>(<any>null);
}
/**
* @return Success
*/
Test(input: TestDetailsDto): Observable<void> {
let url_ = this.baseUrl + "/api/services/app/Test";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(input ? input.toJSON() : null);
let options_ = {
body: content_,
method: "put",
headers: new Headers({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json; charset=UTF-8"
})
};
return this.http.request(url_, options_).flatMap((response_) => {
return this.processTest(response_);
}).catch((response_: any) => {
if (response_ instanceof Response) {
try {
return this.processTest(response_);
} catch (e) {
return <Observable<void>><any>Observable.throw(e);
}
} else
return <Observable<void>><any>Observable.throw(response_);
});
}
protected processTest(response: Response): Observable<void> {
const status = response.status;
if (status === 200) {
const responseText = response.text();
return Observable.of<void>(<any>null);
} else if (status === 401) {
const responseText = response.text();
return throwException("A server error occurred.", status, responseText);
} else if (status !== 200 && status !== 204) {
const responseText = response.text();
return throwException("An unexpected server error occurred.", status, responseText);
}
return Observable.of<void>(<any>null);
}
/**
* @return Success
*/
Test(input: TestDetailsDto): Observable<number> {
let url_ = this.baseUrl + "/api/services/app/Test";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(input ? input.toJSON() : null);
let options_ = {
body: content_,
method: "post",
headers: new Headers({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json; charset=UTF-8"
})
};
return this.http.request(url_, options_).flatMap((response_) => {
return this.processTest(response_);
}).catch((response_: any) => {
if (response_ instanceof Response) {
try {
return this.processTest(response_);
} catch (e) {
return <Observable<number>><any>Observable.throw(e);
}
} else
return <Observable<number>><any>Observable.throw(response_);
});
}
protected processTest(response: Response): Observable<number> {
const status = response.status;
if (status === 200) {
const responseText = response.text();
let result200: number = null;
let resultData200 = responseText === "" ? null : JSON.parse(responseText, this.jsonParseReviver);
result200 = resultData200 !== undefined ? resultData200 : <any>null;
return Observable.of(result200);
} else if (status === 401) {
const responseText = response.text();
return throwException("A server error occurred.", status, responseText);
} else if (status !== 200 && status !== 204) {
const responseText = response.text();
return throwException("An unexpected server error occurred.", status, responseText);
}
return Observable.of<number>(<any>null);
}
/**
* @return Success
*/
Test(id: number): Observable<void> {
let url_ = this.baseUrl + "/api/services/app/Test?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined and cannot be null.");
else
url_ += "Id=" + encodeURIComponent("" + id) + "&";
url_ = url_.replace(/[?&]$/, "");
const content_ = "";
let options_ = {
body: content_,
method: "delete",
headers: new Headers({
"Content-Type": "application/json; charset=UTF-8",
"Accept": "application/json; charset=UTF-8"
})
};
return this.http.request(url_, options_).flatMap((response_) => {
return this.processTest(response_);
}).catch((response_: any) => {
if (response_ instanceof Response) {
try {
return this.processTest(response_);
} catch (e) {
return <Observable<void>><any>Observable.throw(e);
}
} else
return <Observable<void>><any>Observable.throw(response_);
});
}
protected processTest(response: Response): Observable<void> {
const status = response.status;
if (status === 200) {
const responseText = response.text();
return Observable.of<void>(<any>null);
} else if (status === 401) {
const responseText = response.text();
return throwException("A server error occurred.", status, responseText);
} else if (status !== 200 && status !== 204) {
const responseText = response.text();
return throwException("An unexpected server error occurred.", status, responseText);
}
return Observable.of<void>(<any>null);
}
}
The problem is that for the TS generator you use:
"operationGenerationMode": "MultipleClientsFromPathSegments",
instead of
"operationGenerationMode": "MultipleClientsFromOperationId",
MultipleClientsFromPathSegments uses just the last route segement as method name, and thus often provokes a name clash...
This is also not working, giving more than 100 errors.
It has started giving errors.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,24): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (14,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommunicationServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,47): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-general.component.ts (5,28): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,24): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (14,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommunicationServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,47): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-general.component.ts (5,28): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,24): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (14,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommunicationServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,47): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-general.component.ts (5,28): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,24): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (14,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommunicationServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,47): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-general.component.ts (5,28): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (13,24): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-list.component.ts (14,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommunicationServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'AlertServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-main.component.ts (6,47): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-general.component.ts (5,28): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CommonServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-storelist.component.ts (8,5): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'NoticeServiceProxy'.
ERROR in C:/Users/viveknuna/source/repos/Stanchion/angular/src/app/merchandising/alerts/alert-store.component.ts (9,10): Module '"C:/Users/viveknuna/source/repos/Stanchion/angular/src/shared/service-proxies/service-proxies"' has no exported member 'NoticeServiceProxy'.
I have another project with the below config file, for this project its working fine, But when I copy my config file this project also fails. So I think this issue is related to config. Please find both config files and let me know if I do need to change my config.
Working Service.Config.Nswag
{
"swaggerGenerator": {
"fromSwagger": {
"url": "http://localhost:22742/swagger/v1/swagger.json",
"output": null
}
},
"codeGenerators": {
"swaggerToTypeScriptClient": {
"className": "{controller}ServiceProxy",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 1.8,
"template": "Angular",
"promiseType": "Promise",
"dateTimeType": "MomentJS",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": false,
"wrapDtoExceptions": false,
"useTransformOptionsMethod": false,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromPathSegments",
"markOptionalProperties": false,
"generateCloneMethod": false,
"typeStyle": "Class",
"extensionCode": "service.extensions.ts",
"generateDefaultValues": true,
"excludedTypeNames": [],
"handleReferences": false,
"generateConstructorInterface": true,
"importRequiredTypes": true,
"baseUrlTokenName": "API_BASE_URL",
"output": "../src/shared/service-proxies/service-proxies.ts"
},
"swaggerToCSharpClient": {
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateDtoTypes": true,
"injectHttpClient": false,
"disposeHttpClient": true,
"generateExceptionClasses": true,
"exceptionClass": "SwaggerException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": false,
"useBaseUrl": true,
"generateSyncMethods": false,
"clientClassAccessModifier": "public",
"generateContractsOutput": false,
"className": "{controller}Client",
"namespace": "MyNamespace",
"generateOptionalParameters": false,
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTime",
"dateTimeType": "System.DateTime",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.ObjectModel.ObservableCollection",
"dictionaryType": "System.Collections.Generic.Dictionary",
"classStyle": "Inpc",
"operationGenerationMode": "MultipleClientsFromOperationId",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"wrapResponses": false,
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"output": null
},
"swaggerToCSharpController": {
"className": "{controller}",
"namespace": "MyNamespace",
"additionalNamespaceUsages": [
"System.Web.Http"
],
"generateOptionalParameters": false,
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTime",
"dateTimeType": "System.DateTime",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.IEnumerable",
"dictionaryType": "System.Collections.Generic.Dictionary",
"classStyle": "Inpc",
"operationGenerationMode": "MultipleClientsFromOperationId",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"wrapResponses": false,
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"output": null
}
}
}
My Service.Config.Nswag
{
"swaggerGenerator": {
"fromSwagger": {
"url": "http://localhost:22742/swagger/v1/swagger.json",
"output": null
}
},
"codeGenerators": {
"swaggerToTypeScriptClient": {
"className": "{controller}ServiceProxy",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 1.8,
"template": "Angular",
"promiseType": "Promise",
"dateTimeType": "MomentJS",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": false,
"wrapDtoExceptions": false,
"useTransformOptionsMethod": false,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromPathSegments",
"markOptionalProperties": false,
"generateCloneMethod": false,
"typeStyle": "Class",
"extensionCode": "service.extensions.ts",
"generateDefaultValues": true,
"excludedTypeNames": [],
"handleReferences": false,
"generateConstructorInterface": true,
"importRequiredTypes": true,
"baseUrlTokenName": "API_BASE_URL",
"output": "../src/shared/service-proxies/service-proxies.ts"
},
"swaggerToCSharpClient": {
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateDtoTypes": true,
"injectHttpClient": false,
"disposeHttpClient": true,
"generateExceptionClasses": true,
"exceptionClass": "SwaggerException",
"wrapDtoExceptions": true,
"useHttpClientCreationMethod": false,
"httpClientType": "System.Net.Http.HttpClient",
"useHttpRequestMessageCreationMethod": false,
"useBaseUrl": true,
"generateSyncMethods": false,
"clientClassAccessModifier": "public",
"generateContractsOutput": false,
"className": "{controller}Client",
"namespace": "MyNamespace",
"generateOptionalParameters": false,
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTime",
"dateTimeType": "System.DateTime",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.ObjectModel.ObservableCollection",
"dictionaryType": "System.Collections.Generic.Dictionary",
"classStyle": "Inpc",
"operationGenerationMode": "MultipleClientsFromOperationId",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"wrapResponses": false,
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"output": null
},
"swaggerToCSharpController": {
"className": "{controller}",
"namespace": "MyNamespace",
"additionalNamespaceUsages": [
"System.Web.Http"
],
"generateOptionalParameters": false,
"requiredPropertiesMustBeDefined": true,
"dateType": "System.DateTime",
"dateTimeType": "System.DateTime",
"timeType": "System.TimeSpan",
"timeSpanType": "System.TimeSpan",
"arrayType": "System.Collections.Generic.IEnumerable",
"dictionaryType": "System.Collections.Generic.Dictionary",
"classStyle": "Inpc",
"operationGenerationMode": "MultipleClientsFromOperationId",
"generateDefaultValues": true,
"generateDataAnnotations": true,
"excludedTypeNames": [],
"wrapResponses": false,
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"handleReferences": false,
"generateImmutableArrayProperties": false,
"generateImmutableDictionaryProperties": false,
"output": null
}
}
}
Any updates on this?
Seems to me that the operation resolution gets tripped up when controller names contain a subset of other controller names.
Example:
The generated TypeScript has a single client called InvoiceClient with duplicate get, post, patch, delete functions (one set for Invoice and one set for ShipmentInvoice) and will not compile. I would expect separate InvoiceClient and ShipmentInvoiceClient to be generated. There is no inheritance in the POCO objects Invoice and ShipmentInvoice either.
@alexwiese is the generated swagger spec or the clients wrong?
The swagger spec is fine. The client is wrong. I was able to reproduce it. It is caused when there is an underscore in the controller name. If I remove the underscore from Shipment_InvoiceController
it works fine (don't ask why I need underscores).
You can find my repro here: https://github.com/alexwiese/NSwag-1141
Although that appears to be unrelated to the OP's original problem, I can't see underscores in their controller name/path segment. I can open another issue if you like?
Found this while researching a similar issue. Turns out I had additional routes mapped that Swashbuckle was generating actions for (i.e. /api/v1/MyController/MyAction/
and /api/v1/specialRoutePath/MyController/MyAction
)
The Angular service being generated does not differentiate them by path so the action name would conflict with a duplicate using the other path.
I corrected this by making sure the route mapping for /api/v1/specialRoutePath/{controller}/{action}
had explicit controllers to match for the controller
constraint (i.e. if I only want BarController and BazController to use the special route the constraint is as follows controller=@"^(bar|baz)&"
. This way FooController wont match and will only generate for the intended default path.
To clarify, this isn't explicitly an NSwag issue as the 'duplicate' operations can be seen in swagger-ui and is a result of too loose of routing mappings. (At least for my situation)
Can it be that swashbuckle generates non-unique operation ids?
Can it be that swashbuckle generates non-unique operation ids?
I believe so. In my scenario, the routes were too loosely defined thus the same operation would map to multiple routes. I'm not sure I follow what you're getting at.
can i use username & password if URL implemented SwaggerAuthentication?
swagger.json
"/api/identity/roles/{id}": {
"get": {
"tags": [
"Role"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
...
"/api/identity/roles": {
"get": {
"tags": [
"Role"
],
"parameters": [
{
"name": "Filter",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "Sorting",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "SkipCount",
"in": "query",
"schema": {
"maximum": 2147483647,
"minimum": 0,
"type": "integer",
"format": "int32"
}
},
{
"name": "MaxResultCount",
"in": "query",
"schema": {
"maximum": 2147483647,
"minimum": 1,
"type": "integer",
"format": "int32"
}
}
],
with nswag.json
...
"codeGenerators": {
"openApiToTypeScriptClient": {
"template": "Axios",
"operationGenerationMode": "MultipleClientsFromFirstTagAndPathSegments",
...
result:
export class RoleServiceProxy {
private instance: AxiosInstance;
private baseUrl: string;
...
/**
* @return Success
*/
rolesGet(id: string, cancelToken?: CancelToken | undefined): Promise<IdentityRoleDto> {
let url_ = this.baseUrl + "/api/identity/roles/{id}";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
...
/**
* @param filter (optional)
* @param sorting (optional)
* @param skipCount (optional)
* @param maxResultCount (optional)
* @return Success
*/
rolesGet(filter: string | undefined, sorting: string | undefined, skipCount: number | undefined, maxResultCount: number | undefined, cancelToken?: CancelToken | undefined): Promise<PagedResultDto_1OfOfIdentityRoleDtoAndContractsAnd_0AndCulture_neutralAndPublicKeyToken_null> {
let url_ = this.baseUrl + "/api/identity/roles?";
if (filter === null)
throw new Error("The parameter 'filter' cannot be null.");
name conflicts.
Hi, I'm trying to create my service as restful, but when I run Refresh.bat file and run npm start. It gives errors.
Errors:
Service.Swag.Config file:
I have "nswag": "10.6.0" version