From 08b1293619258368aa2f8c7ebdecb640bdaa8537 Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Fri, 15 Nov 2024 11:31:51 -0800 Subject: [PATCH] feat: individual error objects for gnap errors --- openapi/auth-server.yaml | 126 +++++++++++++----- .../openapi/generated/auth-server-types.ts | 100 +++++++++----- 2 files changed, 162 insertions(+), 64 deletions(-) diff --git a/openapi/auth-server.yaml b/openapi/auth-server.yaml index c39660d6..5a908924 100644 --- a/openapi/auth-server.yaml +++ b/openapi/auth-server.yaml @@ -77,19 +77,21 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + oneOf: + - $ref: '#/components/schemas/error-invalid-request' + - $ref: '#/components/schemas/error-invalid-client' '401': description: Unauthorized content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-invalid-client' '500': description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-request-denied' requestBody: content: application/json: @@ -213,19 +215,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + oneOf: + - $ref: '#/components/schemas/error-too-fast' + - $ref: '#/components/schemas/error-invalid-client' '401': description: Unauthorized content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + oneOf: + - $ref: '#/components/schemas/error-invalid-client' + - $ref: '#/components/schemas/error-invalid-continuation' + - $ref: '#/components/schemas/error-request-denied' '404': description: Not Found content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + oneOf: + - $ref: '#/components/schemas/error-invalid-continuation' + - $ref: '#/components/schemas/error-invalid-request' requestBody: content: application/json: @@ -250,24 +259,21 @@ paths: responses: '204': description: No Content - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/gnap-error' '401': description: Unauthorized content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + oneOf: + - $ref: '#/components/schemas/error-invalid-client' + - $ref: '#/components/schemas/error-invalid-continuation' + - $ref: '#/components/schemas/error-invalid-request' '404': description: Not Found content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-invalid-request' description: Cancel a grant request or delete a grant client side. tags: - grant @@ -318,19 +324,25 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-invalid-rotation' '401': description: Unauthorized content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-invalid-client' '404': description: Not Found content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-invalid-rotation' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/error-request-denied' description: Management endpoint to rotate access token. tags: - token @@ -341,18 +353,18 @@ paths: responses: '204': description: No Content - '400': - description: Bad Request + '401': + description: Unauthorized content: application/json: schema: - $ref: '#/components/schemas/gnap-error' - '401': - description: Unauthorized + $ref: '#/components/schemas/error-invalid-client' + '500': + description: Internal Server Error content: application/json: schema: - $ref: '#/components/schemas/gnap-error' + $ref: '#/components/schemas/error-request-denied' tags: - token components: @@ -588,7 +600,7 @@ components: - debitAmount - required: - receiveAmount - gnap-error: + error-invalid-client: type: object properties: error: @@ -599,15 +611,67 @@ components: code: type: string enum: - - invalid_request - invalid_client - - invalid_interaction - - invalid_rotation - - invalid_continuation - - user_denied + error-invalid-request: + type: object + properties: + error: + type: object + properties: + description: + type: string + code: + type: string + enum: + - invalid_request + error-request-denied: + type: object + properties: + error: + type: object + properties: + description: + type: string + code: + type: string + enum: - request_denied - - unknown_interaction - - too_fast + error-too-fast: + type: object + properties: + error: + type: object + properties: + description: + type: string + code: + type: string + enum: + - too_fast + error-invalid-continuation: + type: object + properties: + error: + type: object + properties: + description: + type: string + code: + type: string + enum: + - invalid_continuation + error-invalid-rotation: + type: object + properties: + error: + type: object + properties: + description: + type: string + code: + type: string + enum: + - invalid_rotation securitySchemes: GNAP: name: Authorization diff --git a/packages/open-payments/src/openapi/generated/auth-server-types.ts b/packages/open-payments/src/openapi/generated/auth-server-types.ts index b0c33937..64d7b757 100644 --- a/packages/open-payments/src/openapi/generated/auth-server-types.ts +++ b/packages/open-payments/src/openapi/generated/auth-server-types.ts @@ -172,18 +172,40 @@ export interface components { receiveAmount?: external["schemas.yaml"]["components"]["schemas"]["amount"]; interval?: components["schemas"]["interval"]; }; - "gnap-error": { + "error-invalid-client": { error?: { description?: string; - code?: - | "invalid_request" - | "invalid_client" - | "invalid_interaction" - | "invalid_rotation" - | "invalid_continuation" - | "user_denied" - | "request_denied" - | "unknown_interaction - too_fast"; + code?: "invalid_client"; + }; + }; + "error-invalid-request": { + error?: { + description?: string; + code?: "invalid_request"; + }; + }; + "error-request-denied": { + error?: { + description?: string; + code?: "request_denied"; + }; + }; + "error-too-fast": { + error?: { + description?: string; + code?: "too_fast"; + }; + }; + "error-invalid-continuation": { + error?: { + description?: string; + code?: "invalid_continuation"; + }; + }; + "error-invalid-rotation": { + error?: { + description?: string; + code?: "invalid_rotation"; }; }; }; @@ -211,19 +233,21 @@ export interface operations { /** Bad Request */ 400: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": + | components["schemas"]["error-invalid-request"] + | components["schemas"]["error-invalid-client"]; }; }; /** Unauthorized */ 401: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-client"]; }; }; /** Internal Server Error */ 500: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-request-denied"]; }; }; }; @@ -259,19 +283,26 @@ export interface operations { /** Bad Request */ 400: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": + | components["schemas"]["error-too-fast"] + | components["schemas"]["error-invalid-client"]; }; }; /** Unauthorized */ 401: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": + | components["schemas"]["error-invalid-client"] + | components["schemas"]["error-invalid-continuation"] + | components["schemas"]["error-request-denied"]; }; }; /** Not Found */ 404: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": + | components["schemas"]["error-invalid-continuation"] + | components["schemas"]["error-invalid-request"]; }; }; }; @@ -297,22 +328,19 @@ export interface operations { responses: { /** No Content */ 204: never; - /** Bad Request */ - 400: { - content: { - "application/json": components["schemas"]["gnap-error"]; - }; - }; /** Unauthorized */ 401: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": + | components["schemas"]["error-invalid-client"] + | components["schemas"]["error-invalid-continuation"] + | components["schemas"]["error-invalid-request"]; }; }; /** Not Found */ 404: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-request"]; }; }; }; @@ -336,19 +364,25 @@ export interface operations { /** Bad Request */ 400: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-rotation"]; }; }; /** Unauthorized */ 401: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-client"]; }; }; /** Not Found */ 404: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-rotation"]; + }; + }; + /** Internal Server Error */ + 500: { + content: { + "application/json": components["schemas"]["error-request-denied"]; }; }; }; @@ -363,16 +397,16 @@ export interface operations { responses: { /** No Content */ 204: never; - /** Bad Request */ - 400: { + /** Unauthorized */ + 401: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-invalid-client"]; }; }; - /** Unauthorized */ - 401: { + /** Internal Server Error */ + 500: { content: { - "application/json": components["schemas"]["gnap-error"]; + "application/json": components["schemas"]["error-request-denied"]; }; }; };