Skip to content

Commit b5a0d17

Browse files
authored
Revise the usage of OpenAPI Generator online (docker image) (#73)
* revise openapi generator online image usage * remove -o from command
1 parent d93bf4e commit b5a0d17

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,34 @@ The generated code will be located under `./out/go` in the current directory.
157157

158158
The openapi-generator-online image can act as a self-hosted web application and API for generating code. This container can be incorporated into a CI pipeline, and requires at least two HTTP requests and some docker orchestration to access generated code.
159159

160-
Example usage (note this assumes `jq` is installed for command line processing of JSON):
160+
Example usage:
161161

162162
```sh
163-
# Start container and save the container id
164-
CID=$(docker run -d openapitools/openapi-generator-online)
163+
# Start container at port 8888 and save the container id
164+
> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online)
165+
165166
# allow for startup
166-
sleep 5
167-
# Get the IP of the running container
167+
> sleep 10
168+
169+
# Get the IP of the running container (optional)
168170
GEN_IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}' $CID)
169-
# Execute an HTTP request and store the download link
170-
RESULT=$(curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
171-
"swaggerUrl": "https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml"
172-
}' 'http://localhost:8188/api/gen/clients/python' | jq '.link' | tr -d '"')
173-
# Download the generated zip and redirect to a file
174-
curl $RESULT > result.zip
175-
# Shutdown the swagger generator image
176-
docker stop $CID && docker rm $CID
177-
```
178171

179-
In the example above, `result.zip` will contain the generated client.
172+
# Execute an HTTP request to generate a Ruby client
173+
> curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' \
174+
-d '{"openAPIUrl": "https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml"}' \
175+
'http://localhost:8888/api/gen/clients/ruby'
176+
177+
{"code":"c2d483d3-3672-40e9-91df-b9ffd18d22b8","link":"http://localhost:8888/api/gen/download/c2d483d3-3672-40e9-91df-b9ffd18d22b8"}
178+
179+
# Download the generated zip file
180+
> wget http://localhost:8888/api/gen/download/c2d483d3-3672-40e9-91df-b9ffd18d22b8
181+
182+
# Unzip the file
183+
> unzip c2d483d3-3672-40e9-91df-b9ffd18d22b8
184+
185+
# Shutdown the openapi generator image
186+
> docker stop $CID && docker rm $CID
187+
```
180188

181189
#### Development in docker
182190

0 commit comments

Comments
 (0)