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

minItems not being respected in auto-generated example value #2076

Closed
hhromic opened this issue Nov 21, 2019 · 5 comments
Closed

minItems not being respected in auto-generated example value #2076

hhromic opened this issue Nov 21, 2019 · 5 comments

Comments

@hhromic
Copy link

hhromic commented Nov 21, 2019

Q&A (please complete the following information)

  • OS: Docker container in Linux
  • Browser: Chrome
  • Version: Version 78.0.3904.97 (Official Build) (64-bit)
  • Method of installation: Official Docker image
  • Swagger-Editor version: latest tag in Docker Hub
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example OpenAPI definition:

openapi: 3.0.2
info:
  title: 'Test'
  version: 1.0.0

paths:
  /test:
    get:
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                type: array
                items:
                  type: integer
                minItems: 3
                maxItems: 5

Describe the bug you're encountering

The Swagger Editor is ignoring the minItems attribute of an array-type response when auto-generating example values. Currently, only one item is being generated regardless of the minItems declaration in the schema.

To reproduce...

Steps to reproduce the behavior:

  1. Create a new API specification
  2. Copy/paste the minimum example in this issue
  3. Refer to the right-panel with the API preview
  4. Open the /test endpoint path and verify the example value being generated for the response

Expected behavior

Auto-generated example value showing at least minItems elements in the array. For the example in this issue, it should be showing something like this: [0, 0, 0].

Screenshots

image

@hhromic
Copy link
Author

hhromic commented Nov 21, 2019

Just verified it also happens in the live Swagger Editor: http://editor.swagger.io/

@GregNed
Copy link

GregNed commented Aug 29, 2021

Got the same issue. It makes one have to manually add the missing values which slows down the work. Any updates on the issue?

@hhromic
Copy link
Author

hhromic commented Aug 29, 2021

Thanks @GregNed for reminding me of this issue.

I can confirm that both, the latest Docker image and the online version of the Swagger Editor both seem to have fixed the issue:

image

I can also confirm that the latest Docker Image of the Swagger UI also is fixed 👍

@GregNed maybe try updating your local Swagger component to latest?

@hhromic hhromic closed this as completed Aug 29, 2021
@GregNed
Copy link

GregNed commented Aug 31, 2021

@hhromic Alright, let's close it then. I'm using it via the Connexion lib for Python. I guess they just haven't updated their dependencies yet.

@hhromic
Copy link
Author

hhromic commented Aug 31, 2021

@GregNed looks like you are not alone: spec-first/connexion#1412
And looks like a PR to update Swagger UI is already proposed so I guess you just have to wait :)

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

No branches or pull requests

3 participants