gothinkster / hapijs-realworld-example-app

Real World Hapi.JS + Mongoose backend implementations
https://realworld.io
78 stars 26 forks source link

HapiJs example() #5

Closed rajeevmca11 closed 3 years ago

rajeevmca11 commented 5 years ago

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

geromegrignon commented 3 years ago

Hello, closing this issue as unrelated to the project itself.