2

I'm having an issue with adding proper examples to hapi-swagger with Joi. When I add .example('') to either the response schema or validate { payload: {} } it's adding an additional obj with a value.

    response: {
      schema: Joi.object().keys({
        name: Joi.string().example('Coinbase'),
        baseCurrency: Joi.string()
          .valid('USD', 'EUR', 'MXN', 'ETH', 'LTH', 'BTC'),
      }),
    },
    validate: {
      payload: Joi.object().keys({
        name: Joi.string().required(),
        baseCurrency: Joi.string().required(),
      }),
    },

enter image description here

What I expect is on the example value to have

{ "name": "Coinbase", "baseCurrency": "USD" }

Not

{ "name": { "value": "Coinbase" }, "baseCurrency": { "value": "USD" } }

Joseph Chambers
  • 3,698
  • 4
  • 22
  • 37

1 Answers1

2

Downgrade joi to v13.
Track issue on hapi-swagger github: https://github.com/glennjones/hapi-swagger/issues/540

isharko
  • 90
  • 11