This repo is for Xfers' API documentation. Beta site for API documentation (https://docs.xfers.io/)
This README contains information regarding the big picture of Xfers' approach to API documentation. To get the detailed information on how the parser or front end works refer to the dir README. Client facing interface check react-pages
directory. For information on the Parser
check ruby-parser
directory.
- Xfers have multiple products that currently require different documentation.
- Manually creating the documentation for each product is inefficient and problems of inconsistency will arise
- Any changes made to the endpoints that are used by multiple documentations require changes to be made manually to each documentation
To tackle the above problems, this repo aims to create a way of documentation at a higher level of abstraction. Any changes made to the documentation should only be made to 1 source to ensure efficiency and standardization.
The github pages that host our docuementation is built according to json files in the /react-page/src/oas_spec/ folder. Once the json files have been written into the directory, the page will be updated.
- Ability to define specific parameters for different sets of documentation by adding this fied
"x-custom-params"
. More info here - Ability to state custom parameter requires wrt to the country add this field
"x-custom-params-requirements"
- API docs analytics powered by Google Analytics(WIP)
- Changes to Client facing interface
- Refer to /react-pages/README.md
- Changes to behavior and functionality of Parser
- Refer to /ruby-parser/README.md
- Changes to content of the docuementation rendered to the client see below
- Refer to /src/oas_spec/README.md for information on details on OAS
Optional Env setup(make your life easier)
- Download VS Code OpenAPI (Swagger) editor
- Download openapi-lint
Env Setup
- clone entire repo
cd react-page
yarn install
Generate new documentation for all merchants
MAKE SURE YOU ARE IN react-page
folder
PORT=3002 yarn start
- open
http://localhost:3002/
- make desired changes to
master-openapi.json
. When you save changeshttp://localhost:3002
will hot reload and you can review the changes you made - View changes made to client facing interface on
http://localhost:302
- Create PR and let PM/Engineer review
- Once approved run
npm run deploy
inreact-page
- Changes will be seen on
docs.xfers.io
Generate a new documentation page
- go to
/react-pages/src/oas_spec
- create a new folder
/react-pages/src/oas_spec/{doc-name}
- open
/react-pages/src/index.js
and make changes according to the comment(make sure you do not delete the comments) - run
PORT=3002 yarn start
inreact-page
and check doc inhttp://localhost:3002/V3/{doc-name}
- Once satisfied create PR and let PM/Engineer review
- Once approved run
npm run deploy
inreact-page
- Changes will be seen on
docs.xfers.io
Here are information that you cannot find anywhere on the interent. Read this to save your time googling it.
- To have path/query/requestBody parameters only present in certain document
- This code will only work if you add into
Parameter Object
andSchema Object
- Legend:
doc_nameX => the name of the document(as per config.yml)
"x-custom-params" : ["doc_name1","doc_name2"],
- To have certain parameters only required for certain document
- This code will only work if you add into
Shema Object
in requestBody - Legend:
doc_nameX => the name of the document(as per config.yml)
,paramX => the name of parameters you want to be required by only certain documents
Documentation here
- Tags that are for general information and have nothing to do with endpoints
- This code will only work if you add into
Tags Object
in"tags"
"x-traitTag" : true
- To add sample
curl or ...
http request
"x-code-samples": [{
"lang": "Shell_curl", //Lang of request
"source": "curl --location --request ..." //example of curl request
}],