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

schema.minItems and schema.maxItems problem #193

Closed
CiotkaCierpienia opened this issue Apr 3, 2020 · 0 comments · Fixed by postmanlabs/postman-app-support#8527
Closed
Assignees
Labels
bug Something isn't working

Comments

@CiotkaCierpienia
Copy link

Hello,

I'm one of the developers of Flotiq, and we use this package to generate Postman collection dynamically after the user makes changes to their API, but it generates with one issue. We sometimes require only one element in an array (it is described in maxItems in the schema of the parameter), and it is validated on POST and PUT requests.
However, this package always generates an array with 2 sample elements in an array, it is connected with

schema.maxItems = 2;
.

Because of that when the user sends the POST or PUT request it sometimes results in an error (Too many elements).

I'm wondering why this is hardcoded like that, and if I can make it more dynamic and post PR with that change. Something like this

// This nonsense is needed because the schemaFaker doesn't respect options.maxItems/minItems
      schema.maxItems = schema.maxItems ?? 2;
      schema.minItems = schema.minItems ?? 2;
      // have to create a shallow clone of schema object,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants