From 9b9b22de303ef2075bc3c25c2ee4dc395498340f Mon Sep 17 00:00:00 2001 From: Drew Gallardo Date: Wed, 25 Oct 2023 09:45:49 -0700 Subject: [PATCH] Spec: Fix error response model definition in OpenAPI spec (#8914) --- open-api/rest-catalog-open-api.py | 4 ++ open-api/rest-catalog-open-api.yaml | 81 ++++++++++++++++------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/open-api/rest-catalog-open-api.py b/open-api/rest-catalog-open-api.py index 3bc8574e0cd5..529524025662 100644 --- a/open-api/rest-catalog-open-api.py +++ b/open-api/rest-catalog-open-api.py @@ -461,6 +461,10 @@ class OAuthTokenResponse(BaseModel): class IcebergErrorResponse(BaseModel): + """ + JSON wrapper for all error responses (non-2xx) + """ + class Config: extra = Extra.forbid diff --git a/open-api/rest-catalog-open-api.yaml b/open-api/rest-catalog-open-api.yaml index 29f06ffc746c..ff1984784c9b 100644 --- a/open-api/rest-catalog-open-api.yaml +++ b/open-api/rest-catalog-open-api.yaml @@ -226,7 +226,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NoSuchNamespaceExample: $ref: '#/components/examples/NoSuchNamespaceError' @@ -266,7 +266,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceAlreadyExists: $ref: '#/components/examples/NamespaceAlreadyExistsError' @@ -302,7 +302,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NoSuchNamespaceExample: $ref: '#/components/examples/NoSuchNamespaceError' @@ -334,7 +334,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NoSuchNamespaceExample: $ref: '#/components/examples/NoSuchNamespaceError' @@ -364,7 +364,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NoSuchNamespaceExample: $ref: '#/components/examples/NoSuchNamespaceError' @@ -415,7 +415,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceNotFound: $ref: '#/components/examples/NoSuchNamespaceError' @@ -426,7 +426,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: UnprocessableEntityDuplicateKey: $ref: '#/components/examples/UnprocessableEntityDuplicateKey' @@ -462,7 +462,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceNotFound: $ref: '#/components/examples/NoSuchNamespaceError' @@ -510,7 +510,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceNotFound: $ref: '#/components/examples/NoSuchNamespaceError' @@ -519,7 +519,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceAlreadyExists: $ref: '#/components/examples/TableAlreadyExistsError' @@ -562,7 +562,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceNotFound: $ref: '#/components/examples/NoSuchNamespaceError' @@ -571,7 +571,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: NamespaceAlreadyExists: $ref: '#/components/examples/TableAlreadyExistsError' @@ -637,7 +637,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToLoadDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -691,7 +691,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToUpdateDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -701,7 +701,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' 419: $ref: '#/components/responses/AuthenticationTimeoutResponse' 500: @@ -710,7 +710,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Internal Server Error", @@ -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", @@ -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", @@ -754,7 +754,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Bad Gateway", @@ -792,7 +792,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToDeleteDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -825,7 +825,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToLoadDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -875,7 +875,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToRenameDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -888,7 +888,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: $ref: '#/components/examples/TableAlreadyExistsError' 419: @@ -931,7 +931,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToLoadDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -984,7 +984,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' examples: TableToUpdateDoesNotExist: $ref: '#/components/examples/NoSuchTableError' @@ -994,7 +994,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' 419: $ref: '#/components/responses/AuthenticationTimeoutResponse' 500: @@ -1003,7 +1003,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Internal Server Error", @@ -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", @@ -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", @@ -1047,7 +1047,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Bad Gateway", @@ -2322,6 +2322,7 @@ components: description: Authorization scope for client credentials or token exchange IcebergErrorResponse: + description: JSON wrapper for all error responses (non-2xx) type: object required: - error @@ -2329,6 +2330,14 @@ components: error: $ref: '#/components/schemas/ErrorModel' additionalProperties: false + example: + { + "error": { + "message": "The server does not support this operation", + "type": "UnsupportedOperationException", + "code": 406 + } + } CreateNamespaceResponse: type: object @@ -2450,7 +2459,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Malformed request", @@ -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", @@ -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", @@ -2575,7 +2584,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Credentials have timed out", @@ -2593,7 +2602,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Slow down", @@ -2610,7 +2619,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/ErrorModel' + $ref: '#/components/schemas/IcebergErrorResponse' example: { "error": { "message": "Internal Server Error",