Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Facing some problem with Swagger generated Json schema.

I have a one base class which of type abstract class. And two classes extends this base class. And main transfer object object contains abstract class filed so that it will acts as a common placeholder for two types of extended classes

I can achieve this by using Jackson annotations. But Swagger is respecting jackson annotations.

Using Jackson:

@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.WRAPPER_OBJECT)
    @JsonSubTypes({@JsonSubTypes.Type(ExtendedClass1.class), @JsonSubTypes.Type(ExtendedClass2.class)})
    private BaseClass baseClass;

Swagger just says, need to pass the object of type base class, but I want swagger to construct the json schema with the details of the extended classes and display it.

Swagger json schema looks like:

"baseClass" : "BaseClass"

But I want swagger to expand the extended classes also.

Is there any way I can impose swagger to use the jackson annotations?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.