-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[online] Revert GENERATOR_HOST explicit setting #3287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jimschubert
merged 1 commit into
OpenAPITools:master
from
jimschubert:revert-online-host-setting
Jul 6, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,54 @@ | ||
# OpenAPI generated server | ||
|
||
Spring Boot Server | ||
A Spring Boot Server application which hosts a client/server generator API. | ||
|
||
|
||
## Overview | ||
|
||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. | ||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub or one of 100+ client packages. | ||
|
||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. | ||
|
||
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) | ||
|
||
Start your server as a simple java application | ||
## Building | ||
|
||
Refer to [root README](../../README.md) for build directions. | ||
|
||
## Running | ||
|
||
### Via command line | ||
|
||
Running is as simple as: | ||
|
||
``` | ||
java -jar ./target/openapi-generator-online.jar | ||
``` | ||
|
||
This exposes the API on local port 8080. | ||
|
||
Springfox supports configuration of the "host" value in the output OpenAPI document by setting the `Host` HTTP header in the request. | ||
To set this explicitly, pass the system property `springfox.documentation.swagger.v2.host` with the desired host. For example: | ||
|
||
``` | ||
java -Dspringfox.documentation.swagger.v2.host=example.com:8888 -jar ./target/openapi-generator-online.jar | ||
``` | ||
|
||
### Via Docker | ||
|
||
After building from source, change to this module directory (`cd modules/openapi-generator-online`) and build the docker image: | ||
|
||
``` | ||
docker build -t openapitools/openapi-generator-online:latest . | ||
``` | ||
|
||
Now, run the docker image: | ||
|
||
``` | ||
docker run -d -p 8888:8080 \ | ||
-e GENERATOR_HOST=http://localhost:8888 \ | ||
openapitools/openapi-generator-online | ||
``` | ||
|
||
Change default port value in application.properties | ||
The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. Do we keep GENERATOR_HOST?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbornet
GENERATOR_HOST
is still used here:openapi-generator/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/GenApiService.java
Line 161 in 109808e
This isn't "correct" and will need to be changed. The previous value here would be incorrect for all invocations unless bound to port 80, which I believe requires super user privileges. This change at least causes the variable to match the exposed port.
Many people try out docker images by binding to random host ports (
-P
), and when doing this…GENERATOR_HOST
will be useless and the file download link generation won't work.This PR limits focus to get the proxying host setting working on the server. I can look at the other work later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #3288 to address this other concern.