-
Notifications
You must be signed in to change notification settings - Fork 23
OpenAPI Filter force its order to prevent flickering #373
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
Conversation
@MikeEdgar @phillip-kruger i wonder if I should open a quarkus ticket? It would be great if the I think we need to give the SmallRye Health the same treatment. If all filters are 1 we get "flickering" OpenAPI generation so it looks like it changes on every build with no code changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to give the SmallRye Health the same treatment. If all filters are 1 we get "flickering" OpenAPI generation so it looks like it changes on every build with no code changes.
Do you mean that they are running in random order because they have the same priority?
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-openapi-spi</artifactId> | ||
<artifactId>quarkus-smallrye-openapi-deployment</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why deployment? @OpenApiFilter
is in the runtime library.
<artifactId>quarkus-smallrye-openapi-deployment</artifactId> | |
<artifactId>quarkus-smallrye-openapi</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deployment modules usually depend on other extension's deployment modules
Correct so I use both this extension and SmallRye Health which both add private List<String> getUserDefinedFilters(IndexView index, OpenApiFilter.RunStage stage) {
EnumSet<OpenApiFilter.RunStage> stages = EnumSet.of(OpenApiFilter.RunStage.BOTH, stage);
Comparator<Object> comparator = Comparator
.comparing(x -> ((AnnotationInstance) x).valueWithDefault(index, "priority").asInt())
.reversed();
return index
.getAnnotations(OpenApiFilter.class)
.stream()
.filter(ai -> stages.contains(OpenApiFilter.RunStage.valueOf(ai.valueWithDefault(index).asEnum())))
.sorted(comparator)
.map(ai -> ai.target().asClass())
.filter(c -> c.interfaceNames().contains(DotName.createSimple(OASFilter.class.getName())))
.map(c -> c.name().toString())
.collect(Collectors.toCollection(ArrayList::new));
} |
Yeah, adding the fully-qualified class name to that comparator seems reasonable to me. |
OK that would be better than me hacking around! Let me submit a PR to Quarkus |
PR submitted: quarkusio/quarkus#47779 |
Because this just uses the default priority = 1 and so does the Health API they can flicker back and forth in the generated OpenAPI docs.
cc @phillip-kruger