title: How to generate JSON schema from a JAXB annotated class?
body: <p>I have a entity class looks like this.</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRootElement
  public class ImageSuffix {
  
      @XmlAttribute
      private boolean canRead;
  
      @XmlAttribute
      private boolean canWrite;
  
      @XmlValue;
      private String value;
  }
  </code></pre>
  
  <p>And I'm using following dependency for JSON generation.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
    &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
    &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
    &lt;version&gt;2.1.4&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>When I tried with following code, (which referred from <a href="http://wiki.fasterxml.com/JacksonJsonSchemaGeneration" rel="nofollow">Generating JSON Schemas with Jackson</a>)</p>
  
  <pre class="lang-java prettyprint-override"><code>@Path("/imageSuffix.jsd")
  public class ImageSuffixJsdResource {
  
      @GET
      @Produces({MediaType.APPLICATION_JSON})
      public String read() throws JsonMappingException {
  
          final ObjectMapper objectMapper = new ObjectMapper();
  
          final JsonSchema jsonSchema =
              objectMapper.generateJsonSchema(ImageSuffix.class);
  
          final String jsonSchemaString = jsonSchema.toString();
  
          return jsonSchemaString;
      }
  }
  </code></pre>
  
  <p>Server complains with following error message</p>
  
  <pre><code>java.lang.IllegalArgumentException: Class com.googlecode.jinahya.test.ImageSuffix would not be serialized as a JSON object and therefore has no schema
          at org.codehaus.jackson.map.ser.StdSerializerProvider.generateJsonSchema(StdSerializerProvider.java:299)
          at org.codehaus.jackson.map.ObjectMapper.generateJsonSchema(ObjectMapper.java:2527)
          at org.codehaus.jackson.map.ObjectMapper.generateJsonSchema(ObjectMapper.java:2513)
  </code></pre>
  
  <p>How can I fix this?</p>