Increase OAS description
Parce docstring of http handlers to increase OAS Remove the not expected definitions key in the OAS
This commit is contained in:
29
demo/view.py
29
demo/view.py
@@ -10,25 +10,54 @@ from .model import Error, Pet
|
||||
|
||||
class PetCollectionView(PydanticView):
|
||||
async def get(self, age: Optional[int] = None) -> r200[List[Pet]]:
|
||||
"""
|
||||
List all pets
|
||||
|
||||
Status Codes:
|
||||
200: Successful operation
|
||||
"""
|
||||
pets = self.request.app["model"].list_pets()
|
||||
return web.json_response(
|
||||
[pet.dict() for pet in pets if age is None or age == pet.age]
|
||||
)
|
||||
|
||||
async def post(self, pet: Pet) -> r201[Pet]:
|
||||
"""
|
||||
Add a new pet to the store
|
||||
|
||||
Status Codes:
|
||||
201: Successful operation
|
||||
"""
|
||||
self.request.app["model"].add_pet(pet)
|
||||
return web.json_response(pet.dict())
|
||||
|
||||
|
||||
class PetItemView(PydanticView):
|
||||
async def get(self, id: int, /) -> Union[r200[Pet], r404[Error]]:
|
||||
"""
|
||||
Find a pet by ID
|
||||
|
||||
Status Codes:
|
||||
200: Successful operation
|
||||
404: Pet not found
|
||||
"""
|
||||
pet = self.request.app["model"].find_pet(id)
|
||||
return web.json_response(pet.dict())
|
||||
|
||||
async def put(self, id: int, /, pet: Pet) -> r200[Pet]:
|
||||
"""
|
||||
Update an existing object
|
||||
|
||||
Status Codes:
|
||||
200: Successful operation
|
||||
404: Pet not found
|
||||
"""
|
||||
self.request.app["model"].update_pet(id, pet)
|
||||
return web.json_response(pet.dict())
|
||||
|
||||
async def delete(self, id: int, /) -> r204:
|
||||
"""
|
||||
Deletes a pet
|
||||
"""
|
||||
self.request.app["model"].remove_pet(id)
|
||||
return web.Response(status=204)
|
||||
|
||||
Reference in New Issue
Block a user