-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
impl JsonSchema for serde_json::Value #33
Comments
Schemars is doing the right thing here, as "type" is not a required property in JSON Schema or OpenAPI 3 Schema objects (as confirmed in OAI/OpenAPI-Specification#1657). Swagger UI seems to handle this ok in my opinion - the property doesn't appear in the example, but this would be fixed by GREsau/okapi#11. And to be honest I don't think it's much better when we include all types in "anyOf": I don't think these slightly odd behaviours in third-party UIs are enough to warrant adding workarounds in Schemars. If you do want to include all types in an "anyOf" for any schemas without a "type", you can do this in your application by writing a |
The current implementation for
impl JsonSchema for Value
where Value is serde_json::Value does not work well.https://github.com/GREsau/schemars/blob/master/schemars/src/json_schema_impls/serdejson.rs
Because this is a very special type it might be tricky.
Currently when this value is included in a response it will not set a type.
When a description is given it will set that. But that is about it.
The 'value' variable is the serde_json::Value type in the screenshot below.
Because of this UI's have a hard time parsing this.
RapiDoc: (an okay response)
Swagger UI: (Does not even acknowledge it, but in schema it is better)
I know these are issues with UI's and not Schemars. And the Spec does not really give any option for this.
But maybe we can use "allOf", "oneOf", "anyOf" to allow all types ("integer", "number", "string" and "boolean"). This will make sure there is at least something good there.
The text was updated successfully, but these errors were encountered: