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

Swagger failed to load after using joi lazy(fn) #36

Open
ganeshkharche12 opened this issue Aug 27, 2018 · 3 comments
Open

Swagger failed to load after using joi lazy(fn) #36

ganeshkharche12 opened this issue Aug 27, 2018 · 3 comments

Comments

@ganeshkharche12
Copy link

Using JOI validation with lazy(fn) to check recursive validation. In this case swagger failed to load routes even all routes are working. Below are all the generated logs.

Failed to build API documentation for "/Demo"!
This is likely a bug in your Foxx service.
Check the route methods you are using to document your API. via Error: sorry, do not know how to convert unknown joi type: "lazy"
at convert (/usr/share/arangodb3/js/node/node_modules/joi-to-json-schema/build/index.js:186:11)
at Array.forEach (native)
at Object.array (/usr/share/arangodb3/js/node/node_modules/joi-to-json-schema/build/index.js:87:14)
at convert (/usr/share/arangodb3/js/node/node_modules/joi-to-json-schema/build/index.js:225:32)
at /usr/share/arangodb3/js/node/node_modules/joi-to-json-schema/build/index.js:167:43
at Array.forEach (native)
at Object.object (/usr/share/arangodb3/js/node/node_modules/joi-to-json-schema/build/index.js:165:25)
at joi2schema (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/swagger-context.js:568:10)

i already had opened this issue on github ArangoDB issues
arangodb/arangodb#6132

@pluma
Copy link

pluma commented Aug 27, 2018

Specifically the schema in question looks like this:

const Person = Joi.object({
    firstName: Joi.string().required(),
    lastName: Joi.string().required(),
    children: Joi.array().items(Joi.lazy(() => Person).description('Person schema'))
});

The relevant part of the stack trace is this:

Error: sorry, do not know how to convert unknown joi type: "lazy"
at convert (joi-to-json-schema/build/index.js:186:11)
at Array.forEach (native)
at Object.array (joi-to-json-schema/build/index.js:87:14)
at convert (joi-to-json-schema/build/index.js:225:32)
at joi-to-json-schema/build/index.js:167:43
at Array.forEach (native)
at Object.object (joi-to-json-schema/build/index.js:165:25)

ArangoDB is using joi 9.2.0 with version 2.3.0 of this library (but AFAICT 3.x also doesn't support lazy).

@lightsofapollo
Copy link
Owner

Yeah all but certain lazy was not a thing when we wrote the initial version. I will take a look but this is an area where we could honestly use some help.

@jeremymelchor
Copy link

Hi, any news on this issue ?

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

4 participants