Home > Mobile >  Why doesn't OpenAPI (JSON Schema) support unsigned integers?
Why doesn't OpenAPI (JSON Schema) support unsigned integers?

Time:12-01

I realise there are many similar questions about why Java or some other language doesnt support unsigned integers, but those are questions about the rationale and philosophy behind the design of a language, intended for creativity in expression of new things.

OpenAPI is supposed to be descriptive. If an API wants to expose 64 bit unsigned words it should be able to. And OpenAPI should facilitate code generators to build clients to consume that api.

Ok the argument could be taken on ad infinitum to allow all kinds of exotic primitive types. This could be pointed at as 'they had to draw a line somewhere'.

But unsigned 32-bit and 64-bit words are super common primitives. Why are they unsupported?.

Bonus: what REST API spec formats support them?

CodePudding user response:

Can't you do:

{
  "type": "integer",
  "minimum": "0"
}
  • Related