Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 向响应类添加json示例的Swagger注释_Java_Swagger Ui_Spring Restcontroller - Fatal编程技术网

Java 向响应类添加json示例的Swagger注释

Java 向响应类添加json示例的Swagger注释,java,swagger-ui,spring-restcontroller,Java,Swagger Ui,Spring Restcontroller,如何使用swagger注释插入默认值而不是“{}”值?您需要使用@ApiResponses和@ApiResponse注释Rest方法 比如说 @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of demand",responseContainer="List"),


如何使用swagger注释插入默认值而不是“{}”值?

您需要使用@ApiResponses@ApiResponse注释Rest方法

比如说

@ApiResponses(value = { 
                        @ApiResponse(code = 200, message = "Successful retrieval of demand",responseContainer="List"),
                        @ApiResponse(code = 404, message = "Demand does not exist", response = Your Error response.class),
                        @ApiResponse(code = 500, message = "Internal server error", response = Your Error response.class) 
                    }
            )
@ApiModel注释Json响应类,用@ApiModelProperty注释其字段


显示当前使用的代码/注释会很有帮助。通常,您在
@ApiOperation
/
@apisresponse
响应值中指定一个响应类。示例值通过
@ApiModel
和相关注释提供。
@ApiModel(description = "Your comment")
public class Demand implements Serializable {

    private static final long serialVersionUID = 1L;

    
    @ApiModelProperty(notes = "Your comments", required = true, example = "example value")
    private String demandId;
}