-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
SmallRye OpenAPI 3.6.2 changes contract for post/put/delete/patch when consumes/produces content type is not defined #36297
Comments
/cc @EricWittmann (openapi), @Ladicek (smallrye), @MikeEdgar (openapi), @jmartisk (smallrye), @phillip-kruger (openapi,smallrye), @radcortez (smallrye) |
I don't understand why expected type is Is expected / actual behavior according to how endpoints behave? Isn't actual type closer to
|
This issue is about content generated through open api (http://localhost:8080/q/dev-ui/io.quarkus.quarkus-smallrye-openapi/schema-yaml) Spring Web extension is just about API, so the defaults are the same as with Quarkus "native" REST endpoints.
Adjusted the title and description to be more explicit about generated schema yaml file content. |
OpenAPI document establishes contract, therefore I expect it to tell me exactly what is expected to accept. Why should it default to
I adjusted
for Spring Web endpoint, both requests are accepted, therefore it is not same?
Still accepts any content type:
|
In SmallRye OpenAPI , the default type when not specified is This was the case for a while, until a bug was logged that there is a mismatch with the default when the response type is a primitive or String, and in that case the response type should be As with any defaults, there will be cases where the default is not what a user want, and they need to add an annotation to create what they want. The default is just trying to cover the usual case. W.r.t consume vs produce, on the RESTEasy side of things, the Produce (response type) is fairly straight forward to decide the type, as it's based on the response type as described above. For the consume (input parameters) it's a bit different. The RestEasy extension does not have to set any value of the response matching this, and in most cases the parameters are define in the path, query or form parameters, so the only case where we try to set this automatically is in the case of the body in a POST/PUT. After some discussion it was decided to leave this default as What we did realized with this effort is that we need to decide if we are doing sensible defaults, or if we want to correctly set the value automatically. The latter is much more involved and would need some collaboration between open api and resteasy extensions. // cc @cescoffier @geoand @FroMage |
I discussed the matter with @phillip-kruger yesterday, and his summary is totally accurate. The generated openapi descriptor must be align with what RestEasy (reactive) is doing. Otherwise it would break (like it did) swagger and discard almost all usage of the descriptor. We also discussed that in a first step we will only fix String. Then we will create a test case to discuss the other types (primitives, buffer, json objects/array, file, byebuff, byte[]....). We may need to introduce new build item to give to RR a way to indicate the types/media types to openapi. |
Thanks folks. For sure, let's make things easier for OpenAPI and more correct for users! |
Disable checks related to quarkusio/quarkus#36297
This reverts commit 938c2b2.
Fixed in #36514, closing |
Describe the bug
SmallRye OpenAPI 3.6.2 (introduced in #36279) changes generated contract in yaml schema file (text/plain vs. application/json) for post/put/delete/patch when consumes/produces primitives and content type is not explicitly defined
After fixing #34700 through #36198 the default content type was
text/plain
for primitives. This was true for response and also request content type.I'm using simple endpoint that works with String - https://github.com/quarkus-qe/beefy-scenarios/blob/main/603-spring-web-smallrye-openapi/src/main/java/org/acme/spring/web/PostController.java#L13
I would expect the behaviour that was before SmallRye OpenAPI 3.6.2 merge, where request and response in generated schema yaml file were on the same content type (
text/plain
) when working with String.Expected behavior
Actual behavior
How to Reproduce?
Run https://github.com/quarkus-qe/beefy-scenarios/blob/main/603-spring-web-smallrye-openapi app in dev mode
Open http://localhost:8080/q/dev-ui/io.quarkus.quarkus-smallrye-openapi/schema-yaml
Search for
/post/no-type:
Output of
uname -a
orver
macOS
Output of
java -version
Java 17
GraalVM version (if different from Java)
No response
Quarkus version or git rev
841b3a1
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: