OpenAPITools / OpenAPITools/openapi-generator

[BUG] Overflow in maximum value validator (python and others)

Open
#12,565 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Client: Python Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

With a schema like this:

"item": {
  "maximum": 18446744073709551615,
  "type": "integer",
  "minimum": 0
}

The python generator produces a validator like this:

      validations = {
          ('value',): {
              'inclusive_maximum': -1,
              'inclusive_minimum': 0,
          },
      }

It seems like that maximum value is overflowing. (These ranges are automatically generated by my openapi library for uint64_t types.) This also affects a number of other generators I've tried.

openapi-generator version
>docker run --rm openapitools/openapi-generator-cli version
6.0.1-SNAPSHOT
OpenAPI declaration file content or url
{"openapi":"3.0.0","info":{"version":"2.0","title":"Test API"},"servers":[{"url":"http://localhost:8092/api"}],"paths":{"/":{"get":{"operationId":"top","responses":{"200":{"$ref":"#/components/responses/top"}}}}},"components":{"schemas":{"item":{"maximum":18446744073709551615,"type":"integer","minimum":0}},"responses":{"top":{"description":"top result","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/item"}}}}}}}}
Generation Details
docker run -v $PWD:/data --rm openapitools/openapi-generator-cli generate -i /data/openapi.json -g python -o /data/python

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

Reproduce the issue using the provided OpenAPI declaration and the Python generator command in Docker, then inspect how the maximum constraint becomes the generated validator's inclusive_maximum value. Trace the shared generator or template path responsible and check whether the same overflow affects the other generators mentioned. Done means the uint64 maximum remains correct in generated validation and regression coverage confirms it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.