-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Add examples field to schema objects, or allow reference objects in example fields #1404
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
The Putting an example in the Schema object doesn't make a lot of sense as the format can change based on the media type that's being used. Because Schema objects are not linked to a media type, describing different ones would have been cumbersome. We kept the |
In JSON Schema draft-06/wright-01 (the next one after the one OAI 3.0 uses) we added Otherwise, if you update JSON Schema versions again you'll probably want to forbid that. But one reason we left the array values unconstrained was to see what people would do with it other than put literal values in it. The media type thing hadn't occurred to me but seems pretty reasonable. |
I'm going to close this out given that it's more than two years since the last answers on the thread. Note that with OAS 3.1 updating to the latest JSON Schema, there is an |
Currently, example objects can be referenced from the
examples
fields of parameter objects and media type objects, but not from the mutually exclusiveexample
fields of those objects, or from schema objects.It's not obvious why schema objects are different, and in fact putting a
$ref
in a schema object'sexample
field nearly works in swagger-ui. (Likely it also works with parameter objects and media type objects, although I haven't tested that.)It would be nice if this was supported, or if not, if the rationale was clearly documented in the schema object section of the spec and in the
example
entries in the field tables.(There's also the confusing Examples Object section of the spec -- not to be confused with the Example Object section, singular -- which states:
But it looks like the plural version's been removed in 3.0.1.)
The text was updated successfully, but these errors were encountered: