Is there anyway I could make a Dynamic Schema enum from a database

Something like
“properties”: {
“selectSku”: {
“type”: “string”,
“enum”: “getSkuList(…, …)”
“inventoryNum”: {
“type”: “integer”,
“maximum”: “getInventory(…, $selectSku)”

  1. the enum of selectSku is a list from the database;

  2. the maximum of inventoryNum is queried from the database by the value of selectSku.
    or any other similar solution

Can we write a function in the schema with json? or any other similar solution to interact with database would definitely help.

[original thread by Erik_Ni]

Hi @erik-ni(erik-ni), we usually recommend a custom renderer for integrating dynamic enums. Simply model the respective propety as a string (like you did). In your custom renderer you can query the database and then delegate to our enum renderers.

To dynamically adapt the validation (for the maximum value) you can either customize Ajv or adapt the used JSON Schema whenever a new maximum value shall be set.


@erik-ni(erik-ni) , also see