Default x-operation-name To Controller Method Name
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Currently the generated operationId in the OpenAPI spec follows this pattern: <Controller Class Name>_<Controller Class Method Name>
.
This in itself is probably a good thing. But then when I use ng-openapi-gen it will generate a method from the exact operationId.
So for my findAll()
GET method of my CatsController
class it will generate me an Angular service with the following method name: catsControllerFindAll()
.
Expected behavior
The current behavior is undesirable because the catsControllerFindAll()
method belongs to my CatsApiService
. So it would be much better if findAll()
method would be generated in my CatsApiService
Fortunately ng-openapi-gen
can support this using the x-operation-name
tag. See here about the x-operation-name tag
So what I am asking is the following:
- By default, set the
x-operation-name
tag to be just the name of the method. So for myfindAll()
GET method of myCatsController
, the x-operation-name tag would have a value offindAll
. - Add
xOperationName
to the options object of the@ApiOperation()
decorator. And if thexOperationName
is specified, then set thex-operation-name
tag to the value specified.
What is the motivation / use case for changing the behavior?
I kind of already explained the motivation with my previous example. The motivation is to make the generated API services in Angular spit out more friendly method names.
Environment
Nest version: 6.14.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top GitHub Comments
I’ve seen this has been fixed here: #747
We can make this configurable. Would you like to create a PR for this?