Skip to content

swagger-gradle-plugin - Support for ModelConverter #2971

@peetzen

Description

@peetzen

I am experimenting with the new Swagger Gradle plugin and it works very well!
One important feature I am missing, is the possibility to add custom ModelConverter through the gradle resolve{} task configuration. There are configuration options for filterClass, readerClass and scannerClass but not for (multiple) ModelConverter classes.

Background:
I am using dropwizard with PropertyNamingStrategy.SNAKE_CASE for the ObjectMapper and want to generate a static openapi.yaml file through the gradle resolve{} task.

Code example:
Something that I am trying to achieve through the gradle task configuration could be similar to:

ModelConverters.getInstance().addConverter(new SnakeCaseConverter());

Custom Converter:

public class SnakeCaseConverter extends ModelResolver {

    public SnakeCaseConverter() {
        super(createMaper());
    }

    private static ObjectMapper createMaper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        return mapper;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions