Skip to content

Nested types generate swagger doc incorrectly, Maybe. #2624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ronniedepriest opened this issue Jan 16, 2018 · 0 comments
Open

Nested types generate swagger doc incorrectly, Maybe. #2624

ronniedepriest opened this issue Jan 16, 2018 · 0 comments
Assignees

Comments

@ronniedepriest
Copy link

ronniedepriest commented Jan 16, 2018

Q A
Bug or feature request? YES
Which Swagger-Core version? 1.5.16
Which Java version? Java 8.151
Which JAX-RS framework & version? Jackson 1.9

My model class has a method to get a model type. The path is declared on both the method and the type. This is currently returning improper nesting of values. I'm not sure if I'm not doing this properly, or if it's an issue with using Jackson 1.9 and Swagger 1.5.16....
UPDATE: This is supported in the containers as a json provider for jaxb elements. So my feeling is this is likely highly used. This aritcle desribes it from Jboss' standpoint: (https://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/Built_in_JAXB_providers.html)

Model Class examples:

@ApiModel(value="Example")
@XmlAccessorType( XmlAccessType.NONE )
@XmlRootElement( name = "example" )
public class Example extends BaseExample {
  ...
}
@XmlAccessorType( XmlAccessType.NONE )
public abstract class BaseExample {
  @XmlElement( name = "typeName" )
  public TypeName getTypeName(){...}
}
@XmlAccessorType( XmlAccessType.PROPERTY )
@XmlRootElement( name = "typeName" )
public class TypeName{
  @ApiModelProperty( example="SAMPLETYPENAME" )
  @XmlValue
  public String getName(){...}

  @ApiModelProperty( value="This should produce an href attribute, and does", example="example.com" )
  @XmlAttribute( name = "href" )
  public String getHref() {...}
}

And that generates something similar to this as an example:

<example>
  <typeName href="example.com">
    <typeName>SAMPLETYPENAME</typeName>
  </typeName>
</example>

The expected (and what the server actually returns from a call to the API:

<example>
  <typeName href="example.com">SAMPLETYPENAME</typeName>
</example>

An appropriate version of this in json would be as follows:

{
  "example": {
    "typeName": {
      "$": "SAMPLETYPENAME",
      "@href": "example.com"
    }
  }
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants