swagger-api / swagger-api/swagger-codegen
[JAVASCRIPT] Generating with no host uses localhost instead of a relative path
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am generating JavaScript client code with this command:
java -jar ~/tools/swagger-codegen-cli.jar generate -l javascript -i api.yaml -o swagger
My api.yaml does not specify a host or scheme. Based on the docs, it seems to me like this should access the API from a relative path, such as /api/users. However, it tries to access the api at https://localhost/api/users, which does not work.
Command line used for generation
java -jar ~/tools/swagger-codegen-cli.jar generate -l javascript -i api.yaml -o swagger
Steps to reproduce
- Create api file with no host or scheme specification
- Run command listed above
- Look at generated API code with what host and scheme it uses
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the api.yaml example and run the documented Java generation command to inspect the generated JavaScript API code and its selected host and scheme. Compare the result with the no-host behavior described in the Swagger API host and base path documentation. Done means generation without a host or scheme uses a relative path instead of https://localhost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100