Astro企业应用 AstroPro-swagger标签使用指南:9、x-type
时间:2025-02-12 15:02:26
9、x-type
作用:
给dto的字段设置指定的类型。
标签值类型:
String
使用位置:
components.schemas.model.prorperties.field.x-type(设置在dto的指定字段上时,改变该字段的类型为指定类型)
使用示例:
definitions: Contain: type: "object" x-generic: T x-extends: Parent properties: name: type: "string" description: "" example: data: type: "string" x-type: T # 通过x-type指定data的类型为T, 此处是将T当为一个字符串设置上,如果设置为一个对象时,需要使用x-imports手动导入相应的包 xml: name: "Contain" namespace: "com.huaweicloud.icsl.app.dto" ---------------
使用效果:
使用前:
public class Contain implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("name") private String name = null; @JsonProperty("data") private String data = null;}
使用后:
public class Contain implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("name") private String name = null; @JsonProperty("data") private T data = null;}
support.huaweicloud.com/usermanual-astropro/astropro_05_0143.html