Skip to content

Commit

Permalink
added support for custom json content types
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed Sep 14, 2023
1 parent aa3cd66 commit 9786060
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/openapi_parser/enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class CookieParameterStyle(Enum):
@unique
class ContentType(Enum):
JSON = 'application/json'
JSON_TEXT = 'text/json'
JSON_ANY = 'application/*+json'
XML = 'application/xml'
FORM = 'application/x-www-form-urlencoded'
MULTIPART_FORM = 'multipart/form-data'
Expand Down
13 changes: 13 additions & 0 deletions tests/builders/test_content_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ def _get_schema_factory_mock(expected_value: Schema) -> SchemaFactory:
],
_get_schema_factory_mock(string_schema)
),
(
{
"text/json": {
"schema": {
"type": "string"
}
}
},
[
Content(type=ContentType.JSON_TEXT, schema=string_schema)
],
_get_schema_factory_mock(string_schema)
),
)


Expand Down
2 changes: 2 additions & 0 deletions tests/test_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def test_parameter_location_error() -> None:

media_type_provider = (
("application/json", ContentType.JSON),
("application/*+json", ContentType.JSON_ANY),
("text/json", ContentType.JSON_TEXT),
("application/xml", ContentType.XML),
("application/x-www-form-urlencoded", ContentType.FORM),
("multipart/form-data", ContentType.MULTIPART_FORM),
Expand Down

0 comments on commit 9786060

Please sign in to comment.