forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_schema.py
More file actions
27 lines (17 loc) · 1.1 KB
/
test_schema.py
File metadata and controls
27 lines (17 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from openapi_python_client.schema import DataType, Schema
def test_nullable_with_simple_type():
schema = Schema.model_validate_json('{"type": "string", "nullable": true}')
assert schema.type == [DataType.STRING, DataType.NULL]
def test_nullable_with_allof():
schema = Schema.model_validate_json('{"allOf": [{"type": "string"}], "nullable": true}')
assert schema.oneOf == [Schema(type=DataType.NULL), Schema(allOf=[Schema(type=DataType.STRING)])]
assert schema.allOf == []
def test_nullable_with_type_list():
schema = Schema.model_validate_json('{"type": ["string", "number"], "nullable": true}')
assert schema.type == [DataType.STRING, DataType.NUMBER, DataType.NULL]
def test_nullable_with_any_of():
schema = Schema.model_validate_json('{"anyOf": [{"type": "string"}], "nullable": true}')
assert schema.anyOf == [Schema(type=DataType.STRING), Schema(type=DataType.NULL)]
def test_nullable_with_one_of():
schema = Schema.model_validate_json('{"oneOf": [{"type": "string"}], "nullable": true}')
assert schema.oneOf == [Schema(type=DataType.STRING), Schema(type=DataType.NULL)]