Skip to content

Detail for schema of array object #2867

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

Closed
fforfabio opened this issue Jan 20, 2025 · 5 comments
Closed

Detail for schema of array object #2867

fforfabio opened this issue Jan 20, 2025 · 5 comments
Labels
question Further information is requested

Comments

@fforfabio
Copy link

When I go under the schema tab inside the endpoint, if the object of the response or the request body is an array, the openapi show array <object> as root and Items as object of the array instead of the actual schema

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 3.4.1
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-starter-webmvc-ui version 2.8.3

Expected behavior
My expectation is that when I change the tab from Example value to Schema if the object is an array, the schema must show that it is an array of a specific object.

If the object is not an array but a single one, there is no problem.

Until SpringBoot 3.3.5 this problem is not present (see the last screenshot)

Screenshots
As below the example correctly report that the returned object for a 400 Bad Request is an array, with possible multiple object with schema ApiError

Image

When change to the schema I don't see that the array is made of ApiError objects:

Image

Whit SpringBoot 3.3.5 everything is ok:

Image

@ydrozhdzhal
Copy link

Looks like this question is caused by this issue.

@Mattias-Sehlstedt
Copy link

This is not an error as far as I am aware, but it is rather how Swagger visualizes OpenAPI 3.1 specifications.

swaggerdoc-openapi switch the default version that is exposed here https://github.com/springdoc/springdoc-openapi/releases/tag/v2.8.0 with "2790 - Moving to OpenAPI 3.1 as the default implementation for springdoc-openapi".

You can see the difference visualized here https://editor-next.swagger.io/ when you select the OpenAPI 3.1 Petstore example by selecting File -> Load Example in the top left.

Image

Expand the "Items" property and you should see that the content is still the same as before with errorCode and errorDescription.

@ydrozhdzhal
Copy link

I do not understand why is it expected and is not an issue? Content in OpenAPI JSON looks fine and correct, but I can't see it rendered correct in web UI. For our project this is not acceptable. In case it can be fixed or configured somehow - will think of moving out from this library and never come back.

@Mattias-Sehlstedt
Copy link

If you find it to be an issue then you should raise it to swagger-ui, which should be the part that visualizes the specification.

If you want to keep the old behavior, then you can set springdoc.api-docs.version=openapi_3_0
in your properties file and then the old 3.0 way of visualizing a specification should occur.

@ydrozhdzhal
Copy link

@Mattias-Sehlstedt , thank you for provided solution - it resolved our issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants