File tree Expand file tree Collapse file tree 2 files changed +48
-6
lines changed
Expand file tree Collapse file tree 2 files changed +48
-6
lines changed Original file line number Diff line number Diff line change 33version 3.
44https://swagger.io/specification/
55"""
6+
67from abc import ABC
78from dataclasses import dataclass
89from enum import Enum
@@ -118,6 +119,7 @@ class Schema(OpenAPIElement):
118119 format : Union [None , str , ValueFormat ] = None
119120 required : Optional [List [str ]] = None
120121 properties : Optional [Dict [str , Union ["Schema" , "Reference" ]]] = None
122+ additional_properties : Union [None , bool , "Schema" , "Reference" ] = None
121123 default : Optional [Any ] = None
122124 deprecated : Optional [bool ] = None
123125 example : Any = None
Original file line number Diff line number Diff line change @@ -92,8 +92,7 @@ class FooParent:
9292
9393class TestItem :
9494 @abstractmethod
95- def get_instance (self ) -> Any :
96- ...
95+ def get_instance (self ) -> Any : ...
9796
9897 def expected_yaml (self ) -> str :
9998 return dedent (self .yaml ()).strip ()
@@ -102,12 +101,10 @@ def expected_json(self) -> str:
102101 return dedent (self .json ()).strip ()
103102
104103 @abstractmethod
105- def json (self ) -> str :
106- ...
104+ def json (self ) -> str : ...
107105
108106 @abstractmethod
109- def yaml (self ) -> str :
110- ...
107+ def yaml (self ) -> str : ...
111108
112109
113110class ParameterExample1 (TestItem ):
@@ -2050,6 +2047,49 @@ def json(self) -> str:
20502047 """
20512048
20522049
2050+ class ResponseExample2 (TestItem ):
2051+ def get_instance (self ) -> Any :
2052+ return Response (
2053+ description = "A simple string response" ,
2054+ content = {
2055+ "text/plain" : MediaType (
2056+ schema = Schema (
2057+ type = "object" ,
2058+ additional_properties = Schema (type = "string" ),
2059+ )
2060+ )
2061+ },
2062+ )
2063+
2064+ def yaml (self ) -> str :
2065+ return """
2066+ description: A simple string response
2067+ content:
2068+ text/plain:
2069+ schema:
2070+ type: object
2071+ additionalProperties:
2072+ type: string
2073+ """
2074+
2075+ def json (self ) -> str :
2076+ return """
2077+ {
2078+ "description": "A simple string response",
2079+ "content": {
2080+ "text/plain": {
2081+ "schema": {
2082+ "type": "object",
2083+ "additionalProperties": {
2084+ "type": "string"
2085+ }
2086+ }
2087+ }
2088+ }
2089+ }
2090+ """
2091+
2092+
20532093class RequestBodyExample1 (TestItem ):
20542094 def get_instance (self ) -> Any :
20552095 return RequestBody (
You can’t perform that action at this time.
0 commit comments