From e6f37b100955fb2670bc066cc148d50be1204d27 Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Wed, 8 May 2024 10:20:07 -0500 Subject: [PATCH 1/2] add 422, openapi lint --- api/openapi.yaml | 100 +++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 42591e3..2566ba2 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -30,9 +30,9 @@ paths: get: responses: '200': - description: OK + $ref: '#/components/responses/200' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' /locations: get: @@ -40,7 +40,7 @@ paths: parameters: - name: asn in: query - description: List available locations for peering with the given ASN + description: List available locations for peering with the given peer ASN required: true schema: type: integer @@ -72,11 +72,11 @@ paths: content: application/json: schema: - $ref: '#/components/responses/ListLocationsResponse' + $ref: '#/components/schemas/ListLocationsResponse' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' /sessions: post: @@ -94,11 +94,13 @@ paths: content: application/json: schema: - $ref: '#/components/responses/CreateSessionsResponse' + $ref: '#/components/schemas/CreateSessionsResponse' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' + '422': + $ref: '#/components/responses/422' get: description: Lists a set of sessions visible to the caller. Each session in the set contains a summary of its current status. @@ -130,11 +132,11 @@ paths: content: application/json: schema: - $ref: '#/components/responses/ListSessionsResponse' + $ref: '#/components/schemas/ListSessionsResponse' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' delete: description: Requests to turn the session down and delete it from the server. @@ -151,11 +153,11 @@ paths: content: application/json: schema: - $ref: '#/components/responses/DeleteSessionsResponse' + $ref: '#/components/schemas/DeleteSessionsResponse' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' /sessions/{session_id}: get: @@ -175,16 +177,15 @@ paths: schema: $ref: '#/components/schemas/Session' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' '404': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/404' delete: description: Requests to turn the session down and delete it from the server. parameters: - parameters: - name: session_id in: path description: Server-generated stable identifier for the session. @@ -199,11 +200,11 @@ paths: schema: $ref: '#/components/schemas/Session' '400': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/400' '403': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/403' '404': - $ref: '#/components/responses/ErrorResponse' + $ref: '#/components/responses/404' components: schemas: @@ -301,7 +302,7 @@ components: title: BGP Session References description: Array of BGP Session References type: array - sessions: + items: $ref: '#/components/schemas/SessionReference' SessionReference: @@ -346,11 +347,14 @@ components: items: type: string readOnly: true + example: + name: peer_asn + messages: + - asn not available at that location required: - name - errors - requests: CreateSessionsRequest: title: CreateSessionsRequest description: Response to a request to create sessions @@ -359,7 +363,6 @@ components: sessions: $ref: '#/components/schemas/SessionRequestArray' - responses: ListLocationsResponse: title: ListLocationsResponse description: Response to a list for locations @@ -402,19 +405,40 @@ components: ErrorResponse: description: API Error response + type: object + properties: + errors: + $ref: '#/components/schemas/Error' + required: + - errors + responses: + '200': + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '422': + description: Human intervention required content: application/json: schema: - type: object - properties: - errors: - $ref: '#/components/schemas/Error' - required: - - errors - examples: - error-example: - value: - errors: - - name: peer_asn - messages: - - asn not available at that location + $ref: '#/components/schemas/ErrorResponse' From fbb78bc03e01f0f89a704f5e370e31beda7b638b Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Wed, 8 May 2024 10:23:08 -0500 Subject: [PATCH 2/2] add return_url --- api/openapi.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 2566ba2..af48bfe 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -86,7 +86,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SessionArray' + $ref: '#/components/schemas/CreateSessionsRequest' required: true responses: '200': @@ -362,6 +362,9 @@ components: properties: sessions: $ref: '#/components/schemas/SessionRequestArray' + return_url: + description: URL to requestor's endpoint to negotiate the session creation + type: string ListLocationsResponse: title: ListLocationsResponse