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

Array items failing validation #8

Closed
rainecc opened this issue Dec 21, 2016 · 2 comments
Closed

Array items failing validation #8

rainecc opened this issue Dec 21, 2016 · 2 comments

Comments

@rainecc
Copy link

rainecc commented Dec 21, 2016

yaml definition

testarray:
  type: "array"
  items:
    type: "integer"
    format: "int64"

sending this data in the body:

testarray: [1,5,9]

-or-

testarray: 1,5,9

returns this error:

body.testarray[0] is not of a type(s) integer, body.testarray[1] is not of a type(s) integer, body.testarray[2] is not of a type(s) integer

Of course, it may well be the format I am sending...

@mikestead
Copy link
Owner

mikestead commented Dec 21, 2016

It's a little hard to debug without seeing your parameter definition, but if you want testarray to be a property of the body then your schema should define the body as an object e.g.

# under 'paths'
/numbers:
  post:
    operationId: submitArray
    parameters:
      - name: body
        in: body
        schema:
          $ref: '#/definitions/SubmitArray'
...
# Under 'definitions'
SubmitArray:
  type: object
  properties:
    testarray:
      type: array
      items:
        type: integer
        format: int64

And then you'd post a payload looking like

{ "testarray": [1,5,9] }

@mikestead
Copy link
Owner

closing as I believe this is answered now

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