mrjono1 / joi-to-typescript

Convert Joi Schemas to TypeScript interfaces
MIT License
126 stars 40 forks source link

Joi.link syntax is not supported #281

Closed wangshijun closed 1 year ago

wangshijun commented 1 year ago

Joi supports link to create nested schema: https://joi.dev/api/?v=17.7.0#linkref

But seems this tool does not support it.

mrjono1 commented 1 year ago

Im open for a pr to add this feature

mrjono1 commented 1 year ago

I have looked into Link, I am not looking to support this feature, I would suggest splitting up the schema into smaller schemas and reference them instead

yegortokmakov commented 10 months ago

What about cases where schema self-references?

const person = Joi.object({
  firstName: Joi.string().required(),
  lastName: Joi.string().required(),
  friends: Joi.array().items(Joi.link('#person'))
}).id('person');
cur3n4 commented 1 month ago

I believe this is an option for self-references:

const person = Joi.object({
  firstName: Joi.string().required(),
  lastName: Joi.string().required(),
  friends: Joi.array().items(Joi.link('#person').meta({ className:'Person' }))
}).id('person').meta({ className:'Person' });
mrjono1 commented 1 month ago

Yes this should work