Skip to content

Validate required fields based on readOnly & writeOnly #1943

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

whoseoyster
Copy link

Fixes #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.

@sampoh0523
Copy link

sampoh0523 commented Mar 12, 2025

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

required readOnly fields are required in request body when they shouldn't be
2 participants