micronaut-openapi icon indicating copy to clipboard operation
micronaut-openapi copied to clipboard

Add support for @JsonView

Open daltonconley opened this issue 2 years ago • 3 comments

Feature description

It appears there is no support for @JsonView annotation. This was added to swagger-core in https://github.com/swagger-api/swagger-core/pull/2662

I'd like to be able to exclude certain fields from the response body schema based on the @JsonView configuration but they get added to the schema regardless of the annotation now so both of my responses with the same object, but different views have the exact same schema.

daltonconley avatar Sep 05 '22 16:09 daltonconley

Have you tried specific names for the different schemas? It might be you are hitting the problem documented in https://micronaut-projects.github.io/micronaut-openapi/latest/guide/#schemasNaming

...if you have two properties of same type with @Schema annotation without name set, Micronaut will accidentally override one definition with another

kevin-wise avatar Sep 15 '22 16:09 kevin-wise

@kevin-wise Just did a bit of testing. I don't believe that is the issue I am seeing. I would also expect there be some reference to JsonView within this repo, but there doesn't appear to be.

My current workaround is to define a different class based on my view and supply that as the schema implementation class.

daltonconley avatar Sep 20 '22 18:09 daltonconley

@daltonconley I understand what you're talking about, but it would be very nice if you create a repository with an example of what you want to see so that I can immediately test JsonView support

altro3 avatar Sep 21 '22 19:09 altro3