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

YAML specification for ledger_entry request #7

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions async_api/requests/ledger_entry_async_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
components:
schemas:
LedgerEntryRequest:
$id: LedgerEntryRequest
type: object
description: >
The ledger_entry method returns a single ledger entry from the XRP Ledger in its raw format.
All information retrieved is relative to a particular version of the ledger.
Returns a LedgerEntryResponse.
allOf:
- $ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntryRequest'
- type: object
properties:
command:
$ref: '../../shared/base.yaml#/components/schemas/CommandTypes'
id:
description: 'A unique identifier for the request.'
required:
- command
- id
example:
id: 3
command: ledger_entry
index: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'
ledger_index: 'validated'

LedgerEntryResponse:
$id: LedgerEntryResponse
type: object
oneOf:
- $ref: '#/components/schemas/LedgerEntrySuccessResponse'
- $ref: '#/components/schemas/LedgerEntryErrorResponse'
properties:
id:
description: 'A unique identifier for the request.'
type:
type: string
description: The value response indicates a direct response to an API request. Asynchronous notifications use a different value such as `ledgerClosed` or `transaction`.
enum:
- response
required:
- id
- type
example:
id: 3
status: success
type: response
result:
index: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'
ledger_index: 54321
node:
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'
Balance: '148446663'
Flags: 8388608
LedgerEntryType: 'AccountRoot'
OwnerCount: 3
PreviousTxnID: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'
PreviousTxnLgrSeq: 54320
Sequence: 336

LedgerEntryErrorResponse:
$id: LedgerEntryErrorResponse
oneOf:
- $ref: '../../shared/base.yaml#/components/schemas/WebsocketErrorFields'
- $ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntryErrorResponse'
properties:
status:
type: string
enum:
- error

LedgerEntrySuccessResponse:
$id: LedgerEntrySuccessResponse
properties:
result:
type: object
allOf:
- $ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntrySuccessResponse'
status:
type: string
enum:
- success
required:
- status
18 changes: 18 additions & 0 deletions async_api/websocket_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ channels:
- $ref: '#/components/messages/AccountChannelsRequest'
- $ref: '#/components/messages/AccountInfoRequest'
- $ref: '#/components/messages/AccountLinesRequest'
- $ref: '#/components/messages/LedgerEntryRequest'
# ... (Add references for additional requests)
publish:
operationId: publishToRoot
Expand All @@ -62,6 +63,7 @@ channels:
- $ref: '#/components/messages/AccountChannelsResponse'
- $ref: '#/components/messages/AccountInfoResponseV1'
- $ref: '#/components/messages/AccountLinesResponse'
- $ref: '#/components/messages/LedgerEntryResponse'
# ... (Add references for additional responses)

# Moved message definitions to a separate components section
Expand Down Expand Up @@ -91,6 +93,14 @@ components:
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesRequest'

# Ledger entry request message
LedgerEntryRequest:
name: LedgerEntryRequest
messageId: LedgerEntryRequest
contentType: application/json
payload:
$ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryRequest'

# ... (Add definitions for additional message types)

# Account channels response message
Expand All @@ -116,4 +126,12 @@ components:
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesResponse'

# Ledger entry response message
LedgerEntryResponse:
name: LedgerEntryResponse
messageId: LedgerEntryResponse
contentType: application/json
payload:
$ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryResponse'
# ... (Add definitions for additional response types)
10 changes: 10 additions & 0 deletions async_api/websocket_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ channels:
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesRequest'
- name: LedgerEntryRequest
messageId: LedgerEntryRequest
contentType: application/json
payload:
$ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryRequest'
# TODO: Add additional request types for individual requests here
publish:
operationId: publishToRoot
Expand All @@ -83,4 +88,9 @@ channels:
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesResponse'
- name: LedgerEntryResponse
messageId: LedgerEntryResponse
contentType: application/json
payload:
$ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryResponse'
# TODO: Add additional response types for individual requests here
3 changes: 3 additions & 0 deletions open_api/json_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ paths:
account_info: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
account_lines: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
submit: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV1'
ledger_entry: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV1'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
# TODO: Add the rest of the JSON RPC requests here
required: true
operationId: 'POST'
Expand All @@ -61,6 +63,7 @@ paths:
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoResponseV1'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitResponseV1'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryResponse'
# TODO: Add the rest of the JSON RPC responses here

# TODO: We want to be much more explicit with http error codes for a full implementation of this spec.
Expand Down
3 changes: 3 additions & 0 deletions open_api/json_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ paths:
account_info: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
submit: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV2'
account_lines: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
ledger_entry: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV2'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
# TODO: Add the rest of the JSON RPC requests here
required: true
operationId: 'POST'
Expand All @@ -53,6 +55,7 @@ paths:
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoResponseV2'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitResponseV2'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryResponse'
# TODO: Add the rest of the JSON RPC responses here

# TODO: We want to be much more explicit with http error codes for a full implementation of this spec.
Expand Down
55 changes: 55 additions & 0 deletions open_api/requests/ledger_entry_open_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
components:
schemas:
LedgerEntryRequest:
type: object
description: >
The ledger_entry method returns a single ledger entry from the XRP Ledger in its raw format.
All information retrieved is relative to a particular version of the ledger.
Returns a LedgerEntryResponse.
properties:
method:
type: string
enum:
- ledger_entry
params:
type: array
items:
$ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntryRequest'
required:
- method
example:
method: 'ledger_entry'
params:
- ledger_index: 'validated'
binary: false
index: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'

LedgerEntryResponse:
type: object
properties:
result:
type: object
discriminator:
propertyName: status
mapping:
success: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntrySuccessResponse'
error: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntryErrorResponse'
oneOf:
- $ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntrySuccessResponse'
- $ref: '../../shared/requests/ledger_entry.yaml#/components/schemas/LedgerEntryErrorResponse'
required:
- result
example:
result:
index: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'
ledger_index: 54321
node:
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'
Balance: '148446663'
Flags: 8388608
LedgerEntryType: 'AccountRoot'
OwnerCount: 3
PreviousTxnID: '13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8'
PreviousTxnLgrSeq: 54320
Sequence: 336
status: 'success'
16 changes: 8 additions & 8 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"bundle": "redocly bundle open_api/json_api.yaml --output dist/openapi && node generate-specs.js"
},
"devDependencies": {
"@apidevtools/json-schema-ref-parser": "^11.6.4",
"@apidevtools/json-schema-ref-parser": "^11.7.0",
"prettier": "3.2.5"
},
"dependencies": {
Expand Down
11 changes: 11 additions & 0 deletions shared/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,14 @@ components:
issuer:
type: string
description: 'Generally, the account that issues this token. In special cases, this can refer to the account that holds the token instead (for example, in a Clawback transaction).'

CurrencyWithoutAmount:
$id: CurrencyWithoutAmount
type: object
properties:
currency:
type: string
description: 'Arbitrary currency code for the token.'
issuer:
type: string
description: 'Generally, the account that issues this token. In special cases, this can refer to the account that holds the token instead (for example, in a Clawback transaction).'
Loading
Loading