OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.8k stars 6.58k forks source link

[REQ][Java][Spring] Support BigInteger type #19956

Open jorgerod opened 2 weeks ago

jorgerod commented 2 weeks ago

Hi

Currently to support the BigInteger type you have to do it by defining your own typeMapping.

image

Is there any reason why BigInteger is not supported without doing that? For example, Bigdecimal is supported.

Maybe it could be defined like this:

          schema:
            type: integer
            format: bigint

Thank you

AndreasHae commented 2 weeks ago

Hi @jorgerod,

The generator is based on the OpenAPI specification (OAS), and your proposed solution is not listed in the defined formats. As the generator is just following the standard I don't think this should be added.

Maybe you can suggest your proposed solution in the OAS repository, I think many people could benefit from it. As long as it's not part of the standard I think the current type mapping solution is the correct one.

jorgerod commented 2 weeks ago

Hi @AndreasHae, thank you for your response.

True, it is not defined.

But as the documentation says, additional formats such as BigDecimal, email, password, uuid, etc. are being defined.

As defined by the JSON Schema Validation vocabulary, data types can have an optional modifier property: format. OAS defines additional formats to provide fine detail for primitive data types.

AndreasHae commented 2 weeks ago

Hi @jorgerod, I dug a bit further and it seems that the OpenAPI generator assumes that all integers are unbounded unless specified otherwise. This would mean that generating a "type": "integer" without a specified "format" should always lead to a BigInteger.