This project parses Covalent API JSON file and creates typescript types for desired apis.
JSON file is located at ./schemas/schemas.json
At the moment of writting, there is at least one api that is completely wrong.
Program will read and parse entire file (all apis and their components).
These flags are always available
--filterDexSpecific
: Filters api-s that are specific for certain Dexes (uniswap, sushiswap, ...)- These have quite a bit of duplicate components that are not exactly the same, which can cause issues
- Recommended unless those are required
- All from
Class B
exceptxy=k
To create files, update config.json
and run yarn start
.
Explanation of the fields:
outDir
: Directory where files will be written- Will be deleted before trying to write anything
commonComponents
: List of components to be written tocommonFile
- Other files will import these when needed
commonFile
: Name of the file wherecommonComponents
should be writtenapis
: List of apis to be written to files.- Each API will be written to different file, together with their non-common components
- Each API specifies the main component, which is used as filename
- Properties:
path
: API pathcomponentName
: If non-empty it overrides the main component. This is sometimes required because some of them are non-unique and sometimes desired because default names might be unclear.
--force
: It's not recommended to use component name for some api, if that component name is main component for some other api
yarn start list
can be used for printing summary of the API-s.
Instead of writting file, API and Components can be inspected by running:
yarn start summary
This will always print a table of Components and their short summary:
- component name
- in how many apis are they used
- how many different versions there are with the same name
One of the following options can be used for additional print:
--component <componentName>
: Prints more details regarding API-s where specified component is used- version of this component (useful if there are multiple)
- api path
- whether specified component is the main component of this api
- the main component of the api
- api class
--component all
: Same as above, but it prints it for all components
Steps for obtaining file:
- Open https://www.covalenthq.com/docs/api/
- Inspect page's source (e.g.
Ctrl+U
in Chrome) - Locate
<body><scripts>
and there should bewindow.openAPICache
field - Copy it's value into some more powerful editor
- I used: Visual Studio Code
- Save as
*.json
- Format and save again
- I used:
Ctrl+Shift+P
->"Format Document With..."
->"JSON Language Features"
- I used: