|
1 | 1 | # OpenAPI generated server |
2 | 2 |
|
3 | | -Spring Boot Server |
| 3 | +A Spring Boot Server application which hosts a client/server generator API. |
4 | 4 |
|
5 | 5 |
|
6 | 6 | ## Overview |
| 7 | + |
7 | 8 | This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. |
8 | | -By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. |
| 9 | +By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub or one of 100+ client packages. |
| 10 | + |
9 | 11 | This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. |
10 | 12 |
|
11 | 13 | The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) |
12 | 14 |
|
13 | | -Start your server as a simple java application |
| 15 | +## Building |
| 16 | + |
| 17 | +Refer to [root README](../../README.md) for build directions. |
| 18 | + |
| 19 | +## Running |
| 20 | + |
| 21 | +### Via command line |
| 22 | + |
| 23 | +Running is as simple as: |
| 24 | + |
| 25 | +``` |
| 26 | +java -jar ./target/openapi-generator-online.jar |
| 27 | +``` |
| 28 | + |
| 29 | +This exposes the API on local port 8080. |
| 30 | + |
| 31 | +Springfox supports configuration of the "host" value in the output OpenAPI document by setting the `Host` HTTP header in the request. |
| 32 | +To set this explicitly, pass the system property `springfox.documentation.swagger.v2.host` with the desired host. For example: |
| 33 | + |
| 34 | +``` |
| 35 | +java -Dspringfox.documentation.swagger.v2.host=example.com:8888 -jar ./target/openapi-generator-online.jar |
| 36 | +``` |
| 37 | + |
| 38 | +### Via Docker |
| 39 | + |
| 40 | +After building from source, change to this module directory (`cd modules/openapi-generator-online`) and build the docker image: |
| 41 | + |
| 42 | +``` |
| 43 | +docker build -t openapitools/openapi-generator-online:latest . |
| 44 | +``` |
| 45 | + |
| 46 | +Now, run the docker image: |
| 47 | + |
| 48 | +``` |
| 49 | +docker run -d -p 8888:8080 \ |
| 50 | + -e GENERATOR_HOST=http://localhost:8888 \ |
| 51 | + openapitools/openapi-generator-online |
| 52 | +``` |
14 | 53 |
|
15 | | -Change default port value in application.properties |
| 54 | +The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location. |
0 commit comments