Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(backend): add webhooks openapi spec #1210

Merged
merged 12 commits into from
Mar 22, 2023
38 changes: 38 additions & 0 deletions .github/workflows/validate-openapi.yml
Original file line number Diff line number Diff line change
@@ -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
230 changes: 230 additions & 0 deletions packages/backend/src/openapi/webhooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- balance
- balance
- receiver

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

properties:
id:
type: string
format: uuid
paymentPointerId:
type: string
format: uuid
state:
type: string
enum:
- FUNDING
- SENDING
- FAILED
- COMPLETED
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
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