Skip to content

Commit fc32b4e

Browse files
Add additional_properties to the v31 Schema
1 parent e40a1e7 commit fc32b4e

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

openapidocs/v31.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ class Schema(OpenAPIElement):
282282
A list of required property names.
283283
properties (Optional[Dict[str, Union["Schema", "Reference"]]]):
284284
A dictionary of property names to their schemas or references.
285+
additional_properties (Union[None, bool, "Schema", "Reference"]):
286+
Indicates whether additional properties are allowed. If a schema or reference
287+
is provided, it defines the schema of the additional properties.
285288
default (Optional[Any]):
286289
The default value for the schema.
287290
deprecated (Optional[bool]):
@@ -329,6 +332,7 @@ class Schema(OpenAPIElement):
329332
format: Union[None, str, ValueFormat] = None
330333
required: Optional[List[str]] = None
331334
properties: Optional[Dict[str, Union["Schema", "Reference"]]] = None
335+
additional_properties: Union[None, bool, "Schema", "Reference"] = None
332336
default: Optional[Any] = None
333337
deprecated: Optional[bool] = None
334338
example: Any = None

tests/test_v31.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,49 @@ def json(self) -> str:
20742074
"""
20752075

20762076

2077+
class ResponseExample2(TestItem):
2078+
def get_instance(self) -> Any:
2079+
return Response(
2080+
description="A simple string response",
2081+
content={
2082+
"text/plain": MediaType(
2083+
schema=Schema(
2084+
type="object",
2085+
additional_properties=Schema(type="string"),
2086+
)
2087+
)
2088+
},
2089+
)
2090+
2091+
def yaml(self) -> str:
2092+
return """
2093+
description: A simple string response
2094+
content:
2095+
text/plain:
2096+
schema:
2097+
type: object
2098+
additionalProperties:
2099+
type: string
2100+
"""
2101+
2102+
def json(self) -> str:
2103+
return """
2104+
{
2105+
"description": "A simple string response",
2106+
"content": {
2107+
"text/plain": {
2108+
"schema": {
2109+
"type": "object",
2110+
"additionalProperties": {
2111+
"type": "string"
2112+
}
2113+
}
2114+
}
2115+
}
2116+
}
2117+
"""
2118+
2119+
20772120
class RequestBodyExample1(TestItem):
20782121
def get_instance(self) -> Any:
20792122
return RequestBody(

0 commit comments

Comments
 (0)