Skip to content

Commit 19453f7

Browse files
author
Ran Isenberg
committed
a
1 parent 70bdf85 commit 19453f7

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

service/handlers/handle_create_order.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from service.handlers.utils.rest_api_resolver import ORDERS_PATH, app
1515
from service.logic.create_order import create_order
1616
from service.models.input import CreateOrderRequest
17-
from service.models.output import CreateOrderOutput, InternalServerErrorOutput
17+
from service.models.output import CreateOrderOutput, InternalServerErrorOutput, InvalidRestApiRequest
1818

1919

2020
@app.post(
@@ -25,11 +25,15 @@
2525
responses={
2626
200: {
2727
'description': 'The created order',
28-
'content': {'application/json': {'schema': {'$ref': '#/components/schemas/CreateOrderOutput'}}},
28+
'content': {'application/json': {'model': CreateOrderOutput}},
29+
},
30+
442: {
31+
'description': 'Invalid create order request',
32+
'content': {'application/json': {'model': InvalidRestApiRequest}},
2933
},
3034
501: {
3135
'description': 'Internal server error',
32-
'content': {'application/json': {'schema': InternalServerErrorOutput.model_json_schema()}},
36+
'content': {'application/json': {'model': InternalServerErrorOutput}},
3337
},
3438
},
3539
tags=['CRUD'],

service/models/output.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List
2+
13
from pydantic import BaseModel
24

35
from service.models.order import Order
@@ -12,3 +14,11 @@ class CreateOrderOutput(Order):
1214

1315
class InternalServerErrorOutput(BaseModel):
1416
error: str = 'internal server error'
17+
18+
19+
class Error(BaseModel):
20+
x: str
21+
22+
23+
class InvalidRestApiRequest(BaseModel):
24+
details: List[Error]

0 commit comments

Comments
 (0)