调整REST API的Swagger-UI

时间:2015-07-25 14:32:00

标签: jax-rs swagger swagger-ui

我想调整Swagger-UI for Java REST API。 要求:

  1. 添加REST路径的描述
  2. 为多个产品添加下拉列表(我能够这样做,但无法再次复制)
  3. 添加要在“模型架构”
  4. 中选择的示例

    提前致谢。

    @Component
    @Path("/test")
    @Api(value = "/test",
        description = "Demo of how to pass JSON/XML document to the REST services", 
        consumes = MediaType.APPLICATION_JSON + "," + MediaType.APPLICATION_XML,
        produces = MediaType.APPLICATION_JSON + "," + MediaType.APPLICATION_XML)
    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public class TerminologyRest2 {
    
        @POST
        @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
        @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
        @ApiOperation(value = "Creates a product", 
                      notes = "Creates a product and puts it in the catalog.", 
                      consumes = MediaType.APPLICATION_JSON + "," + MediaType.APPLICATION_XML, 
                      produces = MediaType.APPLICATION_JSON + "," + MediaType.APPLICATION_XML, 
                      protocols = "POST", 
                      response = Product.class)
        @ApiResponses(value = { 
                @ApiResponse(code = 400, message = "Malformed definition of new product", response = StatusInfo.class),
                @ApiResponse(code = 500, message = "Internal server error", response = StatusInfo.class),
                @ApiResponse(code = 200, message = "Successful catalogization of new product", response = Product.class)
                })
        public Response createProduct(@ApiParam(name = "product", required = true, value = "Define product content") Product product) {
            try {
    
                return Response.status(200).entity(product).build();
            } catch (IllegalArgumentException e) {
                return Response.status(Status.NOT_ACCEPTABLE).entity(e.getMessage()).build();
            }
        }
    }
    

    目前:

    enter image description here

    通缉:

    enter image description here

0 个答案:

没有答案