968 B
968 B
Swagger or OpenAPI
My company currently use Swagger 2 to document API.
I want to work with OpenAPI 3 but too lazy to convert (for now of course).
So step by step:
- Write API spec in
YAML
. - Convert to API spec in
JSON
. - Format spec files.
- Render spec in local.
- Push to company host for other teams to see.
Only step 1 is manual, aka I write my API spec completely with my hand (no auto gen from code whatever). The others can be done with tools:
# Convert
go install github.com/mikefarah/yq/v4@latest
yq -o=json '.' ./docs/swagger.yaml > ./docs/swagger.json
# Format
bunx prettier@latest --write ./docs/swagger.yaml ./docs/swagger.json
# Render locally
bunx @redocly/cli preview-docs ./docs/swagger.json