Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docket.ignoredParameterTypes() removes classes completly #893

Closed
thomseno opened this issue Aug 4, 2015 · 4 comments
Closed

Docket.ignoredParameterTypes() removes classes completly #893

thomseno opened this issue Aug 4, 2015 · 4 comments
Labels
Milestone

Comments

@thomseno
Copy link
Contributor

thomseno commented Aug 4, 2015

Just migrated our project from swagger-springmvc to springfox 2.1.2 and recognized, that my ignoredParameterTypes are missing completely in swagger:
swagger-springmvc:
swagger_ui
swagger_ui
springfox:
swagger_ui
swagger_ui
SwaggerConfig:
Just ignoring org.joda.time classes

        return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(new ApiInfo("IBS", "REST services", apiVersion, null, null, null, null))
            .ignoredParameterTypes(DateTime.class)
            .ignoredParameterTypes(LocalDate.class)
            .ignoredParameterTypes(LocalTime.class)
            .ignoredParameterTypes(LocalDateTime.class)
            .pathMapping("/api/v1")
            .groupName("1_rest")
            .select()
            .paths(ibsRestPaths())
            .build();
@dilipkrish
Copy link
Member

@thomseno that was a bug unfortunately. the right way to hide properties is to either use an annotation to mark it as such @ApiModelProperty(hidden=true) to hide specific properties. Or if you're only hiding it cos' its generating deep models you don't care about consider using the docket.directModelSubstitute(LocalDate.class, String.class)

@dilipkrish dilipkrish added this to the 2.2.0 milestone Aug 6, 2015
@thomseno
Copy link
Contributor Author

thomseno commented Aug 6, 2015

Hi @dilipkrish thanks for the answer. The intention was to prevent generation of deep models. But if I use docket.directModelSubstitute(LocalDate.class, String.class) the original type of the field (LocalDate) will not be visible anymore, because something like this will be generated:

{
    "printId": "string",
    "printDate": "string"
}

So if I have something like this

{
    "validFrom": "string",
    "validTo": "string"
}

it's hard to decide what input the service expects (LocalDate or LocalDateTime). So how do I handle this?

@dilipkrish
Copy link
Member

@thomseno that could go in the description via @ApiModelProperty#notes

@cbornet
Copy link
Contributor

cbornet commented Feb 2, 2016

@thomseno You can use this:

docket
.directModelSubstitute(LocalDate.class, java.sql.Date.class)
.directModelSubstitute(LocalDateTime.class, java.util.Date.class)

You will get

                "localdate":
                {
                    "type": "string",
                    "format": "date"
                },
                "localdatetime":
                {
                    "type": "string",
                    "format": "date-time"
                },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants