swagger-api / swagger-api/swagger-parser

[REQ] request to adjust storage of numeric json schema constraints

Open
#2,023 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Right now these are the storage of some json schema numeric constraints for this library's Java parsing:
BigDecimal maximum/minimum
BigDecimal exclusiveMaximum/exclusiveMinimum
Integer minLength/maxLength
Integer minProperties/maxProperties
Integer minItems/maxItems
BigDecimal multipleOf

And these are the definitions per the 2020-12 json schema draft:
maximum/minimum (defined as number)
exclusiveMaximum/exclusiveMinimum (defined as number)
minLength/maxLength (defined as non-neg integer)
minProperties/maxProperties (defined as non-neg integer)
minItems/maxItems (defined as non-neg integer)
multipleOf (defined as number > 0)
the josn schema spec does not define any allowed maxes, so json specifications are the only limit on number and integer sizes here

So the range defined is

Keywords Spec Definition Current Java Definition Proposed Java
exclusiveMaximum/exclusiveMinimum defined as number BigDecimal BigDecimal or Number
minLength/maxLength defined as non-neg integer Integer Long or BigInteger
minProperties/maxProperties defined as non-neg integer Integer Long or BigInteger
minItems/maxItems defined as non-neg integer Integer Long or BigInteger
multipleOf defined as number > 0 BigDecimal BigDecimal or Number

I am aware that ArrayList size and String size is integer (32 bit) in Java and your parser is used to generate code in many languages in openapi-generator and other projects. Those languages have different constraints.
In python for example list size + string size is limited by your architecture and can be 32 bit or 64 bit maximums.
For this reason, can the below keywords be changed to Long or BigInteger?

  • minLength/maxLength
  • minProperties/maxProperties
  • minItems/maxItems

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

No source files or tests are named. Start by locating the Java definitions and parsing paths for minLength, maxLength, minProperties, maxProperties, minItems, and maxItems. Determine whether Long or BigInteger is appropriate, then verify that the selected representation supports the JSON Schema range without breaking the parser's generated-code consumers.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
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.