@@ -42,6 +42,18 @@ def camelcase(string):
42
42
"dict" : "object" ,
43
43
}
44
44
45
+ DEFAULT_RESPONSE = {
46
+ "type" : "object" ,
47
+ "properties" : {
48
+ "message" : {
49
+ "type" : "string" ,
50
+ "examples" : [
51
+ "example message" ,
52
+ ],
53
+ },
54
+ },
55
+ }
56
+
45
57
verbs = ["get" , "patch" , "put" , "post" , "delete" ]
46
58
47
59
@@ -222,7 +234,7 @@ def __init__(self, code=None, description=None, content=None, schema=None):
222
234
self .code = code
223
235
self .description = description
224
236
self .content = content or "application/json"
225
- self .schema = schema or "null "
237
+ self .schema = schema if schema else "default_response "
226
238
227
239
def __repr__ (self ):
228
240
"""Return a printable representational string."""
@@ -582,7 +594,9 @@ def __init__(
582
594
version = version ,
583
595
)
584
596
self .paths = {}
585
- self .component_schemas = {}
597
+ self .component_schemas = {
598
+ "default_response" : DEFAULT_RESPONSE ,
599
+ }
586
600
self .parser = parser
587
601
588
602
def process_resources (self , resources ):
@@ -609,6 +623,12 @@ def security_schemes(self):
609
623
610
624
return schema
611
625
626
+ @property
627
+ def security_names (self ):
628
+ """Return security list."""
629
+ authenticators = [x for y in self .auth for x in y .authenticators ]
630
+ return {x .name : [] for x in authenticators }
631
+
612
632
@property
613
633
def components (self ):
614
634
"""Return components."""
@@ -624,5 +644,5 @@ def schema(self):
624
644
"info" : self .info .dict (),
625
645
"paths" : self .paths ,
626
646
"components" : self .components ,
627
- "security" : [{ "BasicAuth" : [], "CookieAuth" : []}] ,
647
+ "security" : self . security_names ,
628
648
}
0 commit comments