OpenAPITools / OpenAPITools/openapi-generator

[BUG] Server URL '/' removed from inputs to generator

Open
#13,494 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

A URL of / in the servers section of an OpenAPI 3 document is replaced with the empty string

openapi-generator version

Gradle plug-in 5.3.0 (also recreated in latest code)

OpenAPI declaration file content or url
...
servers:
   url: /
   description: An API handing off the root of the server
...
Generation Details
openapi-generator generate -i src/main/api/openapi.yaml --library openliberty -t ~/custom-template -g jaxrs-spec --global-property debugSupportingFiles
Steps to reproduce

Use a template that uses {{servers.0.url}} in the files.

Related issues/PRs

The behaviour appears to have been added as part of #7533 where trailing slashes were being removed from the servers.

Suggest a fix

Will raise a PR to add code to only remove the trailing / if there are characters preceding it.

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

Reproduce the issue with the shown OpenAPI YAML and the openapi-generator generate command, using a template that references {{servers.0.url}}. Read the server URL handling introduced by #7533. Done means a root URL of / remains /, while trailing-slash removal still applies when characters precede the slash.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.