Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Include the format of the JSON Response Body in the docs generated by Enunciate?

Currently Enunciate generates the REST API documentation, but the Response Body doesn't contain the information about the JSON structure of the response. In my understanding, if I include the classes with the data entities that are serialized/de-serialized by Jersey to JSON, enunciate would be able to generate that piece of the documentation.

The data entities are in a different module, which is packaged with its sources as suggested in the enunciate documentation - Multi-Module Projects

...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.1.2</version>
    <executions>
        <execution>
            <id>attach-sources</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>
...

This is how my enunciate.xml looks like:

<?xml version="1.0"?>
<enunciate label="someapi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.25.xsd">

    <api-import pattern="com.something.business.vo.**"/>
    <api-import pattern="com.something.business.domain.**"/>

    <api-classes>
        <include pattern="com.something.web.ssoApi.rest.*"/>
        <include pattern="com.something.business.vo.**"/>
        <include pattern="com.something.business.domain.**"/>
    </api-classes>

</enunciate>

And this how the docs look like:

Documentation Screenshot

As you see the Response Body contains just element: (custom).

How to make that contain the JSON structure of the response?

like image 610
Vladimir Tsvetkov Avatar asked Jun 19 '12 08:06

Vladimir Tsvetkov


1 Answers

In order to generate the documentation for the Data Model section, the entities should be annotated with @XmlRootElement.

like image 170
Vladimir Tsvetkov Avatar answered Oct 13 '22 23:10

Vladimir Tsvetkov