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

Wrong default value is generated for integer parameters #1472

Closed
asicignano opened this issue Oct 6, 2015 · 2 comments
Closed

Wrong default value is generated for integer parameters #1472

asicignano opened this issue Oct 6, 2015 · 2 comments
Assignees

Comments

@asicignano
Copy link

The Swagger generated for parameters with a type of integer are surrounded with quotes, when they should not be. This results in errors when attempting to use the Swagger in the editor, the Swagger Import tool for AWS, etc.

Example:

@QueryParam("page") @DefaultValue("1") @ApiParam(value = "Page to be returned") Integer page
generates

  parameters:
    - name: page
      in: query
      description: 'Page to be returned'
      type: integer
      default: "1"
      format: int32

the default should be without quotes:

  parameters:
    - name: page
      in: query
      description: 'Page to be returned'
      type: integer
      default: 1
      format: int32
@lugaru1234 lugaru1234 self-assigned this Oct 9, 2015
@lugaru1234
Copy link
Contributor

@asicignano, what swagger version do you use?
The issue does exist in 1.5.3, but it is fixed in 1.5.4-SNAPSHOT
This test works

public class DefaultValueTest {

    @Test
    public void scanResourceWithDefaultValue() {
        final Swagger swagger = new Reader(new Swagger()).read(ResourceWithDefaultValue.class);
        QueryParameter qp = (QueryParameter) swagger.getPath("/test").getGet().getParameters().get(0);
        final String json = "{" +
                "   \"name\":\"page\"," +
                "   \"in\":\"query\"," +
                "   \"description\":\"Page to be returned\"," +
                "   \"required\":false," +
                "   \"type\":\"integer\"," +
                "   \"default\":1," +
                "   \"format\":\"int32\"" +
                "}";
        SerializationMatchers.assertEqualsToJson(qp, json);
    }

    @Api("/test")
    @Path("/test")
    public class ResourceWithDefaultValue {
        @ApiOperation(value = "test")
        @GET
        public void getTest(@QueryParam("page") @DefaultValue("1") @ApiParam(value = "Page to be returned") Integer page) {
            return;
        }
    }
}

@webron
Copy link
Contributor

webron commented Oct 19, 2015

Closing this as fixed in 1.5.4 (release to come shortly). If that's not the case, please reopen.

@webron webron closed this as completed Oct 19, 2015
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

3 participants