OpenAPITools / OpenAPITools/openapi-generator

[REQ][typescript-axios] Setting default configuration object as fallback if none is provided

Open
#6,941 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Current state

(I'm new to openAPI, but) As far as i know, with typescript-axios, we would have to pass in a configuration object into each generated API Factory. However, something like the accessToken property might always get resolved in the same way from each Factory.

AuthenticationApiFactory().login({ email: '123', password: '123' })
.then(res => {
  PostsApiFactory({ accessToken: 'TOKEN' }) // Configuration object has to be passed in
    .postsGet()
})

Possible solution

It would be nice to have something like a default Configuration object, which gets used if none got injected into the Factory:

baseAPI.configuration.accessToken = () => {
    // Resolve Token
}

AuthenticationApiFactory().login({ email: '123', password: '123' })
.then(res => {
  PostsApiFactory() // Since no configuration object has been passed, use baseAPI.configuration
    .postsGet()
})
openapi-generator version

docker: openapitools/openapi-generator-cli v4.2.2

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 in the typescript-axios generator and trace the generated API factory entry points, especially how they receive a configuration object. Define how a shared default configuration is selected when no configuration is passed, while an explicit configuration remains authoritative; done means the requested factory usage works consistently across generated APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.