Files
openfoodnetwork/script/rswag
Maikel Linke 5a4efdbce3 Separate DFC API swagger config
This allows us to run the specs separately to generate the
documentation. It's more efficient this way and the separate swagger doc
file is easier to read.

The engine-specific swagger helper also allows us to simplify the spec
files.

Added an exception to our styleguide because it's intended and useful to
have a complete (lengthy) description of the API in one block.
2023-07-03 12:37:23 +10:00

26 lines
804 B
Bash
Executable File

#!/usr/bin/env bash
# Generate the API documentation based on our specs.
#
# For API v0 and v1 you can call one of these:
#
# ./bin/rake rswag
# ./script/rswag --dry-run
#
# For the DFC API you need to call:
#
# ./script/rswag engines/dfc_provider
#
# The standard way to generate the documentation is `rake rswag` which calls
# rspec under the hood. We have a few customisations to the rspec call though
# which only work when calling rspec ourselves.
#
# - We actually run the specs to generate examples instead of a dry run.
# While rswag has an RSWAG_DRY_RUN switch, it doesn't work with our setup.
# - We run only tagged swagger specs instead of all matching the pattern.
exec ./bin/rspec\
--tag "swagger_doc"\
--format "Rswag::Specs::SwaggerFormatter"\
--order "defined"\
"${@:1}"