Open RoXuS opened 3 years ago
Hello @RoXuS
Can you share part of schema where contains original searchConsumption
and "duplicate" searchConsumption
?
And which version of swagger schema are you using ?
Just currently I'm not see a problem with local version.
@RoXuS did you see this message on console output ? Module "{moduleName}" already have method "{methodName}()"
?
No we don't have this log. Our schema:
"post": {
"tags": [
"credit-operation-api"
],
"operationId": "searchConsumption",
"parameters": [
{
"name": "organizationId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"filters": {
"$ref": "#/components/schemas/CreditOperationFilters"
},
"pageable": {
"$ref": "#/components/schemas/Pageable"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/hal+json": {
"schema": {
"$ref": "#/components/schemas/CreditPageCreditConsumptionDto"
}
}
}
},
"400": {
"description": "Bad Request"
}
}
}
},
@RoXuS I hope that this problem was fixed in 5.0.0 :)
If not please reopen issue or ping me here
hey,
with 5.0.0, the error remains, for example
/**
* No description
*
* @tags credit-operation-api
* @name SearchConsumption1
* @request POST:/me/organization/credits/search-consumption
* @secure
*/
searchConsumption1 = (
data: CreditOperationFilters,
query?: { page?: number; size?: number; sort?: string[] },
params: RequestParams = {},
) => ...
For info our two different schema:
"/organizations/{organizationId}/credits/search-consumption": {
"post": {
"tags": [
"credit-operation-api"
],
"operationId": "searchConsumption",
"parameters": [
{
"name": "organizationId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "page",
"in": "query",
"description": "Zero-based page index (0..N)",
"schema": {
"type": "integer",
"default": 0
}
},
{
"name": "size",
"in": "query",
"description": "The size of the page to be returned",
"schema": {
"type": "integer",
"default": 20
}
},
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreditOperationFilters"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/hal+json": {
"schema": {
"$ref": "#/components/schemas/CreditPageCreditConsumptionDto"
}
}
}
},
"400": {
"description": "Bad Request"
}
}
}
}
```
"/me/organization/credits/search-consumption": {
"post": {
"tags": [
"credit-operation-api"
],
"operationId": "searchConsumption_1",
"parameters": [
{
"name": "page",
"in": "query",
"description": "Zero-based page index (0..N)",
"schema": {
"type": "integer",
"default": 0
}
},
{
"name": "size",
"in": "query",
"description": "The size of the page to be returned",
"schema": {
"type": "integer",
"default": 20
}
},
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreditOperationFilters"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/hal+json": {
"schema": {
"$ref": "#/components/schemas/CreditPageCreditConsumptionDto"
}
}
}
},
"400": {
"description": "Bad Request"
}
}
}
},
```
Thx for your 5.0.0!
other info
seems to keep increment through the files.
Hi @RoXuS !
Can you message all operations ids ("operationId"
field) of this execureSearch
operations ?
Just I think ending number it is a part of "operationId"
field
like searchConsumption_1
Yeah we have
"/me/organization/credits/search-consumption": {
"post": {
"tags": [
"credit-operation-api"
],
"operationId": "searchConsumption_1",
"parameters": [
{
...
For example.
So the issue is on our swagger generator ?
@RoXuS If you don't see this message
It means that the number endings goes from "operationId" field
I'll try to fix that at next release.
Definetely swagger-typescript-api codegenerator should crop _1
, _2
, _{n}
in "operationId"
Currently, as quick solution you can customize route name with hook onCreateRouteName()
(version 5.1.0)
We will wait your new version, np.
Thx!!
Here is my temporary solution as @js2me suggested
onCreateRouteName: (nameInfo, rawInfo) => {
nameInfo.original = nameInfo.original.replace(/\d+$/, '')
nameInfo.usage = nameInfo.usage.replace(/\d+$/, '')
},
Just faced this issue with following config:
import { generateApi } from 'swagger-typescript-api';
import { resolve } from 'node:path';
void generateApi({
url: 'https://my-domain.tld/api/v3/api-docs',
output: resolve(process.cwd(), 'src/shared/api'),
name: 'generated',
generateClient: true,
httpClientType: 'axios',
});
solution from @amankkg is working for me
Several of our methods has a number after there name:
Ok we have this method in another class but not in the same class. We generate API with
modular
.