swagger-api / swagger-api/swagger-codegen

[typescript-nodejs] Dynamically setting basepath

Open
#3,817 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript General: Suggestion
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I want to be able to pass the basePath as a parameter to the sdk/api. At the moment, it seems to be hardcoded as a variable called var defaultBasePath = "https://localhost/api"

If you want to override it currently, you have to pass a parameter to each model constructor

I would like to be able to call a function / method / property in order to modify it

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./spec.json -l typescript-node

Steps to reproduce

probably need to modify the typescript templates to add the missing functionality

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 typescript-node generation templates and the generated SDK's defaultBasePath variable. Run the shown swagger-codegen command with a representative spec, then verify how basePath is currently passed to model constructors. Done means the generated SDK exposes one documented way to override the base path without passing it to every model constructor.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.