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

boolean parameters with default attribute, if parameter is not configured in the json, swagger will generate a null pointer for this field #1892

Closed
monstercy opened this issue Mar 1, 2019 · 2 comments
Labels

Comments

@monstercy
Copy link

Problem statement

boolean parameter with default attribute, if this parameter is not configured in the json, swagger will generate a null pointer for this parameter

Swagger specification

swagger: '2.0'
info:
  version: 0.1.0
  title: testserver
basePath: /v1
consumes:
  - application/json
produces:
  - application/json
paths:
  /test:
    post:
      parameters:
        - in: body
          name: testInfo
          schema:
            $ref: '#/definitions/TestInfo'
      responses:
        200:
          description: OK
        default:
          description: generic error response
          schema:
            $ref: "#/definitions/Error"
definitions:
  TestInfo
    type: object
    properties:
      myFlag:
        type: boolean
        default: false
      age:
          type: integer
  Error:
    type: object
    properties:
      code:
        type: integer
        format: int64
      message:
        type: string

Steps to reproduce

Environment

swagger version: v0.18.0
go version go1.11.4
OS: linux

@casualjim
Copy link
Member

for the default to take hold you have to either make the field required, or set x-isnullable: false on the field

@fredbi fredbi added the nullable label Mar 1, 2019
@gregmarr
Copy link
Contributor

gregmarr commented Mar 1, 2019

The default: false here should have no effect, as that is already the default for booleans. Also, this shouldn't be a pointer because it's not required.

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

No branches or pull requests

4 participants