Skip to content

Commit

Permalink
Merge pull request #2 from ripple/code-generator
Browse files Browse the repository at this point in the history
Modifications in async_api to make it valid definition
  • Loading branch information
justinr1234 authored Jul 18, 2024
2 parents ec466bd + 325ef98 commit 3cf2d39
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 1 deletion.
15 changes: 15 additions & 0 deletions async_api/websocket_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@
# Submit request (As it will have transaction types as a requirement)

asyncapi: '2.6.0'
defaultContentType: application/json
id: urn:xrp-ledger:public-api
tags:
- name: xrp-ledger
description: API related to XRP Ledger
info:
title: XRP Ledger Public API
contact:
name: Ripple Dev Support
url: https://ripple.com/contact
email: [email protected]
description: A WebSocket API used to query rippled.
license:
name: MIT License
Expand All @@ -36,25 +45,31 @@ channels:
# a channel where the api is 'subscribed'. This is changed in 3.0.0.
description: The root channel for sending requests and receiving responses.
subscribe:
operationId: subscribeToRoot
message:
oneOf:
- name: AccountChannelsRequest
messageId: AccountChannelsRequest
contentType: application/json
payload:
$ref: './requests/account_channels_async_api.yaml#/components/schemas/AccountChannelsRequest'
- name: AccountInfoRequest
messageId: AccountInfoRequest
contentType: application/json
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoRequest'
# TODO: Add additional request types for individual requests here
publish:
operationId: publishToRoot
message:
oneOf:
- name: AccountChannelsResponse
messageId: AccountChannelsResponse
contentType: application/json
payload:
$ref: './requests/account_channels_async_api.yaml#/components/schemas/AccountChannelsResponse'
- name: AccountInfoResponse
messageId: AccountInfoResponse
contentType: application/json
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoResponseV1'
Expand Down
21 changes: 21 additions & 0 deletions generate-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const $RefParser = require('json-schema-ref-parser')
const fs = require('fs')

if (!fs.existsSync('./dist')){
fs.mkdirSync('./dist');
}

$RefParser
.dereference('./async_api/websocket_api.yaml')
.then((schema) => {
fs.writeFileSync('dist/async_api.json', JSON.stringify(schema, null, 2))
})
.then(() => $RefParser.dereference('./open_api/json_api.yaml'))
.then((schema) => {
fs.writeFileSync('dist/open_api.json', JSON.stringify(schema, null, 2))
})
.catch((err) => {
console.error(err)
}).finally(() => {
console.log("Generation process completed");
})
135 changes: 134 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"template": "node addRequestTemplate.js"
},
"devDependencies": {
"json-schema-ref-parser": "^9.0.9",
"prettier": "3.2.5"
},
"dependencies": {
Expand Down

0 comments on commit 3cf2d39

Please sign in to comment.