-
-
Save mtvbrianking/57faef18645e1e7f69c59ac18423610c to your computer and use it in GitHub Desktop.
# https://gitlab.com/mbrian/ects-ea-docs/-/ci/lint | |
# This file is a template, and might need editing before it works on your project. | |
image: node:10-alpine | |
# specify the location of the Open API Specification files within your project | |
# and the filename of the specification that you would like to display by default | |
variables: | |
DOCS_FOLDER: "specs" | |
SPEC_TO_DISPLAY: "rects.yaml" | |
# These folders are cached between builds | |
cache: | |
paths: | |
- ./node_modules | |
# publishes all files from the $DOCS_FOLDER together with the static version of SwaggerUI | |
# sets the specification file named in $SPEC_TO_DISPLAY to be displayed by default | |
pages: | |
stage: deploy | |
before_script: | |
- npm install swagger-ui-dist@3.22.1 | |
script: | |
- mkdir public | |
- cp -rp node_modules/swagger-ui-dist/* public | |
- cp -rp $DOCS_FOLDER/* public | |
- sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" public/index.html | |
artifacts: | |
paths: | |
- public | |
only: | |
- master |
ReDoc alternative
image: node:latest
pages:
stage: deploy
script:
- npm install -g redoc-cli
- redoc-cli bundle -o public/index.html documentation/openapi.yaml
artifacts:
paths:
- public
only:
- master
Source: https://medium.com/hoursofoperation/auto-generate-swagger-docs-to-gitlab-pages-ca040230df3a
Hi, thanks for the write-up.
Could u explain a bit what this line is doing, and why it refers to the petstore? Thanks
- sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" public/index.html
Hi, thanks for the write-up.
Could u explain a bit what this line is doing, and why it refers to the petstore? Thanks
- sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" public/index.html
After installation, you'll find that swagger-ui-dist/ dir is created, which contains index.html file. This file renders the swagger.json file that resides here: https://petstore.swagger.io/v2/swagger.json
"sed -t" looks for the line which contains the path to swagger.json file and replaces it with "your" json file, so that it renders your custom json with the same formatting.
Project Structure