How to make Swagger recognize @XmlTransient (for example, don't ignore it)

It seems to Swaggerignore annotations JAXBsuch as@XmlTransient

In addition, Swagger also seems to parse getters, ignoring @XmlAccessorType(XmlAccessType.FIELD)

Is there a way to specify Swaggerfor evaluating annotations JAXB?

UPDATE

code example

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;

import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiModelProperty;

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    @ApiModel( value = "aaa")
    public class A implements IA
    {
        @ApiModelProperty( value = "bla", required = true )
        @XmlElement(name="a")
        private String a;

        @XmlTransient 
        private B b;

         private A() {}//JAXB

         @XmlTransient
         public boolean isC() { return true;};
}

The IA interface does not contain annotations. and no getters to field b that could interfere.

Generated by JAON:

"A": {
      "id": "A",
      "description": "aaa",
      "properties": {
        "c": {
          "type": "boolean"
        }
      }
    }

As you can see, Swagger ignores the fields and @XMLAccesorType(as Webron noted in his answer), but also ignores the JAXB ( @XmlTransient) annotation in the isC()getter function

+4
source share
3 answers

, . . swagger-jaxrs_2.10 v 1.3.6

, swagger-jaxrs_2.10 v 1.3.0   swagger-jeresy-jaxrs_2.10 v 1.3.10...

@JsonIgnore @XmlTransient

+2

. , - .

a, a.

, , @XmlTransient . @XmlTransient .

, swagger-core ( ) @XmlAccessorType.

, .

+1

For users @Hiddenin 2019, just use the annotation @Hiddenwith @XmlTransienton top of your methods:

@XmlTransient
@Hidden
public getFoo(){
...
0
source

All Articles