Bug Report Checklist
Description
The generator prefixes the basePath with http://localhost when servers[0].url == '/api'
resulting in a basePath == 'http://localhost/api'
if the generated client is used in multiple domains the basePath should be set relative to make the generated client more flexible i think??
Also the openapi specs explicitly state that the url may be relative which isnt the possible with this generator at the moment
4.8.5.1 Fixed Fields
REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in {brackets}.
openapi-generator version
5.2 and master
OpenAPI declaration file content or url
This is an example spec.yaml
openapi: "3.0.3"
info:
title: "test api"
description: "unofficial api test"
termsOfService: "https://localhost/api/"
contact:
name: "API Support"
url: "https://localhost/helpdesk/"
email: "info@localhost"
license:
name: MIT
version: v1
servers:
- url: "/api"
tags:
- name: account
paths:
"/account/v1/json/login"
post:
description: ""
tags:
- account
operationId: "account.login"
responses:
default:
description: ""
content:
"application/json":
schema:
"$ref": "#/components/schemas/account.login.response.default"
requestBody:
description: ""
content:
"application/json":
schema:
type: object
properties:
emailAddress:
type: string
password:
type: string
Generation Details
Steps to reproduce
- save the example file as
api.yaml
- run
./openapi-generator-cli.jar generate -g typescript-axios -i api.yaml -o client
- the generated client library added http://localhost to the relative url
Related issues/PRs
Suggest a fix
Bug Report Checklist
Description
The generator prefixes the basePath with http://localhost when servers[0].url == '/api'
resulting in a basePath == 'http://localhost/api'
if the generated client is used in multiple domains the basePath should be set relative to make the generated client more flexible i think??
Also the openapi specs explicitly state that the url may be relative which isnt the possible with this generator at the moment
4.8.5.1 Fixed Fields
openapi-generator version
5.2 and master
OpenAPI declaration file content or url
This is an example
spec.yamlGeneration Details
Steps to reproduce
api.yaml./openapi-generator-cli.jar generate -g typescript-axios -i api.yaml -o clientRelated issues/PRs
Suggest a fix
openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java
Line 69 in 870ef3a