question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] openapi-generator-maven-plugin version 5.0.0 does not work for OpenApi 3.0 yml-files

See original GitHub issue
Description

I have a perfect OpenApi 3.0.1 yml-file. openapi-generator-maven-plugin v4.3.1 generates perfect code. When changing the plugin version from 4.3.1 to 5.0.0 I get a syntax error. No other changes.

[INFO] [INFO] — openapi-generator-maven-plugin:5.0.0:generate (api) @ core-automation — [ERROR] failed to read resource listing com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘openapi’: was expecting (JSON String, Number, Array, Object or token ‘null’, ‘true’ or ‘false’) at [Source: (StringReader); line: 1, column: 8]

openapi-generator version

5.0.0

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: my Title
  description: Documentation of my REST APIs.
  ...
Generation Details

mvn install

Steps to reproduce

mvn install

Related issues/PRs

N/A

Suggest a fix

???

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
stephanpelikancommented, Mar 26, 2021

We had the same issue with the URL

/api/admin/v1

It worked for builds on a Linux machine but failed for builds on a Windows machine.

We changed the URL to

http://localhost/api/admin/v1

and now it works.

Two major questions:

  1. Why there is no proper error message instead of Unrecognized token ‘openapi’?
  2. Can the documentation be updated since there is no hint that “absolute URL” is different for Linux and Windows.

From the documentation:

url string 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}.

5reactions
maarten-daalder-isaaccommented, Mar 26, 2021

Hi @stephanpelikan, regarding 1, the code assumes that if there is an error that it isn’t a YAML file and then tries the JSON variant. Which fails due to openapi not being { or other valid JSON token.

Regarding 2, once the upstream library is fixed and the plugin is updated the problem should go away. See also the comment by @wing328 above yours.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Open Api Generator plugin does not work with Maven
I am trying to generate Apis with openapi generator just when i run mvn compile seems like doesn't find any depenncy like jacks...
Read more >
Plugins - OpenAPI Generator
Lists generators available via Open API Generators. openApiMeta, Generates a new generator to be consumed via Open API Generator.
Read more >
openapitools/openapi-generator - Docker Image - Docker Hub
Automated builds of openapi-generator images.
Read more >
OpenAPI 3.0 Tutorial | SwaggerHub Documentation
OpenAPI 3.0 is an open-source format for describing and documenting APIs. ... openapi: 3.0.0 info: version: 1.0.0 title: Sample API ...
Read more >
How to use contract first approach with Open API - LinkedIn
We will be using the openapi-generator-maven-plugin to generate server (interface only to ... <spring-fix.version>3.0.0</spring-fix.version> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found