swagger-api / swagger-api/swagger-ui

Swagger UI within docker and one (or multiple) referenced ($ref) YAML file(s)

Open
#5,008 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Content & configuration

Swagger/OpenAPI definition:

Not the full YAML file but an extract to identify what's the purpose of this improvement I think that would be nice

paths:
 /{ueContextId}/provide:
   post:
     summary: Namf_Location ProvideLocation service Operation
     tags:
       - Provide Location
     operationId: ProvideLocation
     parameters:
       - name: ueContextId
         in: path
         description: UE Context Identifier
         required: true
         schema:
           type: string
     requestBody:
       content:
         application/json:
           schema:
             $ref: '#/components/schemas/RequestUELocation'
       required: true
     responses:
       '200':
         description: Expected response to a valid request
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/ProvideUELocation'
       '403':
         $ref: './TS29571_CommonData.yaml#/components/responses/403'
Is your feature request related to a problem?

The current docker image already downloadable allows the user to specify its own JSON / YAML file as soon as the container ran, thanks to the below CLI :

docker run -p 80:8080 -e SWAGGER_JSON=/foo/openapi.yaml -v /bar:/foo swaggerapi/swagger-ui

But in case the current YAML file (openapi.yaml) uses an external file reference (see $ref: './TS29571_CommonData.yaml#/components/responses/403' above), Swagger-UI will not be able to handle it.

Describe the solution you'd like

In the docker-run.sh file I would have replaced the link to the JSON file by a link on each file in its current directory :

if [[ -f $SWAGGER_JSON ]]; then
# OLD CODE 
  # cp -s $SWAGGER_JSON $NGINX_ROOT
# NEW CODE 
  cd $NGINX_ROOT ; ln -s $(dirname $SWAGGER_JSON)/* .

# The others lines stay as they are
  REL_PATH="./$(basename $SWAGGER_JSON)"
  sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
  sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
else
  sed -i "s|https://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
  sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE
fi

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docker-run.sh and trace how SWAGGER_JSON is copied into NGINX_ROOT; run the documented docker command with an openapi.yaml and referenced TS29571_CommonData.yaml. Done means the container serves both files so the external $ref resolves while the existing API_URL behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, shell
Domain
devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.