Facing issues in @Api annotation's description

499 views
Skip to first unread message

SATANIK Panda

unread,
Apr 11, 2014, 10:21:20 AM4/11/14
to swagger-sw...@googlegroups.com
When we are using:

<dependency>
                  <groupId>com.wordnik</groupId>   
                  <artifactId>swagger-jersey-jaxrs_2.10</artifactId>
            </dependency>
            <dependency>
                <groupId>com.wordnik</groupId>
                <artifactId>swagger-annotations_2.9.1</artifactId>
            </dependency>
            <dependency>
                <groupId>com.wordnik</groupId>
                <artifactId>swagger-core</artifactId>
            </dependency>


import com.wordnik.swagger.annotations.Api;

@Api(value = "/erp", description = "Expose apis for entitlement and roles", authorizations="XXXXXX", produces=MediaType.APPLICATION_JSON) 

This is producing the below json:

{
  "apiVersion" : "v1",
  "swaggerVersion" : "1.1",
  "basePath" : "http://openapidev.mhhe.com/openapi/jsp/swagger",
  "apis" : [ {
    "path" : "/erp",
    "description" : ""
  }, {
    "path" : "/common",
    "description" : ""
  }, {
    "path" : "/instructor",
    "description" : ""
  } ]
}

Can any one help me to understand why the description is not coming in the json.

Ron

unread,
Apr 11, 2014, 2:02:51 PM4/11/14
to swagger-sw...@googlegroups.com
you don't say which swagger-core/annotations/jax-rs you're using, but from the output, it looks like you're using an old version.
try updating to version 1.3.4 and see if it fixes the issues.


--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Prosenjit Mondal

unread,
Apr 14, 2014, 3:11:48 AM4/14/14
to swagger-sw...@googlegroups.com
Hi Ron, 

Thanks for your update.
We are using the following versions.

<!-- Swagger related Changes Start -->
<dependency>
  <groupId>com.wordnik</groupId>
  <artifactId>swagger-jersey-jaxrs_2.10</artifactId>
  <version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
<version>1.0.2</version>
</dependency>
       <dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core</artifactId>
<version>1.0</version>
</dependency>

<!-- Swagger related Changes End -->

It will be great if you can share us the latest maven entry for the swagger. 
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Prosenjit Mondal

unread,
Apr 14, 2014, 6:58:10 AM4/14/14
to swagger-sw...@googlegroups.com
Hi,

We have tried with the following maven entry

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.3.4</version>
</dependency>

and also with the following maven entry

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.4</version>
</dependency>

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.4</version>
</dependency>

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.3.4</version>
</dependency>

but the same issue of not generation the description persists.

Any suggestion..

tony tam

unread,
Apr 14, 2014, 11:23:56 AM4/14/14
to swagger-sw...@googlegroups.com
Howdy,
Is it possible that you have more than one class annotated with @Api(value = "/erp"?  If so, it's possible that the description is being lost when merging the operations.

Prosenjit Mondal

unread,
Apr 16, 2014, 5:45:58 AM4/16/14
to swagger-sw...@googlegroups.com
No Tom. We have only one class annotated like the below

@Api(value = "/erp", description = "Expose apis for entitlement and roles", authorizations="XXXXXX", produces=MediaType.APPLICATION_JSON)

 Master Json [in our case service.json] is generating like below:

Ron

unread,
Apr 16, 2014, 6:51:57 AM4/16/14
to swagger-sw...@googlegroups.com
If you're getting the JSON you posted, it means that you haven't updated the dependencies properly.
Please check them again and make sure they're updated.


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Prosenjit Mondal

unread,
Apr 17, 2014, 3:16:46 AM4/17/14
to swagger-sw...@googlegroups.com
Hi Ron,

It will be great if you can share the updated dependencies with us. Please guide us on this.

We have tried with the below dependencies, but no luck.

Dependencies #1

<dependency>
                  <groupId>com.wordnik</groupId>    
                  <artifactId>swagger-jersey-jaxrs_2.10</artifactId>
            </dependency>
            <dependency>
                <groupId>com.wordnik</groupId>
                <artifactId>swagger-annotations_2.9.1</artifactId>
            </dependency>
            <dependency>
                <groupId>com.wordnik</groupId>
                <artifactId>swagger-core</artifactId>
            </dependency>

Dependencies #2

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.4</version>
</dependency>

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.4</version>
</dependency>

<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.3.4</version>
</dependency>

Howdy,
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Apr 17, 2014, 3:30:34 AM4/17/14
to swagger-sw...@googlegroups.com
What's the JSON output you're getting with "Dependencies 2"?


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Prosenjit Mondal

unread,
Apr 17, 2014, 4:29:03 AM4/17/14
to swagger-sw...@googlegroups.com
Hi Ron, 

after using the "Dependencies 2" also, I am getting the same json. No difference.

We are building the json by using the following:

<build>
<plugins>
<plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>1.1.1</version>
                <configuration>
                    <apiSources>
                        <apiSource>
                            <locations>com.XXXX.openapi.rest</locations>
                            <apiVersion>v1</apiVersion>
                            <basePath>http://openapidev.XXXX.com/openapi/jsp/swagger</basePath>
                            <outputTemplate>wiki-new.mustache</outputTemplate>
                            <outputPath>src/main/webapp/jsp/swagger/strapdown.html</outputPath>
                            <withFormatSuffix>false</withFormatSuffix>
                            <swaggerDirectory>src/main/webapp/jsp/swagger</swaggerDirectory>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
</plugins>
</build>


{
  "apiVersion" : "v1",
  "swaggerVersion" : "1.1",
  "apis" : [ {
    "path" : "/instructor",
    "description" : ""
  }, {
    "path" : "/erp",
    "description" : ""
  }, {
    "path" : "/common",
    "description" : ""
  } ]

Ron

unread,
Apr 17, 2014, 4:30:23 AM4/17/14
to swagger-sw...@googlegroups.com
Try upgrading the swagger-maven-plugin to 2.1.


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Prosenjit Mondal

unread,
Apr 17, 2014, 5:33:34 AM4/17/14
to swagger-sw...@googlegroups.com
Hi Ron,

Thanks for your help. The json looks fine now. 

Need one more help. While upgrading to the version 1.3.4 ApiErrors is giving compilation error. Any suggestion for this. 

@ApiErrors({
@ApiError (code=221,reason="Invalid URL, sectionURL should be pass as query param"),
@ApiError (code=3002,reason="No such Book is present for this ISBN in the connect system"),
@ApiError (code=600, reason="Unexpected database error has occurred while processing the request"),
@ApiError (code=700, reason="Unexpected system error has occurred while processing the request")
})

Ron

unread,
Apr 17, 2014, 5:45:06 AM4/17/14
to swagger-sw...@googlegroups.com

What's the compilation error?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Prosenjit Mondal

unread,
Apr 17, 2014, 5:58:36 AM4/17/14
to swagger-sw...@googlegroups.com
The import com.wordnik.swagger.annotations.ApiError cannot be resolved.
The import com.wordnik.swagger.annotations.ApiErrors cannot be resolved.

Ron

unread,
Apr 17, 2014, 6:05:40 AM4/17/14
to swagger-sw...@googlegroups.com


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Pro M

unread,
Apr 17, 2014, 6:17:11 AM4/17/14
to swagger-sw...@googlegroups.com
Thanks Ron. I will update the code accordingly with @ApiResponses & @ApiResponse...

Lastly, we are observing a issue while sending a request in POST method. The method signature is like below. We are using Swagger-UI for the UI representation. Get method is working fine. But sending request through POST method is not working. In the server side the java.lang.NoSuchMethodError error is generating. Any suggestion. 

@Description(description = "Save or Update entitlement ")
@MethodName(defineName = "Save Entitlement")
@ApiOperation(value = "Save or Update entitlement", notes = "Save Entitlement", response = Integer.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid Role Name"),
@ApiResponse (code=10001, message="Role name is not present in the connect system"),
@ApiResponse (code=10002, message="Entitlement name is requered"),
@ApiResponse (code=600, message="Unexpected database error has occurred while processing the request"),
@ApiResponse (code=700, message="Unexpected system error has occurred while processing the request")
})
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@Path("/application/{applicationName}/role/{roleName}/entitlement")
public int saveEntitlement(@ApiParam(value = "Application Name", required = true) @PathParam("applicationName") String applicationName,
@ApiParam(value = "Role Name", required = true) @PathParam("roleName") String roleName, @ApiParam(value = "User Entitlement", required = true) Entitlement entitlement) throws OpenAPIException {

Ron

unread,
Apr 17, 2014, 6:43:40 AM4/17/14
to swagger-sw...@googlegroups.com
It's a bit difficult to say without more details.

If you use a standard REST client, can you operate the API successfully?
Did you check the full request that Swagger-UI produces (using your browser's console)?


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Pro M

unread,
Apr 17, 2014, 6:53:48 AM4/17/14
to swagger-sw...@googlegroups.com
Seems the thing was not working because of the old versions. I checked now. It is working fine. Thanks.

We want to add the authorization for the services. I saw there is some authorizantion field present against the @Api. Could you help us on how to use it.

Ron

unread,
Apr 17, 2014, 6:59:26 AM4/17/14
to swagger-sw...@googlegroups.com


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Pro M

unread,
Apr 17, 2014, 7:09:06 AM4/17/14
to swagger-sw...@googlegroups.com
Thanks Ron for the link. I will go through it & incorporate the same in our services. Need one more help.

<withFormatSuffix>false</withFormatSuffix> present in the swagger-maven-plugin version 1.1.1

which is not present in the version 2.1. hence it is generating the service.json like below. .{format} is generating unnecessary. Any suggestion how to remove it.

{
  "apiVersion" : "v1",
  "swaggerVersion" : "1.2",
  "apis" : [ {
    "path" : "/common.{format}",
    "description" : "Misc Services"
  }, {
    "path" : "/instructor.{format}",
    "description" : "Instructor Services"
  }, {
    "path" : "/erp.{format}",
    "description" : "Roles, Permission, and Entitlement Services"
  } ],

Ron

unread,
Apr 17, 2014, 7:14:54 AM4/17/14
to swagger-sw...@googlegroups.com
You'd have to look through the swagger maven project - https://github.com/kongchen/swagger-maven-plugin and see if you can find documentation for it.
If not, I suggest you open an issue on the project there.


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Pro M

unread,
Apr 17, 2014, 8:02:06 AM4/17/14
to swagger-sw...@googlegroups.com
yeah. It seems some bug in the swagger-maven-plugin version 2.1 & swagger - UI integration. 

Thanks for your help Ron. Thanks a lot.

Pro M

unread,
Apr 18, 2014, 3:52:30 AM4/18/14
to swagger-sw...@googlegroups.com
remove the line 290 in the swagger.js

this.path = this.path+'.json';
...
Reply all
Reply to author
Forward
0 new messages