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

collectionFormat not allowed for array objects within a schema. #419

Closed
codymwalker opened this issue Jul 20, 2015 · 4 comments
Closed

collectionFormat not allowed for array objects within a schema. #419

codymwalker opened this issue Jul 20, 2015 · 4 comments

Comments

@codymwalker
Copy link

As defined in the spec, I can set collectionFormat if I create a parameter of type array.

"parameters": [
      {
        "name": "test",
        "in": "header",
        "description": "testDesc",
        "required": true,
        "type": "array",
        "collectionFormat": "csv",
        "items": {
          "type": "number"
        }
      }
    ],

However, if I were to create a body parameter or something else that requires properties, I would expect the behavior to be the same.

However, if I define my schema as below, creating a property of type array, I receive an error from the validator, saying that I am not allowed to provide a collectionFormat

"parameters": [
      {
        "name": "test",
        "in": "body",
        "description": "testDesc",
        "required": true,
        "schema": {
          "type": "object",
          "properties": {
            "testArray": {
              "type": "array",
              "collectionFormat": "csv",
              "items": {
                "type": "number"
              },
            }
          }
        }
      }
    ],

If I remove the collectionFormat line from the code above, the validator accepts it.

@webron
Copy link
Member

webron commented Aug 7, 2015

Actually, the spec doesn't allow for collectionFormat to be included in body parameters.

@codymwalker
Copy link
Author

Interesting, why would it be different between the two, with both being arrays?

@webron
Copy link
Member

webron commented Aug 7, 2015

Body parameters are, in most cases, models which are normally described as JSON objects. JSON has its way of defining arrays (as does XML). The reason collectionFormat was added was to allow the flexibility for the other parameter types where there's no standard whatsoever for specifying how multiple values are sent.

@codymwalker
Copy link
Author

Ah, that's good to know! Thanks!

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