Пример #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)
Пример #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
     })
Пример #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)
Пример #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)
Пример #5
0
 def on_post(self, request):
     return OpenAPIJSONResponse([request.content['id'], request.content['file_name']])
Пример #6
0
 def on_get(self, request):
     return OpenAPIJSONResponse(store.get_pet(request.path_params['id']))
Пример #7
0
 def on_post(self, request):
     return OpenAPIJSONResponse(store.new_pet(request.content['name']))
Пример #8
0
 def on_get(self, request):
     return OpenAPIJSONResponse([pet for pet in store])
Пример #9
0
def listPets(request):
    limit = request.query_params.get('limit')
    if limit is not None:
        return OpenAPIJSONResponse(pets[:limit])
    return OpenAPIJSONResponse(pets)