diff --git a/async_api/requests/account_currencies_async_api.yaml b/async_api/requests/account_currencies_async_api.yaml new file mode 100644 index 0000000..d041d82 --- /dev/null +++ b/async_api/requests/account_currencies_async_api.yaml @@ -0,0 +1,79 @@ +components: + schemas: + AccountCurrenciesRequest: + type: object + allOf: + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesRequest + properties: + command: + type: string + enum: + - account_currencies + id: + description: A unique identifier for the request. + required: + - command + - id + example: + command: 'account_currencies' + account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59' + ledger_index: 'validated' + AccountCurrenciesResponse: + type: object + properties: + result: + type: object + discriminator: + propertyName: status + mapping: + success: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesSuccessResponse + error: '#/components/schemas/AccountCurrenciesErrorResponse' + oneOf: + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesSuccessResponse + - $ref: '#/components/schemas/AccountCurrenciesErrorResponse' + 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: + result: + ledger_index: 11775823, + receive_currencies: + [ + 'BTC', + 'CNY', + 'DYM', + 'EUR', + 'JOE', + 'MXN', + 'USD', + '015841551A748AD2C1F76FF6ECB0CCCD00000000', + ] + send_currencies: + [ + 'ASP', + 'BTC', + 'CHF', + 'CNY', + 'DYM', + 'EUR', + 'JOE', + 'JPY', + 'MXN', + 'USD', + ] + status: 'success' + validated: true + AccountCurrenciesErrorResponse: + oneOf: + - $ref: ../../shared/base.yaml#/components/schemas/WebsocketErrorFields + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesErrorResponse diff --git a/async_api/websocket_api.yaml b/async_api/websocket_api.yaml index d67d7ff..1f59514 100644 --- a/async_api/websocket_api.yaml +++ b/async_api/websocket_api.yaml @@ -101,6 +101,14 @@ components: payload: $ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryRequest' + # Account channels request message + AccountCurrenciesRequest: + name: AccountCurrenciesRequest + messageId: AccountCurrenciesRequest + contentType: application/json + payload: + $ref: './requests/account_currencies_async_api.yaml#/components/schemas/AccountCurrenciesRequest' + # ... (Add definitions for additional message types) # Account channels response message @@ -134,4 +142,13 @@ components: contentType: application/json payload: $ref: './requests/ledger_entry_async_api.yaml#/components/schemas/LedgerEntryResponse' + + # Account currencies response message + AccountCurrenciesResponse: + name: AccountCurrenciesResponse + messageId: AccountCurrenciesResponse + contentType: application/json + payload: + $ref: './requests/account_currencies_async_api.yaml#/components/schemas/AccountCurrenciesResponse' + # ... (Add definitions for additional response types) diff --git a/async_api/websocket_api_v2.yaml b/async_api/websocket_api_v2.yaml index d0cba84..9a4e21f 100644 --- a/async_api/websocket_api_v2.yaml +++ b/async_api/websocket_api_v2.yaml @@ -39,58 +39,115 @@ servers: protocol: wss description: Testnet (not for production usage) +# Refactored channels section for better reusability channels: + # Root channel for all requests and responses /: - # In AsyncAPI 2.x 'subscribe' is from the api's perspective - so an end user sends a request to - # a channel where the api is 'subscribed'. This is changed in 3.0.0. description: The root channel for sending requests and receiving responses. + # Leverages operationId for clarity 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' - - name: AccountLinesRequest - messageId: AccountLinesRequest - 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 + # Reusable message references + - $ref: '#/components/messages/AccountChannelsRequest' + - $ref: '#/components/messages/AccountInfoRequest' + - $ref: '#/components/messages/AccountLinesRequest' + - $ref: '#/components/messages/LedgerEntryRequest' + # ... (Add references for additional requests) 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/AccountInfoResponseV2' - - name: AccountLinesResponse - messageId: AccountLinesResponse - 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 + - $ref: '#/components/messages/AccountChannelsResponse' + - $ref: '#/components/messages/AccountInfoResponseV2' + - $ref: '#/components/messages/AccountLinesResponse' + - $ref: '#/components/messages/LedgerEntryResponse' + # ... (Add references for additional responses) + +# Moved message definitions to a separate components section +components: + messages: + # Account channels request message + AccountChannelsRequest: + name: AccountChannelsRequest + messageId: AccountChannelsRequest + contentType: application/json + payload: + $ref: './requests/account_channels_async_api.yaml#/components/schemas/AccountChannelsRequest' + + # Account info request message + AccountInfoRequest: + name: AccountInfoRequest + messageId: AccountInfoRequest + contentType: application/json + payload: + $ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoRequest' + + # Account lines request message + AccountLinesRequest: + name: AccountLinesRequest + messageId: AccountLinesRequest + contentType: application/json + 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' + + # Account channels request message + AccountCurrenciesRequest: + name: AccountCurrenciesRequest + messageId: AccountCurrenciesRequest + contentType: application/json + payload: + $ref: './requests/account_currencies_async_api.yaml#/components/schemas/AccountCurrenciesRequest' + + # ... (Add definitions for additional message types) + + # Account channels response message + AccountChannelsResponse: + name: AccountChannelsResponse + messageId: AccountChannelsResponse + contentType: application/json + payload: + $ref: './requests/account_channels_async_api.yaml#/components/schemas/AccountChannelsResponse' + + # Account info response message (version 2) + AccountInfoResponseV2: + name: AccountInfoResponse + messageId: AccountInfoResponseV2 # Consider using a version suffix + contentType: application/json + payload: + $ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoResponseV2' + + # Account lines response message + AccountLinesResponse: + name: AccountLinesResponse + messageId: AccountLinesResponse + 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' + + # Account currencies response message + AccountCurrenciesResponse: + name: AccountCurrenciesResponse + messageId: AccountCurrenciesResponse + contentType: application/json + payload: + $ref: './requests/account_currencies_async_api.yaml#/components/schemas/AccountCurrenciesResponse' + + # ... (Add definitions for additional response types) diff --git a/open_api/json_api.yaml b/open_api/json_api.yaml index 69baa95..9da974a 100644 --- a/open_api/json_api.yaml +++ b/open_api/json_api.yaml @@ -36,6 +36,7 @@ paths: 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' + account_currencies: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest' # TODO: Add the rest of the JSON RPC requests here oneOf: - $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest' @@ -43,6 +44,7 @@ paths: - $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' + - $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest' # TODO: Add the rest of the JSON RPC requests here required: true operationId: 'POST' @@ -64,6 +66,7 @@ paths: - $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' + - $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesResponse' # 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. diff --git a/open_api/json_api_v2.yaml b/open_api/json_api_v2.yaml index 7e2d262..52becc3 100644 --- a/open_api/json_api_v2.yaml +++ b/open_api/json_api_v2.yaml @@ -34,6 +34,7 @@ paths: 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' + account_currencies: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest' # TODO: Add the rest of the JSON RPC requests here oneOf: - $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest' @@ -41,6 +42,7 @@ paths: - $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' + - $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest' # TODO: Add the rest of the JSON RPC requests here required: true operationId: 'POST' @@ -56,6 +58,7 @@ paths: - $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' + - $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesResponse' # 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. diff --git a/open_api/requests/account_currencies_open_api.yaml b/open_api/requests/account_currencies_open_api.yaml new file mode 100644 index 0000000..fbe3e4c --- /dev/null +++ b/open_api/requests/account_currencies_open_api.yaml @@ -0,0 +1,70 @@ +components: + schemas: + AccountCurrenciesRequest: + type: object + description: '' + properties: + method: + type: string + enum: + - account_currencies + params: + type: array + items: + $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesRequest + required: + - method + example: + method: account_currencies + params: + - account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59' + ledger_index: 'validated' + AccountCurrenciesResponse: + type: object + properties: + result: + type: object + discriminator: + propertyName: status + mapping: + success: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesSuccessResponse + error: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesErrorResponse + oneOf: + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesSuccessResponse + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesErrorResponse + required: + - result + example: + result: + ledger_index: 11775823, + receive_currencies: + [ + 'BTC', + 'CNY', + 'DYM', + 'EUR', + 'JOE', + 'MXN', + 'USD', + '015841551A748AD2C1F76FF6ECB0CCCD00000000', + ] + send_currencies: + [ + 'ASP', + 'BTC', + 'CHF', + 'CNY', + 'DYM', + 'EUR', + 'JOE', + 'JPY', + 'MXN', + 'USD', + ] + status: 'success' + validated: true + AccountCurrenciesSuccessResponse: + type: object + allOf: + - $ref: ../../shared/base.yaml#/components/schemas/BaseSuccessResponse + - $ref: ../../shared/requests/account_currencies.yaml#/components/schemas/AccountCurrenciesSuccessResponse diff --git a/shared/requests/account_currencies.yaml b/shared/requests/account_currencies.yaml new file mode 100644 index 0000000..9e47125 --- /dev/null +++ b/shared/requests/account_currencies.yaml @@ -0,0 +1,65 @@ +components: + schemas: + AccountCurrenciesRequest: + description: > + The account_currencies command retrieves a list of currencies that an account can send or receive, based + on its trust lines. (This is not a thoroughly confirmed list, but it can be used to populate user interfaces.) + type: object + allOf: + - $ref: '../base.yaml#/components/schemas/BaseRequest' + - $ref: '../base.yaml#/components/schemas/LookupByLedgerRequest' + properties: + account: + type: string + description: 'Look up currencies this account can send or receive. Updated in: rippled 1.11.0' + + AccountCurrenciesSuccessResponse: + type: object + allOf: + - $ref: '../base.yaml#/components/schemas/BaseSuccessResponse' + properties: + ledger_hash: + type: string + description: The identifying hash of the ledger version used to retrieve this data, as hex. (May be omitted) + ledger_index: + type: integer + description: The ledger index of the ledger version used to retrieve this data. + receive_currencies: + type: array + items: + type: string + description: Array of Currency Codes for currencies that this account can receive. + send_currencies: + type: array + items: + type: string + description: Array of Currency Codes for currencies that this account can send. + validated: + type: boolean + description: If true, this data comes from a validated ledger. + + AccountCurrenciesErrorResponse: + type: object + properties: + error: + type: string + oneOf: + - $ref: '../base.yaml#/components/schemas/UniversalErrorResponseCodes' + - enum: + - invalidParams + - actNotFound + - lgrNotFound + description: > + * `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing. + * `actNotFound` - The address specified in the `account` field of the request does not correspond to an account in the ledger. + * `lgrNotFound` - The ledger specified by the `ledger_hash` or `ledger_index` does not exist, or it does exist but the server does not have it. + status: + type: string + enum: + - error + request: + $ref: '#/components/schemas/AccountCurrenciesRequest' + required: + - status + - error + - request