Skip to content

Commit

Permalink
Spec: Fix error response model definition in OpenAPI spec (#8914)
Browse files Browse the repository at this point in the history
  • Loading branch information
geruh authored Oct 25, 2023
1 parent c10a4d0 commit 9b9b22d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 36 deletions.
4 changes: 4 additions & 0 deletions open-api/rest-catalog-open-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ class OAuthTokenResponse(BaseModel):


class IcebergErrorResponse(BaseModel):
"""
JSON wrapper for all error responses (non-2xx)
"""

class Config:
extra = Extra.forbid

Expand Down
81 changes: 45 additions & 36 deletions open-api/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NoSuchNamespaceExample:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand Down Expand Up @@ -266,7 +266,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceAlreadyExists:
$ref: '#/components/examples/NamespaceAlreadyExistsError'
Expand Down Expand Up @@ -302,7 +302,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NoSuchNamespaceExample:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand Down Expand Up @@ -334,7 +334,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NoSuchNamespaceExample:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand Down Expand Up @@ -364,7 +364,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NoSuchNamespaceExample:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand Down Expand Up @@ -415,7 +415,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceNotFound:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand All @@ -426,7 +426,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
UnprocessableEntityDuplicateKey:
$ref: '#/components/examples/UnprocessableEntityDuplicateKey'
Expand Down Expand Up @@ -462,7 +462,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceNotFound:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand Down Expand Up @@ -510,7 +510,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceNotFound:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand All @@ -519,7 +519,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceAlreadyExists:
$ref: '#/components/examples/TableAlreadyExistsError'
Expand Down Expand Up @@ -562,7 +562,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceNotFound:
$ref: '#/components/examples/NoSuchNamespaceError'
Expand All @@ -571,7 +571,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
NamespaceAlreadyExists:
$ref: '#/components/examples/TableAlreadyExistsError'
Expand Down Expand Up @@ -637,7 +637,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToLoadDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand Down Expand Up @@ -691,7 +691,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToUpdateDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand All @@ -701,7 +701,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
419:
$ref: '#/components/responses/AuthenticationTimeoutResponse'
500:
Expand All @@ -710,7 +710,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Internal Server Error",
Expand All @@ -726,7 +726,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Invalid response from the upstream server",
Expand All @@ -740,7 +740,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Gateway timed out during commit",
Expand All @@ -754,7 +754,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Bad Gateway",
Expand Down Expand Up @@ -792,7 +792,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToDeleteDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand Down Expand Up @@ -825,7 +825,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToLoadDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand Down Expand Up @@ -875,7 +875,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToRenameDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand All @@ -888,7 +888,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example:
$ref: '#/components/examples/TableAlreadyExistsError'
419:
Expand Down Expand Up @@ -931,7 +931,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToLoadDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand Down Expand Up @@ -984,7 +984,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToUpdateDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
Expand All @@ -994,7 +994,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
419:
$ref: '#/components/responses/AuthenticationTimeoutResponse'
500:
Expand All @@ -1003,7 +1003,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Internal Server Error",
Expand All @@ -1019,7 +1019,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Invalid response from the upstream server",
Expand All @@ -1033,7 +1033,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Gateway timed out during commit",
Expand All @@ -1047,7 +1047,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Bad Gateway",
Expand Down Expand Up @@ -2322,13 +2322,22 @@ components:
description: Authorization scope for client credentials or token exchange

IcebergErrorResponse:
description: JSON wrapper for all error responses (non-2xx)
type: object
required:
- error
properties:
error:
$ref: '#/components/schemas/ErrorModel'
additionalProperties: false
example:
{
"error": {
"message": "The server does not support this operation",
"type": "UnsupportedOperationException",
"code": 406
}
}

CreateNamespaceResponse:
type: object
Expand Down Expand Up @@ -2450,7 +2459,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Malformed request",
Expand All @@ -2467,7 +2476,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Not authorized to make this request",
Expand All @@ -2483,7 +2492,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Not authorized to make this request",
Expand Down Expand Up @@ -2575,7 +2584,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Credentials have timed out",
Expand All @@ -2593,7 +2602,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Slow down",
Expand All @@ -2610,7 +2619,7 @@ components:
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorModel'
$ref: '#/components/schemas/IcebergErrorResponse'
example: {
"error": {
"message": "Internal Server Error",
Expand Down

0 comments on commit 9b9b22d

Please sign in to comment.