-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Required field in Schema Object is redefined #794
Comments
I didn't find any use of the boolean For the schema object, the
All examples in the spec for a schema are string-arrays. I don't see how you can argue that a boolean For what is more intuitive, this can be argued ... one argument for having it in the parent object is that the same schema can be used in in several parent objects, and in one of them it could be mandatory, in the other one not. (Though already the description is a bit conflicting, it can be a description of the schema or a description of a property in a schema.) |
Uops, seems like I read wrong, those big horizontal lines confused me. The counterargument to that is that you can override objects from the parent. Because the reference method is by defining a dictionary who has a
Finally, in the swagger spec, you are parameters are defined like I suggest:
|
This is not a bug. For JSON schema draft 4, the |
Reading the Swagger Spec, when reading about
Schema Object
, the document says which list of properties are taken from the document.In this specific case, the problem is that
required
doesn't even have a description in the spec (http://json-schema.org/latest/json-schema-validation.html).However, for some reason in the swagger docs it has two colliding definitions.
The first one is the one that anyone would think on,
required
is a boolean that says if the object it belongs to is required or not.The second one,
required
is a list of children node names that are required.Just in case, this dual behaviour is not specified anywhere in the docs, and is just through examples that I have understood this.
The main problem is that if you put required that the Swagger editor like:
It doesn't work, you need to put it as
I understand that the reason behind that undocumented behaviour is to be able to support something like the following:
However, I don't see the need, as we could perfectly do:
Which IMO makes way more sense, it is more intuitive, and helps cohesion. Indeed, it is more compliant with the json schema spec.
Therefore, I propose to deprecate
required
's use as a list in that way, to start using it as a boolean.The text was updated successfully, but these errors were encountered: