-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Is it possible to order(sort) request methods (POST,GET,PUT,DELETE) in Swagger-UI using swagger-jaxrs2 with Sring boot + Jersey controller API? #3695
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
Comments
I think you need to configure swagger core's Json object mapper Does this work: Declare this anywhere
Configure the Json object mapper for API Operation class ordering
This way you can configure the ordering of any part of the OAS Schema Also if you wish for keys in unordered maps to be sorted:
|
I'm not fully sure how to implement what you mentioned, but I will play around with it to see if I can figure it out when I get some time. Thank you, @swarth100 . |
@swarth100 So your solution worked, somewhat. I only added |
Does adding the |
Seems like a dud. |
I think this is because the Request methods are javax components and not swagger oas components. I'm trying to target the wrong class. |
I am unable to replicate your issue. I forked the latest You can see my changes here https://github.com/swarth100/dropwizard/compare/master...swarth100:check-jaxkson-mixin If I set
The serialised spec is produced with the correct path item property ordering. If I annotate
If I annotate
If I do not annotate
I hope this helps
Unless I misunderstood something all JAX-RS annotations will be scanned by swagger-core and they will be converted into the OAS class structure. In particular HTTP methods will be converted into an instance of |
Do you see the same in Swagger UI? I will try again, but I did everything you did and it sorts by path instead of method. |
@swarth100 I'm pretty sure I'm doing the same thing you are, but I'm just not getting the results in the Swagger-UI. Everything is being sorted by path by |
Hey @tGuichin, As the issue only seems to occur when using Swagger UI, and as the spec's order is indeed configurable I am driven to think the problem might reside within some part of the spring/swagger UI DTOs. I think you might find the best guidance to your problems on their issue boards. I'm sure you've come across this issue already, but I think it could be a start (even though it's JS): swagger-api/swagger-ui#4158 (comment) I believe swagger-UI ordering and configuration must reside in the instantiation of the swagger ui bundle EDIT: It seems like support for |
springdoc-openapi is different from swagger-jaxrs2 as far as I know. I will do some more research and see what else I can find. Thank you. |
Now that I look at the UI closer, it looks like the endpoints are sorted first alphabetically by path, then by method GET, POST, PUT, DELETE in that order. |
Along with the solutions mentioned in comments in this ticket, a solution has been implemented in #3740, see PR comment for details and usage scenarios. Additionally the current issue discussed seems to be related to swagger UI and should be reported there. |
Currently the swagger-jaxrs2 generated Swagger-UI has no order for each "GET", "PUT", "POST"... etc method. It randomly spits the endpoints out as it pleases. Is there a way to sort them? I tried using
@JsonPropertyOrder({"POST","GET","PUT","DELETE"})
, which is the order I would like them in, but to no success. Also tried@JsonPropertyOrder(alphabetic = true)
. This annotation was included in the Jersey Controller class.I'm using:
The text was updated successfully, but these errors were encountered: