Skip to content

Commit c6773c9

Browse files
committed
Document intentional OAS 3.1 format compatibility behavior
1 parent 769d20d commit c6773c9

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

docs/unmarshalling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Openapi-core comes with a set of built-in format unmarshallers:
1717
- `uuid` - converts a string into a UUID object,
1818
- `byte` - decodes a Base64-encoded string.
1919

20+
!!! note
21+
22+
For backward compatibility, OpenAPI 3.1 unmarshalling in openapi-core currently supports `byte` and `binary` format handling.
23+
2024
You can also define your own format unmarshallers (See [Extra Format Unmarshallers](configuration.md#extra-format-unmarshallers)).
2125

2226
## Request unmarshalling

docs/validation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Such valid formats can be further unmarshalled (See [Unmarshalling](unmarshallin
1313

1414
Depending on the OpenAPI version, openapi-core comes with a set of built-in format validators such as: `date`, `date-time`, `binary`, `uuid`, or `byte`.
1515

16+
!!! note
17+
18+
For backward compatibility, OpenAPI 3.1 validation in openapi-core currently accepts OpenAPI 3.0-style format checker behavior, including `byte` and `binary`.
19+
1620
You can also define your own format validators (See [Extra Format Validators](configuration.md#extra-format-validators)).
1721

1822
## Request validation

openapi_core/unmarshalling/schemas/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
"uuid": format_uuid,
7777
"byte": format_byte,
7878
}
79+
# NOTE: Intentionally reuse OAS 3.0 format unmarshallers for OAS 3.1/3.2
80+
# to preserve backward compatibility for `byte`/`binary` formats.
81+
# See https://github.com/python-openapi/openapi-core/issues/506
7982
oas31_format_unmarshallers = oas30_format_unmarshallers
8083
oas32_format_unmarshallers = oas31_format_unmarshallers
8184

openapi_core/validation/schemas/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
Proxy(
4242
partial(build_strict_additional_properties_validator, OAS31Validator)
4343
),
44-
# FIXME: OpenAPI 3.1 schema validator uses OpenAPI 3.0 format checker.
44+
# NOTE: Intentionally use OAS 3.0 format checker for OAS 3.1 to preserve
45+
# backward compatibility for `byte`/`binary` formats.
4546
# See https://github.com/python-openapi/openapi-core/issues/506
4647
format_checker=OAS30ReadValidator.FORMAT_CHECKER,
4748
)

tests/integration/unmarshalling/test_unmarshallers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,8 @@ def unmarshallers_factory(self):
19641964

19651965
@pytest.mark.xfail(
19661966
reason=(
1967-
"OpenAPI 3.1 schema validator uses OpenAPI 3.0 format checker."
1967+
"Intentional backward compatibility: OAS 3.1 currently uses "
1968+
"OAS 3.0-style format checker behavior in openapi-core. "
19681969
"See https://github.com/python-openapi/openapi-core/issues/506"
19691970
),
19701971
strict=True,

0 commit comments

Comments
 (0)