Renamed devices to components

This commit is contained in:
Joel Collins 2020-01-13 11:08:05 +00:00
parent 6b99873d53
commit 4003e4e65c
11 changed files with 60 additions and 50 deletions

View file

@ -148,22 +148,31 @@ tag = Tag
class doc_response(object):
def __init__(self, code, description=None, **kwargs):
def __init__(self, code, description=None, mimetype=None, **kwargs):
self.code = code
self.description = description
self.kwargs = kwargs
self.mimetype = mimetype
self.response_dict = {
"responses": {
self.code: {
"description": self.description or HTTPStatus(self.code).phrase,
**self.kwargs,
}
}
}
if self.mimetype:
self.response_dict.update({
"responses": {
self.code: {
"content": {self.mimetype: {}}
}
}
})
def __call__(self, f):
# Pass params to call function attribute for external access
update_spec(
f,
{
"responses": {
self.code: {
"description": self.description or HTTPStatus(self.code).phrase,
**self.kwargs,
}
}
},
)
update_spec(f, self.response_dict)
return f