File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
openapi_schema_pydantic/v3/v3_1_0 Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
+ ## v1.2.2 - Unreleased
4
+
5
+ ### Fixed
6
+ - [ 4] ( https://github.com/kuimono/openapi-schema-pydantic/issues/4 ) Allow ` Schema ` type ` additionalProperties ` field to be boolean
7
+
8
+
3
9
## v1.2.1 - 2021-09-10
4
10
5
11
### Added
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ class Schema(BaseModel):
243
243
object.
244
244
"""
245
245
246
- additionalProperties : Optional [Union [Reference , "Schema" ]] = None
246
+ additionalProperties : Optional [Union [Reference , "Schema" , bool ]] = None
247
247
"""
248
248
The value of "additionalProperties" MUST be a valid JSON Schema.
249
249
Original file line number Diff line number Diff line change 1
1
import logging
2
2
3
+ from pydantic import BaseModel , Extra
4
+ from pydantic .schema import schema
5
+
3
6
from openapi_schema_pydantic import Schema , Reference
4
7
5
8
@@ -16,3 +19,30 @@ def test_schema():
16
19
assert isinstance (schema .allOf , list )
17
20
assert isinstance (schema .allOf [0 ], Reference )
18
21
assert schema .allOf [0 ].ref == "#/definitions/TestType"
22
+
23
+
24
+ def test_issue_4 ():
25
+ """https://github.com/kuimono/openapi-schema-pydantic/issues/4"""
26
+
27
+ class TestModel (BaseModel ):
28
+ test_field : str
29
+
30
+ class Config :
31
+ extra = Extra .forbid
32
+
33
+ schema_definition = schema ([TestModel ])
34
+ assert schema_definition == {
35
+ "definitions" : {
36
+ "TestModel" : {
37
+ "title" : "TestModel" ,
38
+ "type" : "object" ,
39
+ "properties" : {"test_field" : {"title" : "Test Field" , "type" : "string" }},
40
+ "required" : ["test_field" ],
41
+ "additionalProperties" : False ,
42
+ }
43
+ }
44
+ }
45
+
46
+ # allow "additionalProperties" to have boolean value
47
+ result = Schema .parse_obj (schema_definition ["definitions" ]["TestModel" ])
48
+ assert result .additionalProperties is False
You can’t perform that action at this time.
0 commit comments