Skip to content

Commit 2627a67

Browse files
authored
feat(docker): add customizable codegen URLs (#2910)
Refs #2127 Closes #1488 Closes #2688
1 parent ed8fcbe commit 2627a67

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ docker run -d -p 80:8080 -v $(pwd):/tmp -e SWAGGER_FILE=/tmp/swagger.json swagge
127127
docker run -d -p 80:8080 -e BASE_URL=/swagger-editor swaggerapi/swagger-editor
128128
```
129129

130+
You can also customize the different endpoints used by the Swagger Editor with the following environment variables. For instance, this can be useful if you have your own Swagger generator server:
131+
132+
Environment variable | Default value
133+
--- | ---
134+
`URL_SWAGGER2_GENERATOR` | `https://generator.swagger.io/api/swagger.json`
135+
`URL_OAS3_GENERATOR` | `https://generator3.swagger.io/openapi.json`
136+
`URL_SWAGGER2_CONVERTER` | `https://converter.swagger.io/api/convert`
137+
138+
If you want to run the Swagger Editor locally without the Codegen features (Generate Server and Generate Client) you can set the above environment variables to `null` (`URL_SWAGGER2_CONVERTER=null`).
139+
130140
### Building and running an image locally
131141

132142
To build and run a docker image with the code checked out on your machine, run the following from the root directory of the project:

docker-run.sh

100644100755
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ if [[ "${QUERY_CONFIG_ENABLED}" = "true" ]]; then
4040
sed -i "s|queryConfigEnabled: false|queryConfigEnabled: true|" $INDEX_FILE
4141
fi
4242

43+
if [[ "${URL_SWAGGER2_GENERATOR}" ]]; then
44+
if [[ "$URL_SWAGGER2_GENERATOR" != "null" ]]; then
45+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2GeneratorUrl: '${URL_SWAGGER2_GENERATOR}',|g" $INDEX_FILE
46+
else
47+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2GeneratorUrl: null,|g" $INDEX_FILE
48+
fi
49+
fi
50+
51+
if [[ "${URL_SWAGGER2_CONVERTER}" ]]; then
52+
if [[ "$URL_SWAGGER2_CONVERTER" != "null" ]]; then
53+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2ConverterUrl: '${URL_SWAGGER2_CONVERTER}',|g" $INDEX_FILE
54+
else
55+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2ConverterUrl: null,|g" $INDEX_FILE
56+
fi
57+
fi
58+
59+
if [[ "${URL_OAS3_GENERATOR}" ]]; then
60+
if [[ "$URL_OAS3_GENERATOR" != "null" ]]; then
61+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n oas3GeneratorUrl: '${URL_OAS3_GENERATOR}',|g" $INDEX_FILE
62+
else
63+
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n oas3GeneratorUrl: null,|g" $INDEX_FILE
64+
fi
65+
fi
66+
4367
exec nginx -g 'daemon off;'
4468

4569
## Gzip after replacements

0 commit comments

Comments
 (0)