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
Swagger-UI issues with non-string sequences #386
Comments
You are right, there's not point setting the format for arrays. If you could create a PR for this, this would be great (with a test in |
Will do. ETA is tomorrow |
franklauterwald
pushed a commit
to franklauterwald/tapir
that referenced
this issue
Jan 23, 2020
Fixed in 0.12.17. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for an awesome project. We've recently started playing with it and noticed what we think to be a minor bug in schema generation.
However, this only affects OpenAPI docs. The endpoint itself works fine when curl'ed properly. You just can't test it in the Swagger UI.
Consider this endpoint:
This leads to the following OpenAPI docs to be created (excerpt):
As you can see, the format for ints is repeated for the array type. It is not repeated for strings, because strings do not have a format themselves.
Seemingly, the Swagger UI cannot cope with formats for array types and only provides a single text input field for the int array. It does not show an "Add item" button, making it difficult to test the endpoint via the UI.
I think that setting a format for the array does not make any sense; an array is completely defined by the fact that it is an array and the type of the array elements.
Changing this in Schema.scala, line 37, solves our problem while everything else seems to still work:
I don't know whether this is the right way to approach the issue, but the override of isOptional seems to be there for a similar reason. A comment states: "Also, sets
isOptional
to true as the collection might be empty." Likewise one could say: "Sets format to None because the format of a collection is meaningless. It is determined by its elements"I'll be happy to create a minimal working example and/or pull request if the above is not simple enough to reproduce.
Further info:
The text was updated successfully, but these errors were encountered: