Reputation: 66
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?
Upvotes: 3
Views: 11228
Reputation: 567
If you check OpenAPI.read() it accepts either
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.
You can use swagger editor to switch json file type to yaml. Swagger editor >> Edit >> Convert to YAML >> downloaded file move it to filePath
Upvotes: 2
Reputation: 39
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
Upvotes: 1