OpenAPITools / OpenAPITools/openapi-generator

swagger: '2.0' spec generation is fine but validation fails at runtime

Open
#10,358 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I use openapi-generator-maven-plugin (version - 5.1.0) to generate code for a swagger 2 specification. Generation and build works fine but when run, a validation failure occur with following error:
Caused by: ValidationException{message='provided object should contain property openapi', keyword='required', input={"swagger":"2.0".....

For me it looks like it is trying to validate the spec assuming it is openapi 3.
The code generator used is java-vertx-web.

What is the correct way to specify swagger version to use?

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 runtime validation failure with openapi-generator-maven-plugin 5.1.0, the java-vertx-web generator, and the Swagger 2.0 specification described in the issue. Trace where the generated runtime selects or validates the specification version; done means Swagger 2.0 generation runs without an OpenAPI 3-only validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.