Skip to content

Commit 4548156

Browse files
authored
Merge pull request #22 from tmeiczin/tjm/auth
fix auth
2 parents d9ac7bf + 7dbfe43 commit 4548156

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/reliqua/openapi.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ def camelcase(string):
4242
"dict": "object",
4343
}
4444

45+
DEFAULT_RESPONSE = {
46+
"type": "object",
47+
"properties": {
48+
"message": {
49+
"type": "string",
50+
"examples": [
51+
"example message",
52+
],
53+
},
54+
},
55+
}
56+
4557
verbs = ["get", "patch", "put", "post", "delete"]
4658

4759

@@ -222,7 +234,7 @@ def __init__(self, code=None, description=None, content=None, schema=None):
222234
self.code = code
223235
self.description = description
224236
self.content = content or "application/json"
225-
self.schema = schema or "null"
237+
self.schema = schema if schema else "default_response"
226238

227239
def __repr__(self):
228240
"""Return a printable representational string."""
@@ -582,7 +594,9 @@ def __init__(
582594
version=version,
583595
)
584596
self.paths = {}
585-
self.component_schemas = {}
597+
self.component_schemas = {
598+
"default_response": DEFAULT_RESPONSE,
599+
}
586600
self.parser = parser
587601

588602
def process_resources(self, resources):
@@ -609,6 +623,12 @@ def security_schemes(self):
609623

610624
return schema
611625

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+
612632
@property
613633
def components(self):
614634
"""Return components."""
@@ -624,5 +644,5 @@ def schema(self):
624644
"info": self.info.dict(),
625645
"paths": self.paths,
626646
"components": self.components,
627-
"security": [{"BasicAuth": [], "CookieAuth": []}],
647+
"security": self.security_names,
628648
}

0 commit comments

Comments
 (0)