I have the following ApiModel for my endpoint -
public class CreateConfigRequest {
@ApiModelProperty(example = "hive")
String entityType;
@ApiModelProperty(example = "imports")
String entityNamespace;
@ApiModelProperty(example = "hotel")
String entityName;
@ApiModelProperty(example = "{\"name\": \"hotel\", \"batch\": {\"type\": \"FullScan\"}}")
JobConfig content;
}
Where JobConfig is another pojo class. Code below :
@Data
public class JobConfig {
@NonNull private String name;
@NonNull private BatchSpec batch;
private ProfileConfig profile;
private ValidateConfig validate;
private ActionConfig action;
}
Which is basically the structure of the POJO.
How it should look like -
Basically i am looking to understand how i can set it to a default JSON structure.
If you don't want to include profile
, validate
and action
at all in your JSONs you can simply use @JsonIgnore
as follows:
@Data
public class JobConfig {
@NonNull private String name;
@NonNull private BatchSpec batch;
@JsonIgnore
private ProfileConfig profile;
@JsonIgnore
private ValidateConfig validate;
@JsonIgnore
private ActionConfig action;
}
If you simply don't want to list them in Swagger documentation, you can use @ApiModelProperty
as follows:
@Data
public class JobConfig {
@NonNull private String name;
@NonNull private BatchSpec batch;
@ApiModelProperty(hidden = true)
private ProfileConfig profile;
@ApiModelProperty(hidden = true)
private ValidateConfig validate;
@ApiModelProperty(hidden = true)
private ActionConfig action;
}
Given that you don't want to hide properties but instead show a more realistic example, try the following:
@Data
public class JobConfig {
@NonNull
@ApiModelProperty(example = "hotel")
private String name;
@NonNull
private BatchSpec batch;
private ProfileConfig profile;
private ValidateConfig validate;
private ActionConfig action;
}
@Data
public class BatchSpec {
@ApiModelProperty(example = "FullScan")
private String type;
}