Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joi 1.16 update : Error: requires a joi schema object #57

Open
HugoHeneault opened this issue Nov 26, 2019 · 12 comments
Open

Joi 1.16 update : Error: requires a joi schema object #57

HugoHeneault opened this issue Nov 26, 2019 · 12 comments

Comments

@HugoHeneault
Copy link

While trying to convert my joi schema to JSON I got an error : AssertionError [ERR_ASSERTION]: requires a joi schema object

Here is my code :

import * as Joi from "@hapi/joi";

const convert = require("joi-to-json-schema");

const  report = Joi.object({
      part: Joi.string()
          .valid(['a', 'b', 'c'])
          .required(),
     })

convert(report);

This seems to be related to hapijs/joi#1834

We should use Joi.isSchema() instead.

I will try to provide a PR using isSchema when available then fallback to isJoi if it's OK for you.

@HugoHeneault HugoHeneault changed the title requires a joi schema object Error: requires a joi schema object Nov 26, 2019
@HugoHeneault
Copy link
Author

So looking deeper to this issue, I figured out that, as said on joi v16 release notes:

joi v16.0.0 is a massive release with many changes to every corner of the module and its extensions. The entire code base has been rewritten with many new features and core components.

Updating joi-to-json-schema to work with this new joi version will be more than just using Joi.isSchema(). I'm not sure I'll have enough time to go through all the fixes so I might downgrade my joi version for now.

If anyone need some help for doing the upgrade I could give a hand but not carry all by myself 😦

@HugoHeneault HugoHeneault changed the title Error: requires a joi schema object Joi 1.16 update : Error: requires a joi schema object Nov 26, 2019
@yeongjet
Copy link

Hope this project support the joi v16.

@yeongjet
Copy link

I forked this project in my repo then rewrote some code using typescript and made some adjustments to fit joi v16.0, almost test cases passed. May I make a pull request? @lightsofapollo

@BrianSo
Copy link

BrianSo commented Dec 25, 2019

@yeongjet I tried your repo and it is working, I really hope you could contribute your work to the repo.

But I found that you're changing all files to typescript and the commit message is update. Could you explain whether you have done any thing other than setting up a typescript development environment in the first update commit?

And did you remove any previous test cases?

@yeongjet
Copy link

@BrianSo No, in order to make these test cases running in jest, I have to make syntax modification, there's no difference in fundamental. Except these, the most noteworthy in my commit is remapping the fields and make them works in original logic.

@lightsofapollo
Copy link
Owner

@yeongjet Yes! This repo is in maintenance mode but I'd love some contributions particularly in typescript/new joi direction.

@yeongjet
Copy link

yeongjet commented Jan 5, 2020

@lightsofapollo There has a lot of changes in my commit, which branch should be merged? maybe create a new branch?

@simlu
Copy link
Contributor

simlu commented Jan 17, 2020

We'd love to see joi 1.16 supported as well

@simlu
Copy link
Contributor

simlu commented Mar 31, 2020

Any update on this?

@vgjenks
Copy link

vgjenks commented Mar 18, 2021

@lightsofapollo @yeongjet - any chance this will get merged? This is a package I really need, and it's completely broken in latest Joi. Looks like no movement in over a year. :( Dead project?

@simlu
Copy link
Contributor

simlu commented Mar 18, 2021

@vgjenks We now use https://www.npmjs.com/package/joi-to-json - works really well for our use case

Edit: Here is the corresponding github repo https://github.com/kenspirit/joi-to-json

@vgjenks
Copy link

vgjenks commented Mar 18, 2021

@simlu Works brilliantly, thank you! Will come back w/ feedback as I throw more complex schemas at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants