Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2731
Closed
Open
Issue created Apr 24, 2019 by Administrator@rootContributor6 of 6 checklist items completed6/6 checklist items

[BUG] [typescript-angular] Base Path can't be set to '<empty string>'

Created by: DanielHabenicht

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

If the basePath in the config is set to '' (empty string). The configuration is ignored and 'http://localhost' is used instead. That is unexpected behaviour.

Background

The basePath of the typescript-angular generated Files are currently set to 'http://localhost' (as a Fallback). When trying to setup the basePath to '' (empty String) the config is not used as the generated line of code configuration.basePath || basePath || this.basePath; is evaluated to false, because empty string in javascript is false.

  protected basePath = 'http://localhost';
  public configuration = new Configuration();

  constructor(
    protected httpClient: HttpClient,
    @Optional() @Inject(BASE_PATH) basePath: string,
    @Optional() configuration: Configuration
  ) {
    if (configuration) {
      this.configuration = configuration;
      this.configuration.basePath = configuration.basePath || basePath || this.basePath;
    } else {
      this.configuration.basePath = basePath || this.basePath;
    }
  }
openapi-generator version

4.0.0-beta2

OpenAPI declaration file content or url
Command line used for generation
npm install @openapitools/openapi-generator-cli@0.0.8-4.0.0-beta2
openapi-generator generate -i swagger.json -g typescript-angular -o projects/client-api/src/lib/ --additional-properties="ngVersion=6.1.7" --additional-properties="supportsES6=true"
Steps to reproduce
  1. Generate typescript-angular package from openapi.config
  2. Configure the ApiModule in app.module.ts
  3. Use a service from the generated typescript-angular package.
Related issues/PRs

Nothing found.

Suggest a fix

Two ways:

  1. Remove the fallback basePath by setting it to '' (empty string)
  2. Fix the evalutation basePath property.
Assignee
Assign to
Time tracking