Which library do you use to generate the API definition?

 

 

From: <[email protected]> on behalf of Gökhan Ayrancıoğlu 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Tuesday, November 14, 2017 at 01:59
To: Swagger <[email protected]>
Subject: How to define abstract property in Model - Swagger

 

I am trying to implement Swagger to my rest api which is development with Java 
Spring Boot. There is a problem on model parts of swagger. The problem is 
Detail abstract class and extended classes are not seem in Swagger UI's and the 
other output files. I am just seeing the baseclass with detail object as  null.

 

You can find the code on below.

 
public class BaseClass {
 
   @ApiModelProperty(value ="Id of baseClass.", readOnly = true)
    private String     id;
 
  @ApiModelProperty(value = "Description of baseClass.")
    private String     description;
 
    @ApiModelProperty(value = "Value is equal to subclass json object value.")
    private Detail     detail;
...
 

My abstract class which is attribute of baseclass.

 
@ApiModel(value = "Detail",subTypes = {Page.class,Rank.class},discriminator = 
"detail")
public abstract class Detail {
}
 

My extended classes from Detail Abstract Class;

 

Page Class:
@ApiModel(parent = Detail.class,value = "Page")
public class Page extends Detail {
       @ApiModelProperty(value = "The page URL.")
        private String                  url;
    ...
 

Rank Class:

 
 @ApiModel(parent = Detail.class,value = "Rank")
 public class Rank extends Detail {
 
     @ApiModelProperty(value = "Number List of Rank")
     private List<String> numbers;
    ...
-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to