RapiDoc OpenAPI Viewer Docker Image
This repository contains the definition Docker Image for RapiDoc, which is an OpenAPI viewer. The documentation is exposed via a modified nginx:1.17.6-alpine
image that cotains the production packaging of RapiDoc.
Getting Started
make start
This command will build the RapiDoc image and start the container to expose the API on port 8080.
Other relevant make commands:
make build # build the docker image for RapiDoc.
make clean # shuts down the docker network and deletes the image for RapiDoc.
Folder Content
|- docker
| |- boot.sh # initialisation script for the container.
| |- defaults.env # default settings for the RapiDoc viewer.
| |- index.html.template # template html page for the RapiDoc viewer.
| |- html # HTML assets (favicon, logo, additional javascript).
|
|- .dockerignore # exclude files from docker context
|- .gitignore # exclude files from git
|- Dockerfile # docker image definition
|- Makefile # make instructions for this folder
|- README.md # this file.
Configuring the Viewer
All the options that can be used to configure the RapiDoc viewer can be used to style the web application by passing environment variables to the container. The default values for these variables are stored in the docker/defaults.env
file.
NOTE: the attribute spec-file
is not supported and only spec-url
is used as a pre-built setup.
For more details about the meaning of these attributes please see the RapiDoc documentation
Specification Configuration
TMPL_RAPIDOC_API_MANIFEST_URL
(default: empty): this is the URL to the manifest file. This parameter is utilised in place ofTMPL_RAPIDOC_SPEC_URL
for serving multiple OpenAPI specifications and being able to switch among them. For more details about capability check the section Serving Multiple OpenAPI Specifications.TMPL_RAPIDOC_LOGO_URL
(default:./logo.png
): this is the url of the logo that is shown in the viewer. You can customise it by either replacing thedocker/html/logo.png
file or simply modifing the container to point to another file.TMPL_RAPIDOC_SPEC_URL
(default:openapi.json
): maps tospec-url
TMPL_RAPIDOC_SERVER_URL
(default:TMPL_RAPIDOC_SERVER_URL
): maps toserver-url
TMPL_RAPIDOC_DEFAULT_API_SERVER
(default: empty): maps todefault-api-server
UI Appearance
TMPL_RAPIDC_HEADING_TEXT
(default:Platform API Documentation
): maps toheading-text
TMPL_RAPIDOC_THEME
(default:light
): maps totheme
TMPL_RAPIDOC_BG_COLOR
(default: empty): maps tobg-color
TMPL_RAPIDOC_TEXT_COLOR
(default: empty): maps totext-color
TMPL_RAPIDOC_HEADER_COLOR
(default: empty): maps toheader-color
TMPL_RAPIDOC_PRIMARY_COLOR
(default: empty): maps toprimary-color
TMPL_RAPIDOC_REGULAR_FONT
(default: empty): maps toregular-font
TMPL_RAPIDOC_MONO_FONT
(default: empty): maps tomono-font
TMPL_RAPIDOC_NAV_BG_COLOR
(default: empty): maps tonav-bg-color
TMPL_RAPIDOC_NAV_TEXT_COLOR
(default: empty): maps tonav-text-color
TMPL_RAPIDOC_NAV_HOVER_TEXT_COLOR
(default: empty): maps tonav-hover-text-color
TMPL_RAPIDOC_NAV_HOVER_BG_COLOR
(default: empty): maps tonav-hover-bg-color
TMPL_RAPICOD_NAV_ACCENT_COLOR
(default: empty): maps tonav-accent-color
Layout
TMPL_RAPIDOC_LAYOUT
(default:row
): maps tolayout
TMPL_RAPIDOC_SORT_TAGS
(default:false
): maps tosort-tags
TMPL_RAPIDOC_GOTO_PATH
(default: empty): maps togoto-path
TMPL_RAPIDOC_RENDER_STYLE
(default:read
): maps torender-style
TMPL_RAPIDOC_API_LIST_STYLE
(default:group-by-tag
): maps toapi-list-style
TMPL_RAPIDOC_SCHEMA_STYLE
(default:tree
): maps toschema-style
TMPL_RAPIDOC_SCHEMA_EXPAND_LEVEL
(default:999
): maps toschema-expand-level
TMPL_RAPIDOC_SCHEMA_DESCRIPTION_EXPANDED
(default:true
): maps toschema-description-expanded
TMPL_RAPIDOC_DEFAULT_SCHEMA_TAB=
(default:model
): maps todefault-schema-tab
TMPL_RAPIDOC_SHOW_HEADER
(default:true
): maps toshow-header
TMPL_RAPIDOC_SHOW_INFO
(default:true
): maps toshow-info
Functionalities Switches
TMPL_RAPIDOC_ALLOW_AUTHENTICATION
(default:true
): maps toallow-authentication
TMPL_RAPIDOC_ALLOW_SEARCH
(default:true
): maps toallow-search
TMPL_RAPIDOC_ALLOW_TRY
(default:false
): maps toallow-try
TMPL_RAPIDOC_ALLOW_API_LIST_STYLE_SELECTION
(default:true
): maps toallow-api-list-style-selection
TMPL_RAPIDOC_ALLOW_SERVER_SELECTION
(default:false
): maps toallow-server-selection
TMPL_RAPIDOC_ALLOW_SPEC_URL_LOAD
(default:false
): maps toallow-spec-url-load
TMPL_RAPIDOC_ALLOW_SPEC_FILE_LOAD
(default:false
): maps toallow-spec-file-load
API Key Settings
TMPL_RAPIDOC_API_KEY_NAME
(default:Authorization
): maps toapi-key-name
TMPL_RAPIDOC_API_KEY_LOCATION
(default:header
): maps toapi-key-location
TMPL_RAPIDOC_API_KEY_VALUE
(default: empty): maps toapi-key-value
Modifying the Template
The basis structure of the viewer is modelled upon docker/index.html.template
. You can alter and modify this HTML template document to further customise the appearance of the API documentation.
Serving Multiple OpenAPI Specifications
The default template for RapiDoc has been modified to support the capability of serving multiple OpenAPI specification which are pre-configured with the server. This is done by specifing the value of TMPL_RAPIDOC_API_MANIFEST_URL
to point to a JSON file containing the catalog of API specification available. Here is an example of the manifest file:
{
"default" : "./specs/openapi.json",
"specs" : [{
"title" : "First Spec",
"url" : "./specs/first-openapi.json",
"description" : "First OpenAPI Specification"
},{
"title" : "Second Spec",
"url" : "./specs/second-openapi.json",
"description" : "Second OpenAPI Specification"
},{
"title" : "OpenAPI Spec",
"url" : "./specs/openapi.json",
"description" : "Default OpenAPI Specification"
}]
}
This particular file instructs the viewer to create a selective menu in the application (the current template places button in the left corner of the application bar) and to configure the viewer to visualise the default option ./specs/openapi.json
. If the manifest URL is omitted the default behaviour falls back to showin the pre-configured API specification identified with the TMPL_RAPIDOC_SPEC_URL
environment variable.
In order to modify how the menu is created and looks and feel it is sufficient to alter two files:
docker/index.html.template
: for the styling and the basic structure of the menu.docker/htmls/api-selector.js
: for modifying the logic associated to the initial loading and selection of the OpenAPI specification.