connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Validate required fields based on readOnly & writeOnly

Open whoseoyster opened this issue 1 year ago • 13 comments

Fixes https://github.com/spec-first/connexion/issues/1907.

Changes proposed in this pull request:

  • Add required and readOnly validators to the Draft4ResponseValidator and Draft4RequestValidator objects

Let me know if anything else needs adjustments.

whoseoyster avatar Jun 26 '24 00:06 whoseoyster

This regresses #942. readOnly should not result in a HTTP 400 when the field is present, since OpenAPI only says that the field "SHOULD NOT be sent as part of the request", not "MUST NOT".

Arguably the same should apply for writeOnly, but the user can at least control the responses they sent back, yet they cannot control what API clients will do.

(To fix #942 here, all one needs to do is make validate_readOnly a no-op. It cannot be removed from the validator map, however, without changing how validate_required detects it.)

sampoh0523 avatar Mar 12 '25 12:03 sampoh0523