Skip to content
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

[BUG] openapi-generator-online require environment variable to define scheme/host/port in generated download links #3288

Closed
5 of 6 tasks
jimschubert opened this issue Jul 6, 2019 · 2 comments
Milestone

Comments

@jimschubert
Copy link
Member

jimschubert commented Jul 6, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The GENERATOR_HOST environment variable in openapi-generator-online isn't necessary and can't accurately be set in some cases.

openapi-generator version

all?

OpenAPI declaration file content or url
Command line used for generation

n/a

Steps to reproduce
  • Start a docker image and bind all exposed ports to random ports on the host:
docker run -it -P --rm openapitools/openapi-generator-online:v4.0.2
  • Observe: GENERATOR_HOST would need to be passed at docker run, which isn't possible when docker randomizes port assignments.
    See

image

Related issues/PRs

#3287

Suggest a fix

Remove GENERATOR_HOST and pull scheme/host/port from request details.

GENERATOR_HOST itself adds some other complexity, for example if a single nginx configuration is used to proxy multiple addresses to the same instance of the service (e.g. api.example.com, example.com, and latest.example.com could point to the same service via single nginx configuration, but would all require separate processes due to GENERATOR_HOST.

@jimschubert
Copy link
Member Author

I found that this condition is really only a problem when running from within a docker container. Setting the default value to an empty string appears to fix the bug. Running the service from command line or other means without the GENERATOR_HOST variable also works as expected. I opened #3289 to fix and add some documentation around the usage of the variable.

@jimschubert jimschubert added this to the 4.0.3 milestone Jul 7, 2019
@jimschubert
Copy link
Member Author

Resolved by #3289

➜  openapi git:(master) docker run -it -P  -d --rm openapitools/openapi-generator-online:latest
7405816154d9a62f6b68ffcce4004a6d8ee34084e0aae0e55806c8913705e835
➜  openapi git:(master) ➜  openapi git:(master) curl -s \
    -X POST "http://localhost:32776/api/gen/servers/go-server" \
    -H "Accept: */*" \
    -H "Content-Type: application/json" \
    -d "{ \"openAPIUrl\": \"https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml\"}" \
   | jq .
{
  "code": "176970e4-ad32-49d5-8bff-7f7be2c89be4",
  "link": "http://localhost:32776/api/gen/download/176970e4-ad32-49d5-8bff-7f7be2c89be4"
}

Note the http://localhost:32776 in the curl POST and the response's generated link location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant