-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Why required: [] generates an error #651
Comments
Sure sounds like a bug 🐛. Thanks for reporting! |
I don't think this is a bug. The parser in the IDE I use (JetBrains PyCharm) also spits out an error saying the This ticket can be closed, imo. |
The OpenAPI spec section on the
The JSON Schema Validation spec says of the
... which makes pretty clear that specifying an empty array for |
…erators#651) The Pydantic model for OpenAPI schemas in this tool was more stringent about the required key than the OpenAPI / JSON Schema specs themselves, requiring a min_length of 1, when neither of those schemas actually do. This change just removes the min_length constraint on the required field, so that 'required: []' is allowed in inputs to this tool.
Resolves #651 From that issue: The OpenAPI spec [section](https://swagger.io/specification/) on the `Schema` object says: > The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00). > > For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-bhutton-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00). The JSON Schema Validation spec [says](https://json-schema.org/draft/2020-12/json-schema-validation#name-required) of the `required` property: > The value of this keyword MUST be an array. Elements of this array, if any, MUST be strings, and MUST be unique. > > An object instance is valid against this keyword if every item in the array is the name of a property in the instance. > > Omitting this keyword has the same behavior as an empty array. ... which makes pretty clear that specifying an empty array for `required` is supported by JSON Schema, and thus by OpenAPI, and thus should be supported by this tool's model of OpenAPI.
> [!IMPORTANT] > Merging this pull request will create this release ## Fixes - allow required fields list to be specified as empty (#651) (#1149) - import cast for required const properties, since it's used in the template (#1153) Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
this generates an error:
"required": null
do not generates an errorexpected:
are the same and not generates an error
The text was updated successfully, but these errors were encountered: