swagger-api / swagger-api/swagger-codegen

[JAVASCRIPT] Generating with no host uses localhost instead of a relative path

Open
#9,225 2 comments 1 reaction 0 assignees View on GitHub

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
  1. Create api file with no host or scheme specification
  2. Run command listed above
  3. Look at generated API code with what host and scheme it uses

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.