|
8 | 8 |
|
9 | 9 |
|
10 | 10 | @pytest.mark.parametrize(
|
11 |
| - "schema", |
| 11 | + "schema,expected", |
12 | 12 | [
|
13 |
| - { |
14 |
| - "type": "object", |
15 |
| - "properties": {"name": {"type": "string"}}, |
16 |
| - "required": ["name"], |
17 |
| - "additionalProperties": True, |
18 |
| - }, |
19 |
| - { |
20 |
| - "type": "object", |
21 |
| - "properties": {"name": {"type": "string"}}, |
22 |
| - }, |
23 |
| - { |
24 |
| - "items": {"type": "integer"}, |
25 |
| - "type": "array", |
26 |
| - "maxLength": 1, |
27 |
| - "minLength": 1, |
28 |
| - }, |
29 |
| - { |
30 |
| - "items": {"type": "integer"}, |
31 |
| - "type": "array", |
32 |
| - }, |
33 |
| - { |
34 |
| - "type": "number", |
35 |
| - }, |
36 |
| - { |
37 |
| - "type": "string", |
38 |
| - }, |
39 |
| - { |
40 |
| - "type": "integer", |
41 |
| - }, |
42 |
| - { |
43 |
| - "type": "boolean", |
44 |
| - }, |
| 13 | + ( |
| 14 | + { |
| 15 | + "type": "object", |
| 16 | + "properties": {"name": {"type": "string"}}, |
| 17 | + "required": ["name"], |
| 18 | + "additionalProperties": True, |
| 19 | + }, |
| 20 | + { |
| 21 | + "type": "object", |
| 22 | + "properties": {"name": {"type": "string"}}, |
| 23 | + "required": ["name"], |
| 24 | + "additionalProperties": True, |
| 25 | + }, |
| 26 | + ), |
| 27 | + ( |
| 28 | + { |
| 29 | + "type": "object", |
| 30 | + "properties": {"name": {"type": "string"}}, |
| 31 | + }, |
| 32 | + { |
| 33 | + "type": "object", |
| 34 | + "properties": {"name": {"type": "string"}}, |
| 35 | + }, |
| 36 | + ), |
| 37 | + ( |
| 38 | + { |
| 39 | + "items": {"type": "integer"}, |
| 40 | + "type": "array", |
| 41 | + "maxLength": 1, |
| 42 | + "minLength": 1, |
| 43 | + }, |
| 44 | + { |
| 45 | + "items": {"type": "integer"}, |
| 46 | + "type": "array", |
| 47 | + "maxLength": 1, |
| 48 | + "minLength": 1, |
| 49 | + }, |
| 50 | + ), |
| 51 | + ( |
| 52 | + { |
| 53 | + "items": {"type": "integer"}, |
| 54 | + "type": "array", |
| 55 | + }, |
| 56 | + { |
| 57 | + "items": {"type": "integer"}, |
| 58 | + "type": "array", |
| 59 | + }, |
| 60 | + ), |
| 61 | + # basic types |
| 62 | + ({"type": "number"}, {"type": "number"}), |
| 63 | + ({"type": "string"}, {"type": "string"}), |
| 64 | + ({"type": "integer"}, {"type": "integer"}), |
| 65 | + ({"type": "boolean"}, {"type": "boolean"}), |
45 | 66 | ],
|
46 | 67 | )
|
47 |
| -def test_map_serializer_field_ok(schema: dict): |
| 68 | +def test_map_serializer_field_ok(schema: Any, expected: Any): |
| 69 | + """Test correct mapping of JSON schema to OpenAPI schema.""" |
| 70 | + |
48 | 71 | json_field = CustomJSONField(schema=schema)
|
49 | 72 | extension = CustomJSONFieldSerializerExtension(json_field)
|
50 | 73 | data = extension.map_serializer_field(Mock(), "response")
|
51 |
| - assert data == schema |
| 74 | + assert data == expected |
52 | 75 |
|
53 | 76 |
|
54 | 77 | @pytest.mark.parametrize(
|
|
0 commit comments