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 API v.1.3.2 #482

Closed
gsxoom opened this issue Jun 25, 2014 · 16 comments
Closed

Swagger API v.1.3.2 #482

gsxoom opened this issue Jun 25, 2014 · 16 comments

Comments

@gsxoom
Copy link

gsxoom commented Jun 25, 2014

Using Swagger API with spring-boot 4.
HttpStatus code 204, showing as
image

My spring mvc controller method has the annotation
@ResponseStatus(value = HttpStatus.NO_CONTENT) with no reason, so it should take the default.

@webron
Copy link
Contributor

webron commented Jun 26, 2014

What is the actual issue? The 'Reason' column displays the 'message' field
of the responseMessages.
It doesn't use the standard HTTP status code descriptions. So if you see
'Created' there, either you put it there or the library that you're using.

On 25 June 2014 23:04, gsxoom [email protected] wrote:

Using Swagger API with spring-boot 4.
HttpStatus code 204, showing as
[image: image]
https://cloud.githubusercontent.com/assets/6530462/3390885/ebab3968-fca3-11e3-9aec-c3b54d61f3b7.png


Reply to this email directly or view it on GitHub
#482.

@gsxoom
Copy link
Author

gsxoom commented Jun 26, 2014

As specified by the specs, when no reason is given in the annotation @ResponseStatus,
then it should take the default which is "No Content".
I did not put "Created", and as described I only have the annotation, whose JavaDoc SAYS that if reason is not specified, it should take the default.

@webron
Copy link
Contributor

webron commented Jun 26, 2014

What specs? Which library do you use? swagger-springmvc?

On 26 June 2014 19:22, gsxoom [email protected] wrote:

As specified by the specs, when no reason is given in the annotation
@ResponseStatus,
then it should take the default which is "No Content".
I did not put "Created", and as described I only have the annotation,
whose JavaDoc SAYS that if reason is not specified, it should take the
default.


Reply to this email directly or view it on GitHub
#482 (comment).

@webron
Copy link
Contributor

webron commented Jun 26, 2014

Where did you say that the specs says it reads @ResponseStatus? Can you
show a sample of your code?

On 26 June 2014 19:37, gsxoom [email protected] wrote:

yes, it is spring mvc 4.x. I mean JavaDoc for the annotation. We use
spring-boot 1.1.1.RELEASE
It is wired up with swagger.
spring-mvc 4.0.3
swagger-annotations 1.3.2
swagger-core 1.3.2


Reply to this email directly or view it on GitHub
#482 (comment).

@gsxoom
Copy link
Author

gsxoom commented Jun 26, 2014

@Consumes( {APPLICATION_JSON_CHARSET_UTF_8, PLAIN_TEXT_CHARSET_UTF_8})
@Produces( {APPLICATION_JSON_CHARSET_UTF_8})
@PreAuthorize("#oauth2.hasScope('remittance/send-transfers')")

@ApiOperation(value = "/users/{userId}", httpMethod = "DELETE")
@RequestMapping(value = "/users/{userId}", method = DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteAccountPaymentCredentials(@PathVariable long userId) {

    boolean success = accountPaymentAuthService.deleteAccountPaymentCredentials(userId);
    RestAssert.resourceFound(success, "No active account payment credentials found");
}

@webron
Copy link
Contributor

webron commented Jun 26, 2014

@ResponseStatus is a Spring MVC annotation. Swagger-core does not
introspect these annotations.
If you're using the swagger-springmvc library, and it is not behaving as
you expect, you should open an issue on their repository.
However, this is unrelated to swagger-ui.

On 26 June 2014 19:59, gsxoom [email protected] wrote:

@consumes( {APPLICATION_JSON_CHARSET_UTF_8, PLAIN_TEXT_CHARSET_UTF_8})
@produces( {APPLICATION_JSON_CHARSET_UTF_8})
@PreAuthorize("#oauth2.hasScope('remittance/send-transfers')")

@ApiOperation(value = "/users/{userId}", httpMethod = "DELETE")
@RequestMapping(value = "/users/{userId}", method = DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteAccountPaymentCredentials(@PathVariable long userId) {

boolean success = accountPaymentAuthService.deleteAccountPaymentCredentials(userId);
RestAssert.resourceFound(success, "No active account payment credentials found");

}


Reply to this email directly or view it on GitHub
#482 (comment).

@gsxoom
Copy link
Author

gsxoom commented Jun 26, 2014

So, should this be in swagger-core?, because the swagger image that I attached is generated,
by I guess swagger-core, then?

@webron
Copy link
Contributor

webron commented Jun 26, 2014

Can you share your pom.xml?
Can you share the output you're getting from swagger (not in the ui, the
json itself)?

On 26 June 2014 20:23, gsxoom [email protected] wrote:

So, should this be in swagger-core?, because the swagger image that I
attached is generated,
by I guess swagger-core, then?


Reply to this email directly or view it on GitHub
#482 (comment).

@gsxoom
Copy link
Author

gsxoom commented Jun 26, 2014

Here is a subset of the pom.xml. Removed plugins and repositories.

4.0.0
<groupId>com.xoom.platform-api</groupId>
<artifactId>platform-api-account-payment-auth</artifactId>

<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
    <spring.boot.mainclass>com.xoom.platform.accountpayment.auth.Application</spring.boot.mainclass>
    <spring.version>4.0.3.RELEASE</spring.version>
    <spring.boot.version>1.1.1.RELEASE</spring.boot.version>
    <spring.security.version>3.2.3.RELEASE</spring.security.version>
    <spring.security.oauth.version>2.0.1.RELEASE</spring.security.oauth.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- Came from inf parent pom -->
    <nexus.url.prefix>http://punk:8081/nexus</nexus.url.prefix>
    <nexus.download.url>${nexus.url.prefix}/content/groups/public</nexus.download.url>
    <nexus.deploy.url>${nexus.url.prefix}/content/repositories</nexus.deploy.url>
    <enforcer.skip.enforce>false</enforcer.skip.enforce>
    <xoom.common.version>12.4.68</xoom.common.version>
    <xoom.trunk.version>13.5.3</xoom.trunk.version>
    <!-- validation -->
    <javax.validation.api.version>1.1.0.Final</javax.validation.api.version>
    <org.hibernate.validator.version>5.1.1.Final</org.hibernate.validator.version>


    <jmock.version>2.6.0</jmock.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${spring.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.30</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>

    <dependency>
        <groupId>com.xoom.inf</groupId>
        <artifactId>xoom-boot-api</artifactId>
        <version>1.4</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.xoom.inf</groupId>
        <artifactId>http-client</artifactId>
        <version>1.10</version>
        <exclusions>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.xoom.inf</groupId>
        <artifactId>cluster</artifactId>
        <version>1.8</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-mapper-asl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>3.0</version>
    </dependency>

    <!--  common  -->
    <dependency>
        <groupId>com.xoom.common</groupId>
        <artifactId>common-util</artifactId>
        <version>${xoom.common.version}</version>
    </dependency>
    <dependency>
        <groupId>com.xoom.common</groupId>
        <artifactId>common-crypto</artifactId>
        <version>${xoom.common.version}</version>
        <exclusions>
            <exclusion>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
            </exclusion>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
        <version>${spring.security.oauth.version}</version>
        <exclusions>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
        <version>${spring.boot.version}</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <version>2.0.3</version>
    </dependency>

    <!--  This is only when using Hibernate validator  -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>${javax.validation.api.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>${org.hibernate.validator.version}</version>
    </dependency>

    <!-- Testing -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jmock</groupId>
        <artifactId>jmock-junit4</artifactId>
        <version>${jmock.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-library</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>com.xoom.common</groupId>
        <artifactId>common-test-junit4</artifactId>
        <version>${xoom.common.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

@gsxoom
Copy link
Author

gsxoom commented Jun 26, 2014

Here is the swagger .json. Look at the DELETE method, the last one.
Also, if you can point me to a Java sample on how to define request parameters that are of type "header", it would be great. So far, it is not generated. We go thru the mangofactory springmvc

{
apiVersion: "1.0",
swaggerVersion: "1.2",
basePath: "http://localhost:8080",
resourcePath: "/v1",
apis: [
{
path: "/v1/account-payment-auth/users/{userId}",
description: "getAccountPaymentCredentials",
operations: [
{
method: "GET",
summary: "/users/{userId}",
notes: "getAccountPaymentCredentials",
type: "AccountPaymentCredentialsResource",
nickname: "getAccountPaymentCredentials",
parameters: [
{
name: "userId",
description: "userId",
defaultValue: "",
required: true,
type: "integer",
format: "int64",
paramType: "path"
}
],
responseMessages: [
{
code: 404,
message: "Not Found"
},
{
code: 403,
message: "Forbidden"
},
{
code: 401,
message: "Unauthorized"
},
{
code: 200,
message: "OK",
responseModel: "AccountPaymentCredentialsResource"
}
],
deprecated: "false"
}
]
},
{
path: "/v1/account-payment-auth/access-token",
description: "getAccessToken",
operations: [
{
method: "POST",
summary: "/access-token",
notes: "getAccessToken",
type: "OAuth2AccessToken",
nickname: "getAccessToken",
parameters: [
{
name: "scope",
description: "scope",
defaultValue: "",
required: false,
type: "string",
paramType: "body"
}
],
responseMessages: [
{
code: 201,
message: "Created"
},
{
code: 404,
message: "Not Found"
},
{
code: 403,
message: "Forbidden"
},
{
code: 401,
message: "Unauthorized"
},
{
code: 200,
message: "OK",
responseModel: "OAuth2AccessToken"
}
],
deprecated: "false"
}
]
},
{
path: "/v1/account-payment-auth/users/{userId}",
description: "deleteAccountPaymentCredentials",
operations: [
{
method: "DELETE",
summary: "/users/{userId}",
notes: "deleteAccountPaymentCredentials",
type: "Void",
nickname: "deleteAccountPaymentCredentials",
parameters: [
{
name: "userId",
description: "userId",
defaultValue: "",
required: true,
type: "integer",
format: "int64",
paramType: "path"
}
],
responseMessages: [
{
code: 204,
message: "Created"
},
{
code: 403,
message: "Forbidden"
},
{
code: 401,
message: "Unauthorized"
}
],
deprecated: "false"
}
]
}
],
models: {
string: {
id: "string",
description: "",
extends: "",
properties: { }
},
OAuth2AccessToken: {
id: "OAuth2AccessToken",
description: "",
extends: "",
properties: { }
},
AccountPaymentCredentialsResource: {
id: "AccountPaymentCredentialsResource",
description: "",
extends: "",
properties: {
id: {
type: "integer",
format: "int64"
},
username: {
type: "string"
},
modified: {
$ref: "date-time"
},
userId: {
type: "integer",
format: "int64"
},
accountPaymentUserId: {
type: "integer",
format: "int64"
},
deleted: {
type: "boolean"
},
firstName: {
type: "string"
}
}
},
Void: {
id: "Void",
description: "",
extends: "",
properties: { }
}
}
}

@webron
Copy link
Contributor

webron commented Jun 27, 2014

@gsxoom - There are no swagger dependencies in the pom.xml

@gsxoom
Copy link
Author

gsxoom commented Jun 27, 2014

Well, you know about dependency.
mvn dependency:tree
+- com.xoom.inf:xoom-boot-api:jar:1.4:compile
...
| +- com.wordnik:swagger-core_2.10:jar:1.3.2:compile

@webron
Copy link
Contributor

webron commented Jun 27, 2014

Right, so can you please share either the effective pom (rather than the
pom.xml) or the mvn dependency:tree?

On 27 June 2014 20:44, gsxoom [email protected] wrote:

Well, you know about dependency.
mvn dependency:tree
+- com.xoom.inf:xoom-boot-api:jar:1.4:compile
...
| +- com.wordnik:swagger-core_2.10:jar:1.3.2:compile


Reply to this email directly or view it on GitHub
#482 (comment).

@webron
Copy link
Contributor

webron commented Jun 27, 2014

Okay, if it is spring boot that pulls it in, can you please attach the
output of 'mvn dependency:tree'?

On 27 June 2014 21:29, gsxoom [email protected] wrote:

The effective pom does not show de dependencies. It is spring-boot
1.1.1.RELEASE that is pooling it.
I upgraded versions yesterday, but spring-boot is still the same, and the
error still shows,.
Here is the effective pom. I remove local repository info and plugins.

[INFO]

[INFO] Building platform-api-account-payment-auth 1.0-SNAPSHOT

[INFO]

[INFO]
[INFO] --- maven-help-plugin:2.2:effective-pom (default-cli) @
platform-api-account-payment-auth ---
[INFO]
Effective POMs, after inheritance, interpolation, and profiles are applied:

4.0.0
com.xoom.platform-api
platform-api-account-payment-auth
1.0-SNAPSHOT

xoom-releases
Xoom Releases Repository
http://punk:8081/nexus/content/repositories/releases

true
true
false
1.1.0.Final
2.6.0
http://punk:8081/nexus/content/repositories
http://punk:8081/nexus/content/groups/public
http://punk:8081/nexus
5.1.1.Final
UTF-8
-XX:PermSize=256
com.xoom.platform.accountpayment.auth.Application
1.1.1.RELEASE
2.0.1.RELEASE
3.2.3.RELEASE
4.0.3.RELEASE
12.4.68
13.5.3

org.springframework
spring-aop
4.0.3.RELEASE

org.springframework
spring-aspects
4.0.3.RELEASE

org.springframework
spring-beans
4.0.3.RELEASE

org.springframework
spring-context
4.0.3.RELEASE

org.springframework
spring-context-support
4.0.3.RELEASE

org.springframework
spring-core
4.0.3.RELEASE

org.springframew ork
spring-expression
4.0.3.RELEASE

org.springframework
spring-instrument
4.0.3.RELEASE

org.springframework
spring-instrument-tomcat
4.0.3.RELEASE

org.springframework
spring-jdbc
4.0.3.RELEASE

org.springframework
spring-jms
4.0.3.RELEASE

org.springframework
spring-messaging
4.0.3.RELEASE

org.springframework
spring-orm
4.0.3.RELEASE

org.springframework
spring-oxm
4.0.3.RELEASE

org.springframework
spring-test
4.0.3.RELEASE

org.springframework
spring-tx
4.0.3.RELEASE

org.springframework
spring-web
4.0.3.RELEASE

org.springframework
spring-webmvc
4.0.3.RELEASE

org.springframework
spring-webmvc-portlet
4.0.3.RELEASE

org.springframework
spring-websocket
4.0.3.RELEASE

org.springframework.security
spring-security-acl
3.2.3.RELEASE

org.spring framework.security
spring-security-aspects
3.2.3.RELEASE

org.springframework.security
spring-security-cas
3.2.3.RELEASE

org.springframework.security
spring-security-config
3.2.3.RELEASE

org.springframework.security
spring-security-core
3.2.3.RELEASE

org.springframework.security
spring-security-crypto
3.2.3.RELEASE

org.springframework.security
spring-security-ldap
3.2.3.RELEASE

org.springframework.security
spring-security-openid
3.2.3.RELEASE

org.springframework.security
spring-security-remoting
3.2.3.RELEASE

org.springframework.security
spring-security-taglibs
3.2.3.RELEASE

org.springframework.security
spring-security-web
3.2.3.RELEASE

mysql
mysql-connector-java
5.1.30
compile

org.slf4j
slf4j-api
1.7.5
compile

org.slf4j
slf4j-log4j12
1.7.5
compile

< br>com.xoom.inf
xoom-boot-api
1.6
compile

com.xoom.inf
http-client
1.11
compile

commons-codec
commons-codec

com.xoom.inf
cluster
1.9
compile

jackson-mapper-asl
org.codehaus.jackson

org.flywaydb
flyway-core
3.0
compile

commons-io
commons-io
2.4
compile

commons-lang
commons-lang
2.6
compile

commons-codec
commons-codec
1.8
compile

com.xoom.common
common-util
12.4.68
compile

com.xoom.common
common-crypto
12.4.68
compile

commons-httpclient
commons-httpclient

commons-codec
commons-codec

org.springframework
spring-core
4.0.3.RELEASE
compile

org.springframework
spring-context
4.0.3.RELEASE
compile

org.springframework
spring-beans
4.0.3.RELEASE
compile

org.springframework
sp ring-web
4.0.3.RELEASE
compile

org.springframework
spring-jdbc
4.0.3.RELEASE
compile

org.springframework.security
spring-security-core
3.2.3.RELEASE
compile

org.springframework.security
spring-security-web
3.2.3.RELEASE
compile

org.springframework.security
spring-security-config
3.2.3.RELEASE
compile

org.springframework.security.oauth
spring-security-oauth2
2.0.1.RELEASE
compile

commons-codec
commons-codec

org.springframework.boot
spring-boot
1.1.1.RELEASE
compile

com.google.code.findbugs
jsr305
2.0.3
compile

javax.validation
validation-api
1.1.0.Final
compile

org.hibernate
hibernate-validator
5.1.1.Final
compile

junit
junit
4.11
test

org.hamcrest
hamcrest-all
1.3
test

org.jmock
jmock-junit4
2.6.0
test

hamcre st-core
org.hamcrest

hamcrest-library
org.hamcrest

org.springframework
spring-test
4.0.3.RELEASE
compile

com.xoom.common
common-test-junit4
12.4.68
test

mysql-connector-java
mysql

slf4j-log4j12
org.slf4j

co.freeside
betamax
1.1.2
test

junit
junit

commons-lang
commons-lang

httpclient
org.apache.httpcomponents

org.codehaus.groovy
groovy-all
1.8.9
compile

org.mockito
mockito-all
1.9.5
test


Reply to this email directly or view it on GitHub
#482 (comment).

@gsxoom
Copy link
Author

gsxoom commented Jun 27, 2014

I just found out the problem.
I removed irrelevant comments from this issue. It is in the mangofactory jar
[INFO] | +- com.mangofactory.swagger:swagger-models:jar:0.8.3:compile
[INFO] | | +- (org.springframework:spring-context:jar:4.0.3.RELEASE:compile - version managed from 3.2.7.RELEASE; omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.0.3.RELEASE:compile - version managed from 3.2.7.RELEASE; omitted for duplicate)
[INFO] | | +- (com.fasterxml:classmate:jar:1.0.0:compile - omitted for duplicate)
[INFO] | | +- (com.wordnik:swagger-core_2.10:jar:1.3.2:compile - omitted for duplicate)
[INFO] | | - (junit:junit:jar:4.11:compile - omitted for duplicate)

Their mangofactory SpringSwaggerConfig.java has the error.

@gsxoom gsxoom closed this as completed Jun 27, 2014
@gsxoom
Copy link
Author

gsxoom commented Jun 27, 2014

thank you very much for your promptness, follow-up, and patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants