Fix swagger roles issue

master
esensar 2018-09-23 13:56:41 +02:00
parent bea29b4e42
commit 6b76520cc7
5 changed files with 79 additions and 2 deletions

View File

@ -18,7 +18,7 @@ class RoleUpdateSchema(Schema):
class RoleSchema(Schema):
role_id = fields.Integer(required=True, location='json')
id = fields.Integer(required=True, location='json')
display_name = fields.String(required=True, location='json')
permissions = fields.List(fields.String, required=True,
location='json', many=True)
@ -63,9 +63,9 @@ class RoleResource(ProtectedResource):
class RolesResource(ProtectedResource):
@requires_permission('CREATE_ROLE', 'Role creation')
@use_args(RoleCreationWrapperSchema())
@swag_from('swagger/create_role_spec.yaml')
@requires_permission('CREATE_ROLE', 'Role creation')
def post(self, args):
args = args['role']
success = accounts.create_role(args['display_name'],

View File

@ -0,0 +1,19 @@
Creates new role
Requires Role object and creates role
---
tags:
- Role
parameters:
- in: body
name: body
required: true
schema:
type: object
required:
- role
properties:
device:
$ref: '#/definitions/Role'
responses:
201:
description: Successful creation

View File

@ -0,0 +1,21 @@
Gets a role
---
tags:
- Role
parameters:
- in: path
name: role_id
required: true
type: integer
description: Id of the role
responses:
200:
description: Success
schema:
type: object
required:
- role
properties:
device:
$ref: '#/definitions/Role'

View File

@ -0,0 +1,16 @@
Gets all roles
---
tags:
- Role
responses:
200:
description: Success
schema:
type: object
required:
- roles
properties:
devices:
type: array
items:
$ref: '#/definitions/Role'

View File

@ -7,6 +7,11 @@ basePath: ""
definitions:
genericname:
type: string
description: name
default: name
username:
type: string
description: User's name in the system
@ -91,6 +96,22 @@ definitions:
email:
$ref: '#/definitions/email'
Role:
type: object
required:
- id
- display_name
- permissions
properties:
id:
$ref: '#/definitions/id'
display_name:
$ref: '#/definitions/genericname'
permissions:
type: array
items:
$ref: '#definitions/genericname'
Recording:
type: object
required: