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

Integer sample value does not adhere to minimum constraint (while number does) #9740

Closed
twankamp opened this issue Mar 25, 2024 · 2 comments
Closed

Comments

@twankamp
Copy link
Contributor

Q&A (please complete the following information)

  • OS: Any
  • Browser: Any
  • Version: Latest
  • Method of installation: npm
  • Swagger-UI version: Latest
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

See OpenAPI defintion below.
Sample output is:

{
  "integer": 0,
  "number": 4
}

But should be

{
  "integer": 4,
  "number": 4
}

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  version: 1.0.0
  title: Test minimum
paths:
  /path:
    get:
      description: Get example
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Test"
components:
  schemas:
    Test:
      type: object
      properties:
        integer:
          type: integer
          minimum: 4
        number:
          type: number
          minimum: 4

Swagger-UI configuration options:
none

Describe the bug you're encountering

When describing an integer with a minimum > 0, the example generates 0 which violates the schema (however, for a number with the same constraint, the minimum value is correctly generated in the example).

To reproduce...

Input above schema in swagger editor (or any schema using an integer with minimum constraint).

Expected behavior

The example generates an integer according to the minimum constraint

Screenshots

image

@glowcloud
Copy link
Contributor

Addressed by #9749

@char0n
Copy link
Member

char0n commented Mar 27, 2024

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