-
-
Notifications
You must be signed in to change notification settings - Fork 525
Regression: @Header(schema = @Schema(type = "string"))
generates empty or broken schema in OpenAPI output since 2.8.0
#2972
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
Update / New Finding: I've discovered that the issue described above does not occur when I explicitly set the OpenAPI version to 3.0 using the following configuration:
|
Hi, This is most likely, as you yourself have already seen, due to your application producing an OpenAPI 3.1 specification. The default specification that springdoc produces was changed in 2.8.0 (#2790). If you revert to 3.0.1 (as you have already described) then I assume it would retain the previous behavior. What could be reason for the issues with 3.1 is that swagger-core has introduced So you could investigate if setting |
Hi Mattias,
Yes, I've noticed that now too ;) Interesting decision by SpringDoc to switch from OpenAPI 3.0 to 3.1 in a minor version update... I really didn't expect that.
Yes, we can do that. It would take a lot of effort because we have many services distributed across multiple teams, but I prefer the
Thanks for the insight. Unfortunately, I'm not familiar with the internals of SpringDoc. However, from a user perspective, I expect
|
springdoc-openapi relies a lot on swagger-core when it comes to converting code into a specification. What swagger-core offers is the annotations as well as introspection of these that are then collected in their OpenAPI object. I have debugged the issue and to me it does not seem to be a behavior that should reside in So the current best approach would be to revert the OpenAPI schema version if it is too large of an overhead to adjust the Schema annotation to match the new OpenAPI specification It could also be possible to inject some extra behavior to adjust the default behavior, but again, maybe too much work for no real gain unless you really want 3.1 for its extra features. |
As explained by @Mattias-Sehlstedt this is related to the current swagger-core implementation. Please log an issue for the swagger-core team to keep the compatibility. |
Description:
In versions prior to 2.8.0 of springdoc-openapi, using
@Header
with@Schema(type = "string")
correctly generated the expected schema in the OpenAPI documentation.However, starting with 2.8.0, the generated schema became incorrect, and as of 2.8.6 it results in a completely empty schema.
Reproducer Example:
Expected OpenAPI Output (as seen with 2.7.0):
Actual Output:
Workaround:
Switching to
implementation = String.class
fixes the issue:This produces the correct OpenAPI YAML again.
Environment:
Additional Notes:
This seems to be a regression introduced in 2.8.0. The schema handling for headers appears to be broken when using
type = "string"
, which previously worked. The problem did not exist in 2.7.0.Please let me know if you need a full minimal sample project to reproduce.
The text was updated successfully, but these errors were encountered: