Pablo Jomer
Pablo Jomer

Reputation: 10408

swagger-springmvc plugin malformed xml $ref

I have wired up swagger-springmvc in spring and it seams to be working correctly when delivering description of some api paths. How ever when accessing more complex objects it delivers faulty xml. This generates the following message in chrome:

This page contains the following errors:

error on line 1 at column 3963: StartTag: invalid element name
Below is a rendering of the page up to the first error.

I have noted that a tag like this can be found in the xml

<entry>
  <key>questions</key>
  <value>
    <items>
      <$ref>Question</$ref>
      <required>false</required>
      <type>any</type>
      <uniqueItems>false</uniqueItems>
    </items>
    <name>questions</name>
    <required>false</required>
    <type>Set</type>
    <uniqueItems>false</uniqueItems>
  </value>
</entry>

I have tried removing saving the xml info and removing the dollar signs from the ref entries and that seems to make the xml correct. Does any one else have expiriance of this problem?

A closer look reveals that is when converting List Type objects that the problem occours. Still I have no solution to as what to do about it.

Upvotes: 0

Views: 490

Answers (1)

Pablo Jomer
Pablo Jomer

Reputation: 10408

I was able to solve this issue by changing the Jackson dependencies that swagger 0.6.5 uses. The changes were made in the pom.xml.

Excluded the jackson dependencies for swagger which I found in the dependency tree

    <dependency>
      <groupId>com.mangofactory</groupId>
      <artifactId>swagger-springmvc</artifactId>
      <version>0.6.5</version>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.jaxrs</groupId>
          <artifactId>jackson-jaxrs-json-provider</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.module</groupId>
          <artifactId>jackson-module-scala</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml</groupId>
          <artifactId>classmate</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

Added new dependencies for the three jackson dependencies

    <dependency>
      <groupId>com.fasterxml.jackson.jaxrs</groupId>
      <artifactId>jackson-jaxrs-json-provider</artifactId>
      <version>2.2.3</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml</groupId>
      <artifactId>classmate</artifactId>
      <version>1.0.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-scala_2.9.2</artifactId>
      <version>2.2.3</version>
    </dependency>

Upvotes: 1

Related Questions