Skip to content

Comments

OAS30 strict validator#251

Merged
p1c2u merged 1 commit intomasterfrom
feature/OAS30-strict-validator
Feb 21, 2026
Merged

OAS30 strict validator#251
p1c2u merged 1 commit intomasterfrom
feature/OAS30-strict-validator

Conversation

@p1c2u
Copy link
Collaborator

@p1c2u p1c2u commented Feb 21, 2026

This pull request introduces a new "strict" validation mode for OpenAPI 3.0 schemas, alongside refining how string and binary types are validated. The main improvement is the addition of OAS30StrictValidator, which enforces the OpenAPI spec more rigorously by not allowing Python bytes for string types or binary formats, and by requiring base64-encoded strings for the binary format. The default validator remains pragmatic and continues to accept Python bytes for compatibility. Extensive tests are added to ensure correct behavior for both modes.

New strict validation mode:

  • Added OAS30StrictValidator and oas30_strict_format_checker, which strictly enforce OpenAPI 3.0 type and format rules, disallowing Python bytes for string types and requiring base64-encoded strings for the binary format. These are now exported in the package API. [1] [2] [3] [4] [5]

Type and format validation logic changes:

  • Refined the default type checker to pragmatically allow Python bytes for "type": "string", "format": "binary", while the strict checker does not. Added new helper functions is_binary_pragmatic and is_binary_strict for these behaviors. [1] [2] [3] [4]
  • Updated the default string type checker to only accept str (not bytes) for plain string types in both modes.

Testing and integration:

  • Added comprehensive tests for the new strict validator, ensuring that it rejects Python bytes for string types and enforces base64 encoding for the binary format. Adjusted existing tests to reflect the stricter type checks. [1] [2] [3] [4] [5] [6]

@p1c2u p1c2u force-pushed the feature/OAS30-strict-validator branch 6 times, most recently from 4770de5 to 0e51608 Compare February 21, 2026 09:51
@p1c2u p1c2u force-pushed the feature/OAS30-strict-validator branch from 0e51608 to af9beaa Compare February 21, 2026 09:54
@p1c2u p1c2u merged commit 7ae386b into master Feb 21, 2026
14 checks passed
@p1c2u p1c2u deleted the feature/OAS30-strict-validator branch February 21, 2026 11:17
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.

1 participant