-
Notifications
You must be signed in to change notification settings - Fork 112
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
Enforce strict key values for BTreeMap with enum key #128
Comments
Would have to look more into this. But in any case the IndexMap or more specifically the Schemars::Map should be preferred. I also think this part is handled by Schemars and not by Okapi. As everything under |
If you want to have a look at the issue the BTreeMap implementation is here: https://github.com/GREsau/schemars/blob/master/schemars/src/json_schema_impls/maps.rs |
Great, thanks for the info, @ralpha! I'll take a look to see if I can get a PR in for a fix. |
I've started a PR, but I don't think I'll have the time to properly grok this to get it working properly. If anyone wants to pick up where I left off, that would be rad, but I understand there are other priorities. |
@ralpha I've opened a PR for this, I'd appreciate a review! GREsau/schemars#231 |
Whenever a schema is generated for a BTreeMap with an enum value as the key, the result allows any string for the key. For example:
generates:
This allows the
reply
object to have any key, when it should really be limited to the enum values. Something like:I don't know if there's any other way to limit the possible key values for an object, other than using the
oneOf
property, but being able to limit potential keys of a spec using a BTreeMap would be really helpfulThe text was updated successfully, but these errors were encountered: