Accept Python bytes for raw binary payloads#298
Open
p1c2u wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accept Python
bytesfor opaque binary payloads across OAS 3.0, 3.1, and 3.2,implementing the binary-bytes validation design.
Binary detection now lives in one place (
_binary.py) as pure, per-versionpredicates, replacing the old inline
format: binarybranch.bytesacceptanceis confined to the
typekeyword wrapper; the"string"type checker is neverbroadened.
Changes
type: string, format: binaryacceptsbytes(now also enforcesmaxLength/minLengthby octet count).OAS30StrictValidatorstill rejects.contentMediaType, nocontentEncoding) acceptsbytes;type: string+non-text
contentMediaTypeaccepted as a documented pragmatic extension.OAS31StrictValidator/OAS32StrictValidator: preserve JSON Schemastring typing — accept typeless raw binary but reject
byteswhenevertype: stringis asserted.validator_forstill resolves dialect ids to thedefault validators.
maxLength/minLengthenforce octet length for rawbytes;enum/conststay active;
patternshort-circuitsbyteswith noTypeError.contentEncoding, with no-opidentity/binary/7bit/8bitallowlist); media-type parameters strippedand matched case-insensitively.
Migration
In 3.1/3.2,
format: binaryis no longer a binary marker (under 2020-12formatis an annotation).bytesvalidated against a 3.1/3.2{"type": "string", "format": "binary"}schema is now rejected — model rawbinary with
contentMediaType(ideally a typeless schema).