Created
February 16, 2018 04:40
-
-
Save antoniogarrote/e5ba9f726b91171d1861b302052d41dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asyncapi: "1.0.0" | |
info: | |
title: Loan Async API | |
version: "1.0" | |
description: Asynchronous API used to track changes in the loans processing pipeline. | |
servers: | |
- url: rabbit.myorg.com:5676 | |
scheme: amqp | |
components: | |
schemas: | |
MonetaryAmountData: | |
type: object | |
properties: | |
value: | |
type: number | |
currency: | |
type: string | |
LoanCreatedEvent: | |
type: object | |
properties: | |
uuid: | |
type: string | |
loan_id: | |
type: string | |
customer_id: | |
type: string | |
amount: | |
$ref: "#/components/schemas/MonetaryAmountData" | |
interest_rate: | |
type: number | |
timestamp: | |
type: string | |
format: dateTime | |
LoanChangeEvent: | |
type: object | |
properties: | |
uuid: | |
type: string | |
loan_id: | |
type: string | |
timestamp: | |
type: string | |
format: dateTime | |
old_state: | |
type: string | |
enum: | |
- underwriting | |
- cancelled | |
- repayment | |
- closed | |
- failed | |
new_state: | |
type: string | |
enum: | |
- underwriting | |
- cancelled | |
- repayment | |
- closed | |
- failed | |
LoanFailedEvent: | |
type: object | |
properties: | |
uuid: | |
type: string | |
loan_id: | |
type: string | |
customer_id: | |
type: string | |
amountPaid: | |
$ref: "#/components/schemas/MonetaryAmountData" | |
amountFailed: | |
$ref: "#/components/schemas/MonetaryAmountData" | |
interest_rate: | |
type: number | |
timestamp: | |
type: string | |
format: dateTime | |
LoanRepaymentEvent: | |
properties: | |
uuid: | |
type: string | |
customer_id: | |
type: string | |
principal_repaid: | |
$ref: "#/components/schemas/MonetaryAmountData" | |
interest_repaid: | |
$ref: "#/components/schemas/MonetaryAmountData" | |
loan_id: | |
type: string | |
x-serialization: application/json | |
# global bindings | |
x-bindings: | |
amqp_exchange: loans_exchange | |
amqp_exchange_type: topic | |
topics: | |
"loans": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.*" | |
publish: | |
description: Publishes information about created loans | |
payload: | |
$ref: "#/components/schemas/LoanCreatedEvent" | |
subscribe: | |
description: Subscribe to all loan events for all loans | |
payload: | |
anyOf: | |
- $ref: "#/components/schemas/LoanCreatedEvent" | |
- $ref: "#/components/schemas/LoanChangeEvent" | |
- $ref: "#/components/schemas/LoanFailedEvent" | |
"loans.{loans_id}": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "{loans_id}.loans" | |
x-parameters: | |
loan_id: | |
schema: | |
type: string | |
publish: | |
description: Publishes events for an existing loan | |
payload: | |
anyOf: | |
- $ref: "#/components/schemas/LoanChangeEvent" | |
- $ref: "#/components/schemas/LoanFailedEvent" | |
subscribe: | |
description: Subscribes to all loan events for an existing loan | |
payload: | |
anyOf: | |
- $ref: "#/components/schemas/LoanChangeEvent" | |
- $ref: "#/components/schemas/LoanFailedEvent" | |
"loans.created": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.created" | |
publish: | |
description: Publishes all creation events | |
x-pattern: sink | |
payload: | |
$ref: "#/components/schemas/LoanCreatedEvent" | |
subscribe: | |
description: Subscribes to all loan creation events | |
payload: | |
$ref: "#/components/schemas/LoanCreatedEvent" | |
"loans.underwritten": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.created" | |
publish: | |
description: Publishes all underwriting events | |
payload: | |
$ref: "#/components/schemas/LoanChangeEvent" | |
subscribe: | |
description: Subscribes to all loan underwriting events | |
payload: | |
$ref: "#/components/schemas/LoanChangeEvent" | |
"loans.cancelled": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.cancelled" | |
publish: | |
description: Publishes all cancel events | |
payload: | |
$ref: "#/components/schemas/LoanChangeEvent" | |
subscribe: | |
description: Subscribes to all loan cancel events | |
payload: | |
$ref: "#/components/schemas/LoanChangeEvent" | |
"loans.repayments": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_exchange: repayments_exchange | |
amqp_routing_key: "*" | |
subscribe: | |
description: Subscribe to all loan repayments events for all loans | |
payload: | |
$ref: "#/components/schemas/LoanRepaymentEvent" | |
"loans.{loan_id}.repayments": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_exchange: repayments_exchange | |
amqp_routing_key: "{loan_id}" | |
x-parameters: | |
loan_id: | |
schema: | |
type: string | |
subscribe: | |
description: Subscribes to all repayments events for a particular loan | |
payload: | |
$ref: "#/components/schemas/LoanRepaymentEvent" | |
publish: | |
description: Publishes to all repayments events for a particular loan | |
payload: | |
$ref: "#/components/schemas/LoanRepaymentEvent" | |
"loans.failures": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.failures" | |
subscribe: | |
description: Subscribes to all loan failed payments events for all loans | |
payload: | |
$ref: "#/components/schemas/LoanFailedEvent" | |
"loans.closed": | |
x-pattern: publish-subscribe | |
x-bindings: | |
amqp_routing_key: "*.closed" | |
subscribe: | |
description: Subscribes to all closed events for all loans | |
payload: | |
$ref: "#/components/schemas/LoanChangeEvent" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment