-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional path parameters generate two operations in the OpenAPI spec #1960
Comments
Example application: |
@loicmathieu It's correct. In openapi specification - you can't set optional path variables |
I mean, you haven't another way to describe optional path variable. Only by two endpoints - with it and without it |
It's annoying as the operationId is generated with an incremented counter which is not very good when we generate a client based on the OpenAPI spec. Is there a way to customize the operationId generated name? |
Hmm.. I understand what you mean. Okay, if you want a different operationId in that case, how do you propose to do this? The only way I see is to come up with some internal extension for the Operation annotation, in which to specify an explicit operation ID, but there is a problem, there can be many optional variables, then there will be many operations. Your suggestions? |
@loicmathieu another way, you can describe 2 different endpoints |
Yes, the problem is that in case a single methods generates two operations, having an operationId in the code (which can already be customized using OpenAPI extension annotation) will not works. We would need a pluggable operationId naming strategy for that.
I don't think so, we have approx a hundred endpoints on 15 different controllers, all can take an optional tenantId in the path for multi-tenancy so we add it in the Worst is that the counter for the operationId is shared for the whole application, it is not for a controller nor an endpoint. |
Ok, one possible solution: I can add a naming strategy for these endpoints. For example:
@loicmathieu WDYT? |
This would be great! For us, the third option is the best, but you can also make it customizable if you don't want to support the third option so we an implement it in our code base. |
I thought again and decided that there is no point in doing the other 2 options. As a result, operationId will now always be generated as in the third option. Wait for the next release |
Great, thank you a lot. |
Expected Behavior
Optional path parameters generate only one operation in the OpenAPI spec with an optional path parameter.
Actual Behaviour
Using the following controller which has an optional
tenantId
path parameter:The following OpenAPI spec is generated with 2 operations:
Steps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version
4.4.4
The text was updated successfully, but these errors were encountered: