schema-format-defined
Since 0.9.0 · In the rulesets: Recommended at error, Strict at error, All at error
This rule ensures that numeric schemas specify the precision of their values
with a format.
Rule details
JSON Schema does not limit the size or the precision of numbers. Without a
format, code generators and consumers written in strongly typed languages
have to guess which native type to use, which often leads to overflows or to
lost precision.
The schema-format-defined rule checks every schema of an AsyncAPI document
and reports:
Schema with integer type does not define proper formatwhen a schema of typeintegerdoes not have theint32orint64format,Schema with number type does not define proper formatwhen a schema of typenumberdoes not have thefloatordoubleformat.
Turn the rule off if your messages are consumed only by clients written in dynamically typed languages, where the precision of numbers does not matter.
Examples
Good.
asyncapi: 3.0.0
info:
title: Order Events
version: 1.0.0
components:
schemas:
OrderPlaced:
type: object
properties:
quantity:
type: integer
format: int32
total:
type: number
format: double
Bad.
asyncapi: 3.0.0
info:
title: Order Events
version: 1.0.0
components:
schemas:
OrderPlaced:
type: object
properties:
quantity:
type: integer
total:
type: number
format: decimal
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.asyncapi has the details.
commands:
lint:
asyncapi:
rules:
schema-format-defined: off