Skip to content
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

Swagger (ui) is not generating correct sample xml for @XmlRootElement #2630

Open
elonderin opened this issue Aug 20, 2018 · 2 comments
Open

Swagger (ui) is not generating correct sample xml for @XmlRootElement #2630

elonderin opened this issue Aug 20, 2018 · 2 comments

Comments

@elonderin
Copy link

@elonderin elonderin commented Aug 20, 2018

TLDR

  1. the general models representation at the bottom of the page
  2. @XmlRootElement.name is not considered in sample XML for
    a) request parameters ~~~unless there is also a @JacksonXmlRootElement present~~~
    b) return types

Steps to Reproduce

An example of the above bugs is in https://github.com/elonderin/springfox-swagger2-bug-xmlrootelement.

This is a fork of gs-rest-service that i extended for this case with these models:

    @JacksonXmlRootElement(localName = "greeting-jaxb")
    @XmlRootElement(name = "greeting-jaxb")
    public class Greeting2 {
    
      @XmlElement(name = "my-id")
      ...
    }
    
    @XmlRootElement(name = "greeting-jaxb")
    public class Greeting {
    
      @XmlElement(name = "my-id")
      private final long   id;
      private final String content;
      ...
    }
  1. compile and run the complete/ subfolder
  2. open http://localhost:8080/swagger-ui.html#/

Case: the general models representation at the bottom of the page

  1. open the Models section
    💥 both have the java class name, neither the Jason nor JAXB Annotations are honored

Case: @XmlRootElement.name is not considered in sample XML for request parameters unless there is also a @JacksonXmlRootElement present

  1. open /post
    💥 the root tag is <Greeting> but should be <greeting-jaxb>
  2. open /post2
:sob: now that i write this issue report, i cant reproduce this anymore, so plz ignore for now ...

### Case: @XmlRootElement.name is not considered in sample XML for return types
1. open `/greeting`
:boom: the root tag is `<Greeting>` but should be `<greeting-jaxb>` 
 
## Context
This might be related to #2393 but this bug seems to tackle another/more specific case this one is simpler 

* it  might only affect the UI
* it is tested against 2.9.2
@dilipkrish
Copy link
Member

@dilipkrish dilipkrish commented Jul 13, 2020

This can be easily implemented as a plugin that copies JacksonXmlModelPlugin

@stale
Copy link

@stale stale bot commented Oct 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants