3

I'm trying to parse an OPEN API URL this is the following code for it

OpenAPI openAPI = new OpenAPIV3Parser().read("https://petstore3.swagger.io/api/v3/openapi.json");

which is giving me the following exception

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonFactoryBuilder

The library which i'm using is

<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
<version>2.0.19</version>

Is there any other library which i can use for parsing OPEN API 3.0?

1
  • Seems like you have multiple jackson core libraries. Can you exclude one. You can check that by firing mvn:dependency:tree Commented Jul 23, 2020 at 12:39

2 Answers 2

2

If you check OpenAPI.read() it accepts either

  1. (String location) or
  2. (String location, List auths, ParseOptions resolve)

But what you are trying with is "String URL", instead try giving (String "filePath") with below dependency. It will work like charm.

<dependency>
  <groupId>io.swagger.parser.v3</groupId>
  <artifactId>swagger-parser</artifactId>
  <version>2.0.26</version>
</dependency> 

Note:

 OpenAPI openAPI = new OpenAPIV3Parser().read(filePath) for OpenAPI3.0
 Swagger swagger = new SwaggerParser().read(filePath)   for Swagger2.0

Check out below read() snippet handy for your clarity.

enter image description here

You can use swagger editor to switch json file type to yaml. Swagger editor >> Edit >> Convert to YAML >> downloaded file move it to filePath

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

Use the dependency:

<dependency>
  <groupId>io.swagger.parser.v3</groupId>
  <artifactId>swagger-parser</artifactId>
  <version>2.0.25</version>
</dependency>

This works for me parsing OpenAPI and Swagger Specifications

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.