JSON Schema
JSON schema is a powerful tool for validating the structure of JSON data. The following are the advantages of using JSON schema.
-
Describes your existing data formats.
-
Provides clear human-and machine-readable documentation.
-
Validates data that is useful for:
-
Automated testing.
-
Ensuring quality of client-submitted data.
-
The most basic schema is a blank JSON object, which constrains nothing, allows anything, and describes nothing.
You can apply constraints on an instance by adding validation keywords to the schema. Consider the type keyword which can be used to restrict an instance to an object, array, string, number, boolean, or null.
Certain APIs in Finesse JavaScript library may require the user to input objects with complex structures. Having a standard way of validating and providing the input is beneficial for both the consumer and the provider.
There are classes such as the PopoverSchema and ChannelSchema in Finesse JavaScript library which provide APIs such as the getActionDataSchema()
and getChannelConfigSchema()
. These APIs return a human-readable schema for a valid input for the APIs such as the showPopover()
and addChannel()
in a human-readable fashion.
Inspecting the JSON schemas helps to realize the combinations of valid inputs, which can be provided to some of the Finesse JavaScript APIs. For more information on understanding the JSON schema, see https://json-schema.org/understanding-json-schema/.