I want to build a Maven module using the openapi-generator-maven-plugin to generate both server code and client code from two openapi 3 specs. I want the server code to use Spring boot, so I have these settings:
<generatorName>spring</generatorName>
<library>spring-boot</library>
This works fine and I need io.swagger.core.v3:swagger-annotations and jakarta.validation:jakarta.validation-api for OAS 3 annotations and validation.
However, for the client code, I want to use WebClient from Spring, the only settings I could find was:
<generatorName>java</generatorName>
<library>webclient</library>
The client code generates, but the issue is, it requires the older io.swagger:swagger-annotations and javax.validation:validation-api.
I want to avoid having different sets of libraries. Is there a setting for both the server and client code generations that uses the same set of annotation and validation libraries? Preferably both use io.swagger.core.v3:swagger-annotations and jakarta.validation:jakarta.validation-api.
The spring generator for servers and the java generator with webclient for clients use different library versions. Just use the spring generator for both server and client code, as it supports both scenarios and uses the newer dependencies you're looking for.
Change your configuration to:
<generatorName>spring</generatorName>
<library>spring-webclient</library>
You may also need to add the <configOptions> section with interfaceOnly set to true for the client to avoid generating unnecessary server components:
<configOptions>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3> <!-- For Spring Boot 3 compatibility -->
</configOptions>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With