|
15 | 15 | router = AioHttpRouter() |
16 | 16 |
|
17 | 17 |
|
18 | | -@router.post("/authors", tags=["Authors"], status_code=201, response_model=AuthorSchema) |
| 18 | +@router.post( |
| 19 | + "/authors", |
| 20 | + tags=["Authors"], |
| 21 | + status_code=201, |
| 22 | + response_errors=[400, 422, 500], |
| 23 | + response_model=AuthorSchema, |
| 24 | +) |
19 | 25 | async def create_author(body: CreateAuthorSchema) -> AuthorSchema: |
20 | 26 | return await author_service.create_author(body) |
21 | 27 |
|
22 | 28 |
|
23 | | -@router.get("/authors/{author_id}", tags=["Authors"], response_model=AuthorSchema) |
| 29 | +@router.get( |
| 30 | + "/authors/{author_id}", |
| 31 | + tags=["Authors"], |
| 32 | + response_errors=[400, 404, 500], |
| 33 | + response_model=AuthorSchema, |
| 34 | +) |
24 | 35 | async def get_author(author_id: int) -> AuthorSchema: |
25 | 36 | author = await author_service.get_author(author_id) |
26 | 37 | if not author: |
27 | 38 | raise web.HTTPNotFound(reason="Author not found") |
28 | 39 | return author |
29 | 40 |
|
30 | 41 |
|
31 | | -@router.get("/authors/", tags=["Authors"], response_model=list[AuthorSchema]) |
| 42 | +@router.get( |
| 43 | + "/authors/", |
| 44 | + tags=["Authors"], |
| 45 | + response_errors=[500], |
| 46 | + response_model=list[AuthorSchema], |
| 47 | +) |
32 | 48 | async def get_authors(body: FilterAuthorSchema) -> list[AuthorSchema]: |
33 | 49 | return await author_service.get_authors(body) |
34 | 50 |
|
35 | 51 |
|
36 | | -@router.delete("/authors/{author_id}", tags=["Authors"], status_code=204) |
| 52 | +@router.delete( |
| 53 | + "/authors/{author_id}", |
| 54 | + tags=["Authors"], |
| 55 | + status_code=204, |
| 56 | + response_errors=[400, 404, 500], |
| 57 | +) |
37 | 58 | async def delete_author(author_id: int) -> None: |
38 | 59 | author = await author_service.delete_author(author_id) |
39 | 60 | if not author: |
40 | 61 | raise web.HTTPNotFound(reason="Author not found") |
41 | 62 |
|
42 | 63 |
|
43 | | -@router.patch("/authors/{author_id}", tags=["Authors"], response_model=AuthorSchema) |
| 64 | +@router.patch( |
| 65 | + "/authors/{author_id}", |
| 66 | + tags=["Authors"], |
| 67 | + response_errors=[400, 404, 422, 500], |
| 68 | + response_model=AuthorSchema, |
| 69 | +) |
44 | 70 | async def update_author(author_id: int, body: UpdateAuthorSchema) -> AuthorSchema: |
45 | 71 | author = await author_service.update_author(author_id, body) |
46 | 72 | if not author: |
|
0 commit comments