This is a test for publishing NSG&B Open API descriptions in Github using Redocly CLI. See latest version of the published API documentation here.
- Install Node JS.
- Clone this repo and run
npm installin the repo root. - (OPTIONAL) Install redocly
npm i -g @redocly/cli@latestfor linting & other commands.
Starts the reference docs preview server.
Published the versioned API. Use v2 for the next version etc.
Run API linter for the given version
- Navigate to the
openapi/components/schemasfolder. - Add a file named as you wish to name the schema.
- Define the schema.
- Refer to the schema using the
$ref(see example below).
registeredAddress:
$ref: './Address.yaml'- Navigate to the
openapi/pathsfolder. - Add a new YAML file named like your URL endpoint except replacing
/with_(or whichever character you prefer) and putting path parameters into curly braces like{example}. - Add the path and a ref to it inside of your
openapi.yamlfile inside of theopenapifolder.
Example addition to the openapi.yaml file:
'/customers/{id}':
$ref: './paths/customers_{id}.yaml'Automated code sample generations is enabled in the Redocly configuration file. Add manual code samples by the following process:
- Navigate to the
openapi/code_samplesfolder. - Navigate to the
<language>(e.g. PHP) sub-folder. - Navigate to the
pathfolder, and add ref to the code sample.
You can add languages by adding new folders at the appropriate path level.
More details inside the code_samples folder README.
API versioning is done by creating a new API page for each version and publishing the bundled specification for that version. To create a new major version look into packages.json for example.
To bundle and publish new minor version use existing shorthands from packages.json, for example:
npm run publish-v2
Remember to update minor version number to API root in openapi/v{number}.yaml
Test this library for code snippets:
Preview any Open API spec:
redocly preview-docs bundled.yaml
Lint any Open API spec:
redocly lint bundled.yaml
Split Open API to redoc style directories:
redocly split bundled.yaml --outDir .
For more commands see Redocly docs.