Skip to content

Commit fa04453

Browse files
committed
add a structured error response
1 parent cd99115 commit fa04453

File tree

1 file changed

+89
-30
lines changed

1 file changed

+89
-30
lines changed

neurostore-openapi.yml

Lines changed: 89 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,72 @@ paths:
15431543
$ref: '#/components/responses/404'
15441544
components:
15451545
schemas:
1546+
ErrorDetail:
1547+
type: object
1548+
required:
1549+
- code
1550+
- message
1551+
properties:
1552+
field:
1553+
type: string
1554+
description: Field name that caused the error
1555+
example: "source"
1556+
code:
1557+
type: string
1558+
description: Machine-readable error code
1559+
example: "INVALID_VALUE"
1560+
message:
1561+
type: string
1562+
description: Human-readable error message
1563+
example: "invalid source, choose from: 'neurostore'"
1564+
context:
1565+
type: object
1566+
description: Additional error context
1567+
additionalProperties: true
1568+
1569+
ErrorResponse:
1570+
type: object
1571+
required:
1572+
- status
1573+
- title
1574+
- detail
1575+
- timestamp
1576+
- request_id
1577+
properties:
1578+
status:
1579+
type: integer
1580+
description: HTTP status code
1581+
example: 400
1582+
title:
1583+
type: string
1584+
description: Short, human-readable summary
1585+
example: "Bad Request"
1586+
detail:
1587+
type: string
1588+
description: Human-readable explanation
1589+
example: "The request contains invalid parameters"
1590+
type:
1591+
type: string
1592+
description: URI reference for error type
1593+
default: "about:blank"
1594+
instance:
1595+
type: string
1596+
description: URI reference for specific occurrence
1597+
example: "/api/studies/123"
1598+
errors:
1599+
type: array
1600+
description: Field-specific validation errors
1601+
items:
1602+
$ref: '#/components/schemas/ErrorDetail'
1603+
timestamp:
1604+
type: string
1605+
format: date-time
1606+
description: ISO 8601 timestamp
1607+
request_id:
1608+
type: string
1609+
description: Unique request identifier
1610+
example: "a1b2c3d4"
1611+
15461612
pipeline:
15471613
type: object
15481614
properties:
@@ -2576,43 +2642,36 @@ components:
25762642
$ref: '#/components/schemas/metadata'
25772643
responses:
25782644
'404':
2579-
description: Example response
2645+
description: Not Found
25802646
content:
25812647
application/json:
25822648
schema:
2583-
type: object
2584-
properties:
2585-
detail:
2586-
type: string
2587-
example: '"The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."'
2588-
status:
2589-
type: integer
2590-
enum:
2591-
- 404
2592-
title:
2593-
type: string
2594-
example: '"Not Found"'
2595-
type:
2596-
type: string
2597-
example: '"about:blank"'
2649+
$ref: '#/components/schemas/ErrorResponse'
2650+
examples:
2651+
notFound:
2652+
value:
2653+
status: 404
2654+
title: "Not Found"
2655+
detail: "The requested URL was not found on the server."
2656+
type: "about:blank"
2657+
timestamp: "2025-01-01T00:00:00Z"
2658+
request_id: "req-1234"
25982659
'422':
2599-
description: Example response
2660+
description: Unprocessable Entity
26002661
content:
26012662
application/json:
26022663
schema:
2603-
type: object
2604-
properties:
2605-
detail:
2606-
type: string
2607-
example: The request was well-formed but was unable to be followed due to semantic errors.
2608-
status:
2609-
type: integer
2610-
title:
2611-
type: string
2612-
example: Unprocessable Entity
2613-
type:
2614-
type: string
2615-
example: 'about:blank'
2664+
$ref: '#/components/schemas/ErrorResponse'
2665+
examples:
2666+
unprocessable:
2667+
value:
2668+
status: 422
2669+
title: "Unprocessable Entity"
2670+
detail: "The request was well-formed but was unable to be followed due to semantic errors."
2671+
type: "about:blank"
2672+
timestamp: "2025-01-01T00:00:00Z"
2673+
request_id: "req-1234"
2674+
errors: []
26162675
parameters:
26172676
search:
26182677
name: search

0 commit comments

Comments
 (0)