Open Ceres6 opened 1 year ago
cc @klaseca
I think I would revert all those changes. It cannot support all the third-party library. Especially, it cannot support fluent-json-schema
.
Under the hood, valueOf
is called when passing a schema from fluent-json-schema
. How about we remove this code and explicitly call valueOf
when passing the schema? It seems to me that if env-schema
should work not only with fluent-json-schema
, then there should be no code specifically for this library
How about we remove this code and explicitly call valueOf when passing the schema?
No, it should support out-of-the-box. Since, fastify
itself do the same.
cc @fastify/core WDYT?
Anyway, it would be a breaking change in either end. If no other fixes come up, the only choice is revert on current release.
I would also revert the problematic PR and maybe add fluent-json-schema as dependency or as peerDependency
Perhaps the best solution in this situation would be to return the object
type for the schema. At the same time, leave the re-import of the JSONSchemaType
type from the ajv
package. In this case, we will return the previous fully working state and leave the option to declare a type-checked schema
Fastify can support fluent-json-schema without the need of it being a dependency. Take a look how it's done there.
FWIW: Something similar is going on with types here when using with typebox
Prerequisites
Last working version
5.1.0
Stopped working in version
5.1.1
Node.js version
18.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.3
💥 Regression Report
Typings in Typescript now throw an error when using a
fluent-json-schema
generated schema as input forenvSchema
Steps to Reproduce
In a Typescript file the next block of code reproduces the issue
Nevertheless the following block of code does not throw an error
Expected Behavior
As
ObjectSchema
fromfluent-json-schema
was removed from typings in #137 it might be solved otherwise or maybe be documented to avoid future confusion