cbSwagger Companion Module
The cbSwagger
module for ColdBox allows you to quickly scaffold your documentation by performing an auto-discovery of your routes and the associated component metadata. To operate, the module requires that SES routing be enabled in your application. For more information read the official documentation.
Installation ( via Commandbox )
box install cbswagger
Note: Omit the
box
from your command, if you are already in the Commandbox interactive shell
Configure cbSwagger to auto-detect your API Routes
By default, cbSwagger looks for routes beginning with api
. By adding a cbSwagger
configuration key to your Coldbox configuration, you can add additional metadata to the OpenAPI JSON produced by the module entry point. A full configuration example is provided below:
Handler Introspection & Documentation attributes
cbSwagger will automatically introspect your API handlers provided by your routing configuration. You may provide additional function attributes, which will be picked up and included in your documentation. Some notes on function attributes:
Attributes which are not part of the swagger path specification should be prefixed with an
x-
, x-attributes are an official part of the OpenAPI Specification and may be used to provide additional information for your developers and consumersYou may also provide paths to JSON files which describe complex objects which may not be expressed within the attributes themselves. This is ideal to provide an endpoint for parameters and responses If the atttribute ends with
.json
, this will be included in the generated OpenAPI document as a $ref include.
Example:
Last updated