swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
773 stars 526 forks source link

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

Open spacether opened 7 months ago

spacether commented 7 months ago

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?