Reputation: 4190
swagger-maven-plugin
uses Jackson to get information about DTO properties.
I have my own Jackson module (that extends com.fasterxml.jackson.databind.module.SimpleModule
) - how can I inject it into swagger lifecycle?
Upvotes: 2
Views: 1551
Reputation: 4190
You can create Swagger extension and customize default mapper there:
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.jaxrs.ext.AbstractSwaggerExtension;
import io.swagger.util.Json;
public class MyExtension extends AbstractSwaggerExtension {
public MyExtension() {
final ObjectMapper swaggerMapper = Json.mapper();
swaggerMapper.registerModule(...);
}
}
In pom.xml
modify your swagger-maven-plugin
configuration:
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<configuration>
<apiSources>
<apiSource>
<swaggerExtensions>
<swaggerExtension>
com.example.MyExtension
</swaggerExtensions>
</swaggerExtensions>
</apiSource>
</apiSources>
</configuration>
Upvotes: 2