diff --git a/app/api/resources/swagger/create_device_spec.yaml b/app/api/resources/swagger/create_device_spec.yaml index 1bb1850..900789a 100644 --- a/app/api/resources/swagger/create_device_spec.yaml +++ b/app/api/resources/swagger/create_device_spec.yaml @@ -13,7 +13,7 @@ parameters: - device properties: device: - $ref: '#/definitions/Device' + $ref: '#/definitions/DeviceCreation' responses: 201: description: Successful creation diff --git a/app/api/resources/swagger/get_device_types_spec.yaml b/app/api/resources/swagger/get_device_types_spec.yaml index 47dfbe1..2caa5a6 100644 --- a/app/api/resources/swagger/get_device_types_spec.yaml +++ b/app/api/resources/swagger/get_device_types_spec.yaml @@ -2,6 +2,21 @@ Gets all device types --- tags: - DeviceType +parameters: + - in: path + name: page + required: false + schema: + type: integer + minimum: 1 + description: requested page + - in: path + name: per_page + required: false + schema: + type: integer + minimum: 1 + description: requested items per page responses: 200: description: Success diff --git a/app/api/resources/swagger/get_devices_spec.yaml b/app/api/resources/swagger/get_devices_spec.yaml index 2aed5c1..1dd9789 100644 --- a/app/api/resources/swagger/get_devices_spec.yaml +++ b/app/api/resources/swagger/get_devices_spec.yaml @@ -2,6 +2,21 @@ Gets all associated devices --- tags: - Device +parameters: + - in: path + name: page + required: false + schema: + type: integer + minimum: 1 + description: requested page + - in: path + name: per_page + required: false + schema: + type: integer + minimum: 1 + description: requested items per page responses: 200: description: Success @@ -14,4 +29,3 @@ responses: type: array items: $ref: '#/definitions/Device' - diff --git a/app/devices/models.py b/app/devices/models.py index 88a5632..bed15a9 100644 --- a/app/devices/models.py +++ b/app/devices/models.py @@ -138,7 +138,8 @@ class Device(db.Model): * configuration (useless) """ - return Device.query.filter_by(**kwargs).all() + return Device.query.filter_by(**kwargs).paginate( + None, None, False).items @staticmethod def get_many_for_user(account_id): @@ -147,7 +148,7 @@ class Device(db.Model): """ return Device.query.filter( Device.users.any(account_id=account_id) - ).all() + ).paginate(None, None, False).items @staticmethod def get(**kwargs): @@ -260,7 +261,8 @@ class DeviceType(db.Model): * id * name """ - return DeviceType.query.filter_by(**kwargs).all() + return DeviceType.query.filter_by(**kwargs).paginate( + None, None, False).items @staticmethod def get(**kwargs): diff --git a/app/swagger/template.yaml b/app/swagger/template.yaml index cb0dd17..b9b1e04 100644 --- a/app/swagger/template.yaml +++ b/app/swagger/template.yaml @@ -122,6 +122,17 @@ definitions: device_type: $ref: '#/definitions/DeviceType' + DeviceCreation: + type: object + required: + - name + - device_type_id + properties: + name: + $ref: '#/definitions/devicename' + device_type_id: + $ref: '#/definitions/id' + UnauthorizedError: type: object required: