This commit is contained in:
@ -3,7 +3,7 @@ import logging
|
||||
import json
|
||||
from xeger import Xeger
|
||||
from flask_restful import Resource
|
||||
from flask import request, jsonify
|
||||
from flask import request
|
||||
import requests
|
||||
from db import db
|
||||
from models import SampleMetadata
|
||||
@ -28,6 +28,8 @@ class SampleResource(Resource):
|
||||
Sample endpoint
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=Input%20Service
|
||||
"""
|
||||
samplemetadatas_schema = SampleMetadata(many=True,
|
||||
exclude=['id', 'device_id', 'device_date', 'tag', 'timestamp'])
|
||||
|
||||
def post(self):
|
||||
"""
|
||||
@ -58,7 +60,7 @@ class SampleResource(Resource):
|
||||
validate_errors = SampleSchema().validate(desc)
|
||||
if validate_errors:
|
||||
LOGGER.error(
|
||||
"Input JSON did not conform to schema. It was: {}", desc)
|
||||
"Input JSON did not conform to schema. It was: {}".format(desc))
|
||||
return {'err_msg': 'Input JSON schema invalid'}, 417
|
||||
|
||||
xeger = Xeger(limit=30)
|
||||
@ -105,6 +107,8 @@ class SampleParameterResource(Resource):
|
||||
Sample endpoint with parameters
|
||||
"""
|
||||
|
||||
samplemetadata_schema = SampleMetadata(many=False)
|
||||
|
||||
def get(self, tag: str):
|
||||
"""
|
||||
Get a specific item
|
||||
@ -112,4 +116,4 @@ class SampleParameterResource(Resource):
|
||||
:return:
|
||||
"""
|
||||
sample = SampleMetadata.query.filter_by(tag=tag).first_or_404()
|
||||
return sample, 200
|
||||
return self.samplemetadata_schema.dump(sample), 200
|
||||
|
Reference in New Issue
Block a user