Twipped / joi-to-swagger

A library to convert Joi schema objects into Swagger schema definitions
Other
164 stars 63 forks source link

Meta options (className, swagger and swaggerOverride) #65

Closed kfpo closed 3 years ago

kfpo commented 4 years ago

Hello! I have few questions/issues with meta options:

  1. Meta option swagger can't be used with className, since it returns before override: https://github.com/Twipped/joi-to-swagger/blob/00b1fb88d00ef8f2f0964eb64131ca120620ed65/index.js#L380 https://github.com/Twipped/joi-to-swagger/blob/00b1fb88d00ef8f2f0964eb64131ca120620ed65/index.js#L384 E.g.:
    const schema = Joi.string().meta({
    className: 'Email',
    swagger: {
    format: 'email'
    }
    });
    const { components } = j2s(schema)

    Expecting:

    components // => { Email: { type: 'string', format: 'email' } }

    Got:

    components // => { Email: { type: 'string' } }
  2. swaggerOverride can't be used with className, since it returns no components in this case: https://github.com/Twipped/joi-to-swagger/blob/00b1fb88d00ef8f2f0964eb64131ca120620ed65/index.js#L320

Perhaps it was made intentionally, but maybe this info should be added to Readme?

Versions:

Mairu commented 3 years ago

A very late answer: I don't know if it was intended, but I think there is no reason to support it. So I changed the behavior with version 6