question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Joi 14 | Example

See original GitHub issue

Context

  • hapi-swagger version: 9.1.2
  • hapi: 17
  • Joi: 14

What are you trying to achieve or the steps to reproduce?

We have recently upgraded our hapi from version 16 to 17, Joi from 12 to 14 and hapi swagger from 7 to 9. Since than our examples on the documentation page are coming incorrect.

Previous

{
  "someField": "someValue"
}

Now

{
  "someField": {"value": "someValue"}
}

Json schema looks like this

{"someField": Joi.string().example("someValue")}

because of this if someone clicks on example and click “Try It out” it gives bad request because schema doesn’t allow “value”.

I guess this is related to Joi 14 in which examples have started to come in value. Is there any workaround, options or plan to fix this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

4reactions
nickeljewcommented, Nov 15, 2018

Please fixed code in lib/properties.js line 221 as following:

property.example = Hoek.reach(joiObj, '_examples.0.value');
2reactions
robmcguinnesscommented, Mar 10, 2019

https://github.com/glennjones/hapi-swagger/releases/tag/v9.3.2 contains compatibility fix for Joi 14 and examples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Joi — awesome code validation for Node.js and Express
Validation of data is an interesting topic, we tend to write code that looks really horrible in the sense that it contains a...
Read more >
How To Use Joi for Node API Schema Validation - DigitalOcean
In this example, you will create validation rules using Joi to validate an email, phone number, and birthday for a request to create...
Read more >
14.0.0 Release Notes · Issue #1615 · hapijs/joi - GitHub
Summary This major version introduces a lot of breaking changes, trying to fix some long lasting quirks. Most of the breaking changes should ......
Read more >
This version has been deprecated - joi - npm
Author message: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest ...
Read more >
NodeJS and Express API Request Schema with Joi Validation
Widely accepted and well-known package for data validation. Supports validation based on the schema. Let us start with creating a simple demo ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found