schema-format-defined
Since 0.0.1 · In the rulesets: Recommended at error, Strict at error, All at error
This rule checks that every integer and number schema has a format that says its size:
int32, int64 or another integer format for integers, float, double, decimal or another
number format for numbers.
Rule details
A bare integer is a 32-bit int in one generated client and a 64-bit one in another, and a
bare number is a float in one and a double in the next; an ID that fits one and not the
other is a bug found in production. The format names the size, and every generator picks the
same type.
The rule accepts, for integer, the integer formats of the
OpenAPI format registry (int8 to uint64, int32, int64,
double-int, sf-integer) and unixtime; for number, the number formats (float, double,
decimal, …); and a format of openapi.custom_formats of the matching type. It reports
Schema with integer type does not define proper format and Schema with number type does not define proper format.
Examples
Good. A 64-bit identifier.
components:
schemas:
User:
type: object
properties:
id:
type: integer
format: int64
Bad. 32 or 64 bits? Each generator decides.
components:
schemas:
User:
type: object
properties:
id:
type: integer
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.
commands:
lint:
rules:
schema-format-defined: off