diff --git a/.github/workflows/validate-openapi.yml b/.github/workflows/validate-openapi.yml new file mode 100644 index 0000000000..118d3d4a2b --- /dev/null +++ b/.github/workflows/validate-openapi.yml @@ -0,0 +1,38 @@ +name: OpenAPI Validator + +on: + push: + branches: + - main + paths: + - packages/auth/src/openapi/** + - packages/backend/src/openapi/** + - packages/token-introspection/src/openapi/** + pull_request: + branches: + - main + paths: + - packages/auth/src/openapi/** + - packages/backend/src/openapi/** + - packages/token-introspection/src/openapi/** + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + + - name: Lint Open API specs + run: | + npx prettier --check packages/auth/src/openapi/id-provider.yaml + npx prettier --check packages/backend/src/openapi/webhooks.yaml + npx prettier --check packages/token-introspection/src/openapi/token-introspection.yaml + - name: AsyncAPI extension + run: | + echo "{\"extends\":[\"spectral:oas\",\"spectral:asyncapi\"]}" >> .spectral.json + - name: Validate Open API specs + run: | + npx @stoplight/spectral-cli lint packages/auth/src/openapi/id-provider.yaml + npx @stoplight/spectral-cli lint packages/backend/src/openapi/webhooks.yaml + npx @stoplight/spectral-cli lint packages/token-introspection/src/openapi/token-introspection.yaml \ No newline at end of file diff --git a/packages/backend/src/openapi/webhooks.yaml b/packages/backend/src/openapi/webhooks.yaml new file mode 100644 index 0000000000..48cd647a96 --- /dev/null +++ b/packages/backend/src/openapi/webhooks.yaml @@ -0,0 +1,237 @@ +openapi: 3.1.0 +info: + title: Rafiki Webhooks + version: 1.0.0 + description: 'Webhook Events fired by Rafiki' + contact: + email: tech@interledger.org +webhooks: + incomingPaymentCompleted: + post: + requestBody: + description: Notify account servicing entity that an incoming payment was completed and funds should now be withdrawn. + content: + application/json: + schema: + $ref: '#/components/schemas/incomingPaymentEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + incomingPaymentExpired: + post: + requestBody: + description: Notify account servicing entity that an incoming payment has expired and funds should now be withdrawn. + content: + application/json: + schema: + $ref: '#/components/schemas/incomingPaymentEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + outgoingPaymentCreated: + post: + requestBody: + description: Notify account servicing entity that an outgoing payment was created and should now be funded. + content: + application/json: + schema: + $ref: '#/components/schemas/outgoingPaymentEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + outgoingPaymentCompleted: + post: + requestBody: + description: Notify account servicing entity that an outgoing payment completed. Remaining funds should be withdrawn. + content: + application/json: + schema: + $ref: '#/components/schemas/outgoingPaymentEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + outgoingPaymentFailed: + post: + requestBody: + description: Notify account servicing entity that an outgoing payment failed and won't be retried. Funds should be withdrawn. + content: + application/json: + schema: + $ref: '#/components/schemas/outgoingPaymentEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + webMonetization: + post: + requestBody: + description: Notify account servicing entity that a Web Monetization payment was received and funds should be withdrawn. + content: + application/json: + schema: + $ref: '#/components/schemas/webMonetizationEvent' + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully + +components: + schemas: + incomingPaymentEvent: + required: + - id + - type + - data + properties: + id: + type: string + format: uuid + type: + type: string + enum: + - incoming_payment.completed + - incoming_payment.expired + data: + type: object + required: + - id + - paymentPointerId + - createdAt + - updatedAt + - expiresAt + - receivedAmount + - completed + properties: + id: + type: string + format: uuid + paymentPointerId: + type: string + format: uuid + completed: + type: boolean + incomingAmount: + $ref: ./schemas.yaml#/components/schemas/amount + receivedAmount: + $ref: ./schemas.yaml#/components/schemas/amount + description: + type: string + externalRef: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + expiresAt: + type: string + format: date-time + additionalProperties: false + outgoingPaymentEvent: + required: + - id + - type + - data + properties: + id: + type: string + format: uuid + type: + type: string + enum: + - outgoing_payment.created + - outgoing_payment.completed + - outgoing_payment.failed + data: + type: object + required: + - id + - paymentPointerId + - createdAt + - updatedAt + - expiresAt + - sendAmount + - receiveAmount + - state + - stateAttempts + - balance + - receiver + properties: + id: + type: string + format: uuid + paymentPointerId: + type: string + format: uuid + state: + type: string + enum: + - FUNDING + - SENDING + - FAILED + - COMPLETED + receiver: + type: string + format: uri + sendAmount: + $ref: ./schemas.yaml#/components/schemas/amount + sentAmount: + $ref: ./schemas.yaml#/components/schemas/amount + description: + type: string + externalRef: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + expiresAt: + type: string + format: date-time + error: + type: string + stateAttempts: + type: integer + balance: + type: string + format: uint64 + peerId: + type: string + format: uuid + additionalProperties: false + webMonetizationEvent: + required: + - id + - type + - data + properties: + id: + type: string + format: uuid + type: + type: string + enum: + - payment_pointer.web_monetization + data: + type: object + required: + - paymentPointer + properties: + paymentPointer: + type: object + required: + - id + - createdAt + - received + properties: + id: + type: string + format: uuid + createdAt: + type: string + format: date-time + received: + type: string + format: uint64 + additionalProperties: false