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

Validation of minItems/maxItems array query parameter options #10

Closed
oloose opened this issue Dec 6, 2020 · 7 comments
Closed

Validation of minItems/maxItems array query parameter options #10

oloose opened this issue Dec 6, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@oloose
Copy link

oloose commented Dec 6, 2020

I am using the minItems and maxItems options for an array query parameter. The request validation does not automatically respond with a 400 Bad Request as I would expect when sending a request with less or more values as defined by the options.

Example request:

  • /pet/findByTags?tags=test1 (less than minItems)
  • /pet/findByTags?tags=test1,test2,test3,test4,test5,test6 (more than maxItems)

Version Info

  • GitCommit: 24ae678
  • GitBranch: master
  • GitTag: v1.0.0

OpenAPIv2 definition

swagger: '2.0'
info:
  version: 1.0.0
  title: Test
host:  localhost:8080
tags:
  - name: pet
schemes:
  - http
paths:
  /pet/findByTags:
    get:
      tags:
        - pet
      summary: Finds Pets by tags
      description: 'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.'
      operationId: findPetsByTags
      produces:
        - application/json
      parameters:
        - name: tags
          in: query
          description: Tags to filter by
          required: true
          type: array
          minItems: 2
          maxItems: 5
          items:
            type: string
          collectionFormat: csv
      responses:
        '200':
          description: successful operation
          schema:
            type: string
        '400':
          description: Invalid tag value

Expected behaviour

Server request validation automatically rejects the request and responds with 400 Bad Request.

@donutloop
Copy link
Contributor

donutloop commented Dec 12, 2020

@seseloos I will implement it soon or later

My upcoming pull request will contain:

  • The behaviour of this new validator constrain
  • A more than maxItems, less than minItems and in range test case
  • New test spec elements
  • Updated documentation
  • Updated auto generator code files

@seseloos seseloos added the enhancement New feature or request label Dec 12, 2020
@seseloos
Copy link
Contributor

@oloose thank you making up this feature request and enhancement for the APIKit

@seseloos
Copy link
Contributor

@seseloos I will implement it soon or later

My upcoming pull request will contain:

  • The behaviour of this new validator constrain

  • A more than maxItems, less than minItems and in range test case

  • New test spec elements

  • Updated documentation

  • Updated auto generator code files

@donutloop sounds good to me. Thanks for taking care of the enhancement. I am looking forward to see the result 👍

@donutloop
Copy link
Contributor

@seseloos I started working on this

@donutloop
Copy link
Contributor

@seseloos still working on it

@donutloop
Copy link
Contributor

Ref: #16

@seseloos
Copy link
Contributor

Done - Thank you @donutloop

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

No branches or pull requests

3 participants