Skip to content

[BUG] [TYPESCRIPT] BasePath is incorrectly using full urls instead of relative ones when a dash is present in the server url #22767

@Romanow88

Description

@Romanow88

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating typescript clients (and probably other clients) the URL is incorrectly determined to be absolute, in case the url has "-", "@", "~", "." in it.

openapi-generator version

7.19.0, 7.20.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: OpenAPI Petstore
  description: "sample spec"
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: /api-v3
tags: []
paths: {}
components:
  schemas: {}
  securitySchemes: {}
Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
   -i test.yaml \
   -g typescript-angular \
   -o ./typescript-angular
Steps to reproduce

Generate a typescript-angular, open api.base.service.ts and check the protected basePath = "{{{baseUrl}}}"

Related issues/PRs
Suggest a fix

Update Regex in URLPathUtils#URLPathUtils to handle the above mentioned symbols.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions