swagger-api / swagger-api/swagger-parser
Dependency conflict with Spring boot
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Hi, I am working on a spring boot project and we want to parse swagger yaml files.
First I tried adding this dependency to my project
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.17</version>
</dependency>
and then making a parser object as such
OpenAPI openAPI = new OpenAPIV3Parser().read("./swagger.json");
but I keep getting this error thrown when it tries to make the object.
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonFactoryBuilder
at io.swagger.v3.parser.ObjectMapperFactory.createJsonFactory(ObjectMapperFactory.java:41)
at io.swagger.v3.parser.ObjectMapperFactory.createJson(ObjectMapperFactory.java:18)
at io.swagger.v3.parser.ObjectMapperFactory.createJson(ObjectMapperFactory.java:14)
at io.swagger.v3.parser.OpenAPIV3Parser.<clinit>(OpenAPIV3Parser.java:38)
at io.datallama.api.SwaggerTest.main(SwaggerTest.java:11)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonFactoryBuilder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Then what I did is I found a project on git hub that was already working (https://github.com/kalaspuffar/swagger-reader.git) and when I added the swing parent to his pom file I started getting the same error that is in my project.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Has anyone encountered this before or know how to fix it?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Maven POM dependency for io.swagger.parser.v3:swagger-parser and the Spring Boot 2.0.5.RELEASE parent, then inspect the resolved Jackson dependencies and dependency tree. Done means the Spring Boot project can instantiate OpenAPIV3Parser and read the Swagger file without the JsonFactoryBuilder NoClassDefFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring-boot
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100