OpenAPITools / OpenAPITools/openapi-generator

[BUG] 5.0.0 breaks generator if servers url relative

Open
#8,266 16 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi recently switch from openapi-generator-maven-plugin@4.3.1 to 5.0.0 and the generation of my swagger did not work anymore.

After hours of search, I finaly found that it was mu servers > url value that breaked the generation.
Of course my swagger is valid according to https://apitools.dev/swagger-parser/online/ (and many others).
And also specification : https://swagger.io/specification/#server-object

Field Name Type Description
url string REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative
Step to reproduce :

Take the classic petstore : https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml
Change

servers:
  - url: http://petstore.swagger.io/v1

To

servers:
  - url: /v1

Run

java -jar openapi-generator-cli.jar generate -i <path_to/petstore.yaml> -g spring

Breaks with error (unclear at all)
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

I guess it breaks all generator cause it also break validate command.

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 by reproducing the failure with the OpenAPI petstore.yaml example, changing servers.url to /v1, and running the Java CLI generate and validate commands. Trace how the generator and validator handle the relative server URL; done means both commands accept the valid specification without the reported parsing error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.