Skip to content

Descriptions of Class with Attributes Disappearing #3561

@AdamSchwartz-LoweTR

Description

@AdamSchwartz-LoweTR
  • Swagger/OpenAPI version: Swagger 2.1.1

Java Source Attribute Details Wrapper:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import io.swagger.v3.oas.annotations.media.Schema;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AttributeDetailsWrapper", propOrder = {

})
public class AttributeDetailsWrapper {

    @XmlElement(name = "Abc")
    protected AttributeDetails abc;
    @XmlElement(name = "Def")
    protected AttributeDetails def;
    @XmlElement(name = "Ghi")
    protected AttributeDetails ghi;

    @Schema(name = "Abc", description = "Description for Abc")
    public AttributeDetails getAbc() {
        return abc;
    }

    public void setAbc(AttributeDetails value) {
        this.abc = value;
    }

    @Schema(name = "Def", description = "Description for Def")
    public AttributeDetails getDef() {
        return def;
    }

    public void setDef(AttributeDetails value) {
        this.def = value;
    }

    @Schema(name = "Ghi", description = "Description for Ghi")
    public AttributeDetails getGhi() {
        return ghi;
    }

    public void setGhi(AttributeDetails value) {
        this.ghi = value;
    }
}

Java Source Attribute Details:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AttributeDetails", propOrder = {
    "value"
})
public class AttributeDetails {

    @XmlValue
    protected String value;
    @XmlAttribute(name = "attributeA")
    protected String attributeA;
    @XmlAttribute(name = "attributeB")
    protected String attributeB;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getAttributeA() {
        return attributeA;
    }

    public void setAttributeA(String value) {
        this.attributeA = value;
    }

    public String getAttributeB() {
        return attributeB;
    }

    public void setAttributeB(String value) {
        this.attributeB = value;
    }
}

Example Swagger/OpenAPI definition:

AttributeDetailsWrapper:
      type: object
      properties:
        Abc:
          $ref: '#/components/schemas/AttributeDetails'
        Def:
          $ref: '#/components/schemas/AttributeDetails'
        Ghi:
          $ref: '#/components/schemas/AttributeDetails'
AttributeDetails:
      type: object
      properties:
        value:
          type: string
        attributeA:
          type: string
          xml:
            attribute: true
        attributeB:
          type: string
          xml:
            attribute: true
      description: Description for Ghi

Describe the bug you're encountering

I am generating the openapi.yaml using Swagger on a locally deployed tomcat server. I have a class, AttributeDetails, with no Swagger annotations and two fields with @XmlAttribute.
Referring to that class is another, AttributeDetailsWrapper, which has three references to it, each with a different name and annotated with a name and description.
The end result is that the AttributeDetails, in the yaml, gets the description for the last field in AttributeDetailsWrapper applied to it, and the descriptions for the individual references disappear.

To reproduce...

Generate the yaml using these two classes.

Expected behavior

Each reference to AttributeDetails from AttributeDetailsWrapper should have a description in the yaml. The AttributeDetails itself should have no description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions