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 boolean #1368

Closed
fennekit opened this issue Aug 16, 2015 · 13 comments · Fixed by #1378
Closed

Wrong default value is generated for boolean #1368

fennekit opened this issue Aug 16, 2015 · 13 comments · Fixed by #1378
Labels
Milestone

Comments

@fennekit
Copy link
Contributor

In the snippet below the yaml and json generated by swagger-core is not correct according to the editor.swagger.io. The default value for the booleans are generated as "false" instead of false. The error that is given is "Not a valid boolean: false"

    @GET
    @ManagedAsync
    @ApiOperation(value = "Get ships in area",
        notes = "Get ships",
        response = ShipInfo.class,
        responseContainer = "List")
    @ApiResponses(value = { 
              @ApiResponse(code = 404, message = "No ships found") })
    public void allShipsInBoundingbox(
            @ApiParam(value = "Maximum Latitude", required = false) @QueryParam("topLeftLat") Double topLeftLat,
            @ApiParam(value = "Minimum Longitude", required = false) @QueryParam("topLeftLon") Double topLeftLon,
            @ApiParam(value = "Minimum Latitude", required = false) @QueryParam("bottomRightLat") Double bottomRightLat,
            @ApiParam(value = "Maximum Longitude", required = false) @QueryParam("bottomRightLon") Double bottomRightLon,
            @DefaultValue("false") @QueryParam("optin") Boolean optIn,
            @DefaultValue("false") @QueryParam("showAged") Boolean showAged,
            @Suspended final AsyncResponse response) {
  /ship:
    get:
      summary: "Get ships in area"
      description: "Get ships"
      operationId: "allShipsInBoundingbox"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - name: "topLeftLat"
        in: "query"
        description: "Maximum Latitude"
        required: false
        type: "number"
        format: "double"
      - name: "topLeftLon"
        in: "query"
        description: "Minimum Longitude"
        required: false
        type: "number"
        format: "double"
      - name: "bottomRightLat"
        in: "query"
        description: "Minimum Latitude"
        required: false
        type: "number"
        format: "double"
      - name: "bottomRightLon"
        in: "query"
        description: "Maximum Longitude"
        required: false
        type: "number"
        format: "double"
      - name: "optin"
        in: "query"
        required: false
        type: "boolean"
        default: "false"
      - name: "showAged"
        in: "query"
        required: false
        type: "boolean"
        default: "false"
      responses:
        404:
          description: "No ships found"
        200:
          description: "successful operation"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/ShipInfo"
@webron
Copy link
Contributor

webron commented Aug 16, 2015

Yup, that's indeed a bug. Which version of swagger-core have you tried it with?

@fennekit
Copy link
Contributor Author

I am using 1.5.0

@webron
Copy link
Contributor

webron commented Aug 16, 2015

While I seriously doubt it's been resolved, can you give 1.5.3 a try?

@fennekit
Copy link
Contributor Author

Am trying right now. Namespace have changed....

@webron
Copy link
Contributor

webron commented Aug 16, 2015

Not from 1.5.0 - unless you meant one of the Milestone versions (M1, M2, M3). 1.5.0 (final) already has a namespace change. In any case, if you're on any of the milestones, I'd highly recommend upgrading. Thanks for giving it a try.

@fennekit
Copy link
Contributor Author

Is there a mvn package for 1.5.3?

@webron
Copy link
Contributor

webron commented Aug 16, 2015

yup, just change the groupId from com.wordnik to io.swagger.

@fennekit
Copy link
Contributor Author

Tried the 1.5.3. Same issue

@webron
Copy link
Contributor

webron commented Aug 16, 2015

Okay, thanks for the confirmation. We'll have to look into it.

@wsalembi
Copy link

Please look into the other primitive types too. Too bad JAX-RS @DefaultValue only uses strings, so conversions are needed.

 @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.

lugaru1234 added a commit to lugaru1234/swagger-core that referenced this issue Aug 20, 2015
@webron webron added this to the v1.5.4 milestone Aug 20, 2015
webron added a commit that referenced this issue Aug 20, 2015
Fixes #1368: DefaultValue has been fixed
@asicignano
Copy link

This issue appears to have been fixed for Boolean types in the latest version. However, (unless I am mistaken) the issue still exists for other types, such as integer, as reported by @wsalembi.

Can you confirm that this issue still exists?

@webron
Copy link
Contributor

webron commented Oct 5, 2015

@wsalembi, @asicignano - if the issue indeed exists for other types as well, please open a new ticket for it. The PR dealt with the issue as it was reported, and at least for the sake of documentation, I'd rather we resolve other types in a new ticket rather than opening this one. It should work for at least some other types, even if not all.

@asicignano
Copy link

Thank you for the response. I can appreciate the desire to keep the PRs
clean for the sake of documentation.

I have created a new ticket (
#1472) to look into the
issue with integers specifically.

Thank you,
Anthony Sicignano

On Mon, Oct 5, 2015 at 3:35 PM, Ron notifications@github.com wrote:

@wsalembi https://github.com/wsalembi, @asicignano
https://github.com/asicignano - if the issue indeed exists for other
types as well, please open a new ticket for it. The PR dealt with the issue
as it was reported, and at least for the sake of documentation, I'd rather
we resolve other types in a new ticket rather than opening this one. It
should work for at least some other types, even if not all.


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

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

Successfully merging a pull request may close this issue.

4 participants