how to write complex structure to show up as example for user in payload of a swagger API with
hapi js and JOI
complex structutre for like below format:
{
"name" : "aaa",
"age" : 32
"Alladresses" : [{
"country" : "USA"
"city" : "newyork"
"duration" : "2yrs"
},
{ "country" : "India"
"city" : "bangalore"
"duration" : "5yrs"
}
]
}
for name and age I can write as below
payload: Joi.object().keys({
name : Joi.string().example("aaa"),
age : Joi. numbe().example(32),
Alladresses : ?
)}
But how should I write example() correctly to show up my example format as above to the user
My endpoint expecting user to enter the payload as shown in above example, for simple string I am able to make it but when the key it self a kind of complex strucutre(like Alladresses) then how to show up by example() of joi
how to write complex structure to show up as example for user in payload of a swagger API with hapi js and JOI complex structutre for like below format: { "name" : "aaa", "age" : 32 "Alladresses" : [{ "country" : "USA" "city" : "newyork" "duration" : "2yrs" }, { "country" : "India" "city" : "bangalore" "duration" : "5yrs" }
] }
for name and age I can write as below payload: Joi.object().keys({ name : Joi.string().example("aaa"), age : Joi. numbe().example(32), Alladresses : ? )} But how should I write example() correctly to show up my example format as above to the user
My endpoint expecting user to enter the payload as shown in above example, for simple string I am able to make it but when the key it self a kind of complex strucutre(like Alladresses) then how to show up by example() of joi