Beispiel #1
0
def showPetById(request):
    pet_id = request.path_params['petId']
    pet = get_pet_by_id(pet_id)
    if pet is None:
        return OpenAPIResponse(status_code=404)

    return OpenAPIJSONResponse(pet)
Beispiel #2
0
 def on_post(self, request):
     return OpenAPIJSONResponse({
         'file': 'Hello human',
         'input_decoded_file': request.content['file'].read().decode('utf-8')
     }, headers={
         'X-Rate-Limit-Limit': 10,
         'X-Rate-Limit-Remaining': 10,
         'X-Rate-Limit-Reset': 10
     })
Beispiel #3
0
    def on_delete(self, request):
        try:
            store.delete_pet(request.path_params['id'])
        except KeyError:
            return OpenAPIJSONResponse({
                'code': 314,
                'message': "Pet already deleted"
            }, status_code=500)

        return OpenAPIResponse(status_code=204)
Beispiel #4
0
 def on_get(self, request):
     from collections import Mapping  # noqa
     x = request.query_params['x']
     return OpenAPIJSONResponse(dict(x) if isinstance(x, Mapping) else x)
Beispiel #5
0
 def on_post(self, request):
     return OpenAPIJSONResponse([request.content['id'], request.content['file_name']])
Beispiel #6
0
 def on_get(self, request):
     return OpenAPIJSONResponse(store.get_pet(request.path_params['id']))
Beispiel #7
0
 def on_post(self, request):
     return OpenAPIJSONResponse(store.new_pet(request.content['name']))
Beispiel #8
0
 def on_get(self, request):
     return OpenAPIJSONResponse([pet for pet in store])
Beispiel #9
0
def listPets(request):
    limit = request.query_params.get('limit')
    if limit is not None:
        return OpenAPIJSONResponse(pets[:limit])
    return OpenAPIJSONResponse(pets)