Skip to content

Commit 0976655

Browse files
authored
Merge pull request #381 from Jdubrick/update-feedback-responses
Update feedback responses to match road core
2 parents 15e691f + 2f13263 commit 0976655

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

docs/openapi.json

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,16 @@
302302
},
303303
"responses": {
304304
"200": {
305-
"description": "Successful Response",
305+
"description": "Feedback received and stored",
306306
"content": {
307307
"application/json": {
308308
"schema": {
309309
"$ref": "#/components/schemas/FeedbackResponse"
310310
}
311311
}
312-
},
313-
"response": "Feedback received and stored"
312+
}
314313
},
315-
"400": {
314+
"401": {
316315
"description": "Missing or invalid credentials provided by client",
317316
"content": {
318317
"application/json": {
@@ -323,7 +322,7 @@
323322
}
324323
},
325324
"403": {
326-
"description": "User is not authorized",
325+
"description": "Client does not have permission to access resource",
327326
"content": {
328327
"application/json": {
329328
"schema": {
@@ -332,6 +331,16 @@
332331
}
333332
}
334333
},
334+
"500": {
335+
"description": "User feedback can not be stored",
336+
"content": {
337+
"application/json": {
338+
"schema": {
339+
"$ref": "#/components/schemas/ErrorResponse"
340+
}
341+
}
342+
}
343+
},
335344
"422": {
336345
"description": "Validation Error",
337346
"content": {
@@ -1181,6 +1190,37 @@
11811190
"title": "DatabaseConfiguration",
11821191
"description": "Database configuration."
11831192
},
1193+
"ErrorResponse": {
1194+
"properties": {
1195+
"detail": {
1196+
"additionalProperties": {
1197+
"type": "string"
1198+
},
1199+
"type": "object",
1200+
"title": "Detail"
1201+
}
1202+
},
1203+
"type": "object",
1204+
"required": [
1205+
"detail"
1206+
],
1207+
"title": "ErrorResponse",
1208+
"description": "Model representing error response for query endpoint.",
1209+
"examples": [
1210+
{
1211+
"detail": {
1212+
"cause": "Failed to handle request to https://bam-api.res.ibm.com/v2/text",
1213+
"response": "Error while validation question"
1214+
}
1215+
},
1216+
{
1217+
"detail": {
1218+
"cause": "Invalid conversation ID 1237-e89b-12d3-a456-426614174000",
1219+
"response": "Error retrieving conversation history"
1220+
}
1221+
}
1222+
]
1223+
},
11841224
"FeedbackCategory": {
11851225
"type": "string",
11861226
"enum": [

src/app/endpoints/feedback.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from auth.interface import AuthTuple
1212
from configuration import configuration
1313
from models.responses import (
14+
ErrorResponse,
1415
FeedbackResponse,
1516
StatusResponse,
1617
UnauthorizedResponse,
@@ -23,17 +24,23 @@
2324
router = APIRouter(prefix="/feedback", tags=["feedback"])
2425
auth_dependency = get_auth_dependency()
2526

26-
# Response for the feedback endpoint
2727
feedback_response: dict[int | str, dict[str, Any]] = {
28-
200: {"response": "Feedback received and stored"},
29-
400: {
28+
200: {
29+
"description": "Feedback received and stored",
30+
"model": FeedbackResponse,
31+
},
32+
401: {
3033
"description": "Missing or invalid credentials provided by client",
3134
"model": UnauthorizedResponse,
3235
},
3336
403: {
34-
"description": "User is not authorized",
37+
"description": "Client does not have permission to access resource",
3538
"model": ForbiddenResponse,
3639
},
40+
500: {
41+
"description": "User feedback can not be stored",
42+
"model": ErrorResponse,
43+
},
3744
}
3845

3946

src/models/responses.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,28 @@ class ConversationsListResponse(BaseModel):
470470
]
471471
}
472472
}
473+
474+
475+
class ErrorResponse(BaseModel):
476+
"""Model representing error response for query endpoint."""
477+
478+
detail: dict[str, str]
479+
480+
model_config = {
481+
"json_schema_extra": {
482+
"examples": [
483+
{
484+
"detail": {
485+
"response": "Error while validation question",
486+
"cause": "Failed to handle request to https://bam-api.res.ibm.com/v2/text",
487+
},
488+
},
489+
{
490+
"detail": {
491+
"response": "Error retrieving conversation history",
492+
"cause": "Invalid conversation ID 1237-e89b-12d3-a456-426614174000",
493+
},
494+
},
495+
]
496+
}
497+
}

0 commit comments

Comments
 (0)