大摇大摆是否支持自定义参数类型?

时间:2019-04-26 14:54:52

标签: java jersey swagger swagger-ui

我关注了这篇文章:https://stackoverflow.com/a/30407999/2458858,并使用自定义queryparam成功创建了jersey rest api

@GET
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/test")
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(notes = "test api", value = "Get", nickname = "gettest", tags = {"Salus/Identity" })
    public Response identity2(@QueryParam("user") Tempuser user1) {
        return Response.ok().build();   
    }

我还在此自定义类上使用了@ApiModel

@XmlRootElement(name="TempUser")
@ApiModel(value="DifferentModel", description="Sample model for the documentation")
public class Tempuser {

        private String name;

        public Tempuser(String name) {
            this.name = name;
        }

        @XmlElement(name = "name")  
    @ApiModelProperty(required = true)
      public String getName() {
        return name;
      }

      public void setType(String name) {
        this.name = name;
      }

      public static Tempuser valueOf(String name) {
          return new Tempuser(name);
      }

}

但是,当我加载swagger文档时,它仍将TempUser显示为String类型: enter image description here

Swagger不支持自定义数据类型?

0 个答案:

没有答案