Use new error format for auth errors (factor exceptions into module)
This commit is contained in:
parent
9c08717173
commit
eba75494d9
25 changed files with 214 additions and 177 deletions
|
@ -3,7 +3,6 @@
|
|||
import re
|
||||
import logging
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from flask.ext.restful import reqparse
|
||||
|
||||
|
@ -180,24 +179,50 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
if response_schema_name:
|
||||
models[response_schema_name] = view_class.schemas[response_schema_name]
|
||||
|
||||
models['ApiError'] = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'status': {
|
||||
'type': 'integer'
|
||||
},
|
||||
'type': {
|
||||
'type': 'string'
|
||||
},
|
||||
'detail': {
|
||||
'type': 'string'
|
||||
},
|
||||
'title': {
|
||||
'type': 'string'
|
||||
}
|
||||
},
|
||||
'required': [
|
||||
'status',
|
||||
'type',
|
||||
'title',
|
||||
]
|
||||
}
|
||||
|
||||
responses = {
|
||||
'400': {
|
||||
'description': 'Bad Request'
|
||||
'description': 'Bad Request',
|
||||
},
|
||||
|
||||
'401': {
|
||||
'description': 'Session required'
|
||||
'description': 'Session required',
|
||||
},
|
||||
|
||||
'403': {
|
||||
'description': 'Unauthorized access'
|
||||
'description': 'Unauthorized access',
|
||||
},
|
||||
|
||||
'404': {
|
||||
'description': 'Not found'
|
||||
'description': 'Not found',
|
||||
},
|
||||
}
|
||||
|
||||
for status, body in responses.items():
|
||||
body['schema'] = {'$ref': '#/definitions/ApiError'}
|
||||
|
||||
if method_name == 'DELETE':
|
||||
responses['204'] = {
|
||||
'description': 'Deleted'
|
||||
|
|
Reference in a new issue