Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !3287
An error occurred while fetching the assigned milestone of the selected merge_request.

[online] Revert GENERATOR_HOST explicit setting

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jim Schubert requested to merge github/fork/jimschubert/revert-online-host-setting into master 6 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 3

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Removing GENERATOR_HOST usage, and moving configuration to server. We may want to consider removing GENERATOR_HOST completely from GenApiServer (if possible), and just using built-in support for retrieving the host/port. I was trying to reduce confusion around this variable in the code that is removed by this PR, but upon discussion it seems the environment variable just adds confusion and is therefore not the appropriate configuration to target.

Compare
  • master (base)

and
  • latest version
    c392b016
    1 commit, 2 years ago

3 files
+ 47
- 19

    Preferences

    File browser
    Compare changes
modules/openapi-‎generator-online‎
src/main/…/…/…/…/o‎nline/configuration‎
OpenAPIDocument‎ationConfig.java‎ +0 -12
Docke‎rfile‎ +4 -3
READ‎ME.md‎ +43 -4
modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/configuration/OpenAPIDocumentationConfig.java
+ 0
- 12
  • View file @ c392b016

  • Edit in single-file editor

  • Open in Web IDE


@@ -52,7 +52,6 @@ public class OpenAPIDocumentationConfig {
String version = properties.getProperty("version", "unknown");
return new ApiInfoBuilder()
.title("OpenAPI Generator Online")
.description("This is an online openapi generator server. You can find out more at https://github.com/OpenAPITools/openapi-generator.")
@@ -66,18 +65,7 @@ public class OpenAPIDocumentationConfig {
@Bean
public Docket customImplementation(){
String host;
try {
String baseUrl = System.getenv("GENERATOR_HOST");
if (baseUrl == null) {
baseUrl = System.getProperty("generator.host", "http://localhost");
}
host = new URI(baseUrl).getHost();
} catch (URISyntaxException e) {
host = "";
}
return new Docket(DocumentationType.SWAGGER_2)
.host(host)
.select()
.apis(RequestHandlerSelectors.basePackage("org.openapitools.codegen.online.api"))
.build()
modules/openapi-generator-online/Dockerfile
+ 4
- 3
  • View file @ c392b016

  • Edit in single-file editor

  • Open in Web IDE


@@ -4,9 +4,10 @@ WORKDIR /generator
COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar
ENV GENERATOR_HOST=http://localhost
# GENERATOR_HOST can be used to determine the target location of a download link.
# The default value asumes binding to host via: docker -p 8080:8080 image_name
ENV GENERATOR_HOST=http://localhost:8080
EXPOSE 8080
CMD ["java", "-jar", "/generator/openapi-generator-online.jar"]
CMD ["java", "-jar", "/generator/openapi-generator-online.jar" ]
modules/openapi-generator-online/README.md
+ 43
- 4
  • View file @ c392b016

  • Edit in single-file editor

  • Open in Web IDE

# 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.
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/jimschubert/revert-online-host-setting

Menu

Explore Projects Groups Snippets