OAS 3.1.0 output: maxLength
constraint not saved to schema for nullable string field
#1302
Labels
bug
Something isn't working
fix confirmation pending
issue has been fixed and confirmation from issue reporter is pending
Describe the bug
We have several string fields in our API that are nullable (i.e., optional), but also have a max length. When using OAS 3.0.3 as the target schema version, this works fine, however with OAS 3.1.0, no
maxLength
is stored. For non-nullable fields,maxLength
is stored properly.I expect more constraints (e.g.,
minLength
should be obvious) are also dropped from the schema. Format specifiers (such astype: email
),readOnly
,writeOnly
and probably other specs work fine for nullable fields across OpenAPI versions, so there must be something special about constraint handling.To Reproduce
Python code:
Excerpt from generated OAS 3.0.3 schema:
Same excerpt from generated OAS 3.1.0 schema:
Expected behavior
Expected output should include
maxLength
constraint.If I understand the OpenAPI specs correctly (hints taken from this OpenAPI Spec question), this concise form should be fine:
If you want to be more explicit, this should work as well:
The text was updated successfully, but these errors were encountered: