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

Update openapi schema to include missing fields in asset schema #94

Merged
merged 17 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 10 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
8 changes: 8 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# STOP WHAT YOU'RE DOING

If you're here to make some fixes to Stellar's API documentation (first, thank
you!), you probably don't want to be in this location. Most of the API
documentation located here has been generated by the `.yml` files contained in
the [`/openapi`](../openapi/) directory. Unless you're working on something
that's _outside_ the `/api/resources` directory, you'll probably want to check
in `/openapi` instead of here.
14 changes: 13 additions & 1 deletion api/resources/assets/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,24 @@ When Horizon returns information about an asset, it uses the following format:
- num_claimable_balances
- number
- The current number of claimable_balances for this asset.
- num_contracts
- number
- The current number of Soroban contracts holding this asset.
- num_liquidity_pools
- number
- The current number of liquidity pools holding this asset.
- balances
- object
- The number of units issued for this asset grouped by each trustline flag state.
- claimable_balances_amount
- string
- The number of units in claimable balances for this asset.
- The number of units for this asset held by all claimable balances.
- contracts_amount
- string
- The number of units for this asset held by all Soroban contracts.
- liquidity_pools_amount
- string
- The number of units for this asset held by all liquidity pools.
- amount
- string
- The number of authorized units issued for this asset. This will be deprecated in Horizon v3.
Expand Down
4 changes: 2 additions & 2 deletions api/resources/get-effects-by-account-id.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/resources/list-all-assets.api.mdx

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions openapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Stellar Horizon OpenAPI Documentation

Contained in this directory is the OpenAPI specification for interacting with
the Horizon servers on the Stellar network.

## Contributing

First, thanks for you interest in helping out! Major kudos to you. Second, it
can be a bit difficult to figure out exactly _what_ is being rendered from
_where_ in this section of the codebase. Read on to learn all the details.

In order to make any changes or fixes, here are some steps you'll want to take.
I'll assume you're past the point of cloning and installing dependencies, and
we'll skip right to the tricky parts that are specific to this API section.

### Where to make your changes

Inside this `/openapi` directory, you'll find several `.yml` files that are used
to generate the API section of our documentation. The setup we have here will
combine all of the different `.yml` files we've got, and _bundle_ them into one
single specification file that will then be used to generate the actual
documentation pages.

Here's a quick tour of our files:

- `/openapi/main.yml`: This is the _root_ of our API specification. This file
defines two things (among others) that I want to draw your attention to:
1. `tags`: The tags are used to collect our various endpoints into a cohesive
structure based on resource type.
2. `paths`: The path definitions in this file list the endpoint URLs available
to consume from our API. These path definitions also reference the location
where we'll pull in more specification details from.
- `/openapi/components`: The various endpoints, schemas, parameters, variables,
response examples, etc. that make up our openAPI specification. These are
likely the files you'll want to edit when you are trying to make changes here.
- `/openapi/bundled.yml`: As part of the build process, all of the linked `.yml`
files we have will be _bundled_ into one all-encompassing file that will then
generate the API documentation that will actually be served on the docs site.
- **Please Note**: You don't want to edit this file as you're making changes
to our documentation. If you make changes here, and preview them locally,
those changes _may_ be reflected in your preview. However, since the bundled
file is intended to be a generated file, those changes will likely not last
once someone else makes changes.
- **Double Please Note**: While you don't want to edit this file by hand, you
_do_ want to **commit changes to this file**.

### Bundle and generate

Once your changes are made, you'll need to do three quick things:

1. Clean up the previously generated openapi docs. It appears `redocly` has some
trouble over-writing files that already exist (or figuring out if those files
should be overwritten, perhaps?). So, you can use this script to clean up the
existing generated files.

```bash
yarn api:clean
```

2. Bundle your changes into the `bundled.yml` file. We've gone over this a bit,
so I wont' repeat myself. Bring any changes you've made in the other
ElliotFriend marked this conversation as resolved.
Show resolved Hide resolved
components into the bundled file.

```bash
yarn api:bundle
```

If you don't have `redocly` installed, you can use `npx` to accomplish the same
thing:

```bash
npx @redocly/cli@latest bundle openapi/main.yml --output openapi/bundled.yml
```

3. Generate the new `.mdx` files that will be read and parsed for people to use.

```bash
yarn api:gen
```

4. Ooooorrr... You can use the shortcut that does all three of those at once:

```bash
yarn api
```

Now you should be ready to preview your changes locally, fiddle with them, make
a pull request, and on the list goes. You know the drill by now.

Thanks again for contributing!
16 changes: 15 additions & 1 deletion openapi/bundled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ paths:
x-supports-streaming: true
responses:
'200':
description: OK
description: Success
content:
application/json:
schema:
Expand Down Expand Up @@ -2616,6 +2616,10 @@ components:
type: integer
num_claimable_balances:
type: integer
num_contracts:
type: integer
num_liquidity_pools:
type: integer
balances:
type: object
properties:
Expand All @@ -2627,6 +2631,10 @@ components:
type: string
claimable_balances_amount:
type: string
contracts_amount:
type: string
liquidity_pools_amount:
type: string
amount:
type: string
num_accounts:
Expand Down Expand Up @@ -4939,13 +4947,15 @@ components:
paging_token: CNY_GA6VXTS64XUOCQZSBAYHD24ZYJYPNB3KJ2CVKSYIE43P2DQQIX74UT2A_credit_alphanum4
num_accounts: 10
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '899996000000.0000000'
accounts:
authorized: 10
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '899996000000.0000000'
Expand All @@ -4965,13 +4975,15 @@ components:
paging_token: CNY_GAASPHILC6DCBPP2P4T66QNSYF6C6OGN6DK36NY4G5SBR7AWH75TJG7N_credit_alphanum4
num_accounts: 43
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '1.0000000'
accounts:
authorized: 43
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '1.0000000'
Expand All @@ -4991,13 +5003,15 @@ components:
paging_token: CNY_GABGBJYLIC2OGATH3DVW22UEB66TFMWC3VKTAPFIOINVESRZLFKIHA4I_credit_alphanum4
num_accounts: 1
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '65000000000.0000000'
accounts:
authorized: 1
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '65000000000.0000000'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ components:
paging_token: CNY_GA6VXTS64XUOCQZSBAYHD24ZYJYPNB3KJ2CVKSYIE43P2DQQIX74UT2A_credit_alphanum4
num_accounts: 10
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '899996000000.0000000'
accounts:
authorized: 10
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '899996000000.0000000'
Expand All @@ -46,13 +48,15 @@ components:
paging_token: CNY_GAASPHILC6DCBPP2P4T66QNSYF6C6OGN6DK36NY4G5SBR7AWH75TJG7N_credit_alphanum4
num_accounts: 43
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '1.0000000'
accounts:
authorized: 43
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '1.0000000'
Expand All @@ -72,13 +76,15 @@ components:
paging_token: CNY_GABGBJYLIC2OGATH3DVW22UEB66TFMWC3VKTAPFIOINVESRZLFKIHA4I_credit_alphanum4
num_accounts: 1
num_claimable_balances: 0
num_contracts: 0
num_liquidity_pools: 0
amount: '65000000000.0000000'
accounts:
authorized: 1
authorized_to_maintain_liabilities: 0
unauthorized: 0
claimable_balances_amount: '0.0000000'
contracts_amount: '0.0000000'
liquidity_pools_amount: '0.0000000'
balances:
authorized: '65000000000.0000000'
Expand Down
8 changes: 8 additions & 0 deletions openapi/components/schemas/assetSchema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ components:
type: integer
num_claimable_balances:
type: integer
num_contracts:
type: integer
num_liquidity_pools:
type: integer
balances:
type: object
properties:
Expand All @@ -44,6 +48,10 @@ components:
type: string
claimable_balances_amount:
type: string
contracts_amount:
type: string
liquidity_pools_amount:
type: string
amount:
type: string
num_accounts:
Expand Down
Loading