swagger-api / swagger-api/swagger-codegen

Generation via swagger ui gives an incorrect default value for limit numbers

Open
#11,304 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Q&A (please complete the following information)
  • OS: RHEL 7 (docker)
  • Browser: yandex broser
  • Version: latest container (swagger ui)
  • Method of installation: docker
  • Swagger/OpenAPI version: 3.0.2
Content & configuration

Example Swagger/OpenAPI definition:

Path is:
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/checkNegativeNumbers"

ComponentSchema is:
    checkNegativeNumbers:
      type: "object"
      properties:
        negativeInteger:
          type: "integer"
          maximum: -1
      required:
      - "nonPositiveInteger"
      - "negativeInteger"
Describe the bug you're encountering

When specifying a negative maximum value (such as -1), swagger displays correctly. But if we generate a spring server, we get an incorrect default value of zero.

To reproduce...

Use swagger ui.

Steps to reproduce the behavior:

  1. Define any type with a number.
  2. Set maximum = -1.
  3. Generate a spring server.
Expected behavior

Json with a valid number in the generated code. (it very useful for autotesting)

Screenshots

image

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Swagger UI with the supplied OpenAPI 3.0.2 definition and reproduce Spring server generation for an integer with maximum -1. Trace how the negative maximum is used for the generated default value; done means the generated code contains a valid negative number instead of zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, spring
Domain
api, backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.