You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an API object has a field that is required but has readOnly: true, a request containing an object without that field fails to validate.
OpenAPI spec says:
You can use the readOnly and writeOnly keywords to mark specific properties as read-only or write-only. This is useful, for example, when GET returns more properties than used in POST – you can use the same schema in both GET and POST and mark the extra properties as readOnly. readOnly properties are included in responses but not in requests, [...]
If a readOnly or writeOnly property is included in the required list, required affects just the relevant scope – responses only or requests only. That is, read-only required properties apply to responses only, [...]
This is a regression from Connexion 2.x.
Expected behaviour
Object validates successfully.
Actual behaviour
Object fails to validate, because it is missing a read-only field:
ERROR:connexion.validators.json:Validation error: 'objectId' is a required property
ERROR:connexion.middleware.exceptions:BadRequestProblem(status_code=400, detail="'objectId' is a required property")
Presumably Connexion 3.x fails to use jsonschema validation properly here.
Steps to reproduce
Use the openapi.yaml and testcontroller.py from below
Start with connexion run openapi.yaml --stub
Attempt to do the following request: PUT .../objects/45d2847a-ed55-440a-bfa7-5e759d0d671f, with body
The text was updated successfully, but these errors were encountered:
sampoh0523
changed the title
readOnly and required fields are required in body when they shouldn't be
readOnly and required fields are required in request body when they shouldn't be
Apr 4, 2024
sampoh0523
changed the title
readOnly and required fields are required in request body when they shouldn't be
required readOnly fields are required in request body when they shouldn't be
Apr 4, 2024
Description
When an API object has a field that is required but has readOnly: true, a request containing an object without that field fails to validate.
OpenAPI spec says:
This is a regression from Connexion 2.x.
Expected behaviour
Object validates successfully.
Actual behaviour
Object fails to validate, because it is missing a read-only field:
Presumably Connexion 3.x fails to use jsonschema validation properly here.
Steps to reproduce
connexion run openapi.yaml --stub
Minimal example:
openapi.yaml
testcontroller.py
Additional info:
Output of the commands:
python --version
Python 3.11.3
pip show connexion | grep "^Version\:"
Version: 3.0.6
The text was updated successfully, but these errors were encountered: