-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Schema absolute references failure #2446
Comments
Given that you are not using |
Actually, that doesn't mesh with our docs:
@Eomm do you have any insight to offer? |
Unfortunately, the footnote is right for the "serializer compiler" too. I think it would simple to implement, here: Line 270 in 61e8361
we should write But it is not doable (right now) because:
|
It sounds to me like we have a broken feature. As I suggested in #2023 (comment), I think we should define an API contract for user supplied schema containers. Something like: fastify.setSchemaContainer(containerInstance) Where {
addSchema({name, schema}) {}, // `name` is optional if `schema` has a `$id` property
getSchemaValidator (id) {}, // returns function to validate data against schema
getSchema (id) {} // returns raw JSON Schema
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Leaving myself a note to consider #2568 as part of this. |
Regarding the interface of the
Line 46 in 6b64483
Line 129 in 6b64483
Line 269 in 6b64483
The process for the serialization is quite the same:
fastify/lib/schema-compilers.js Line 55 in 6b64483
NB: in this case, you are experiencing the issue that origins this ticket: the fastify So I think we should consider that the
I hope this will help to understand the flow and I'm more than happy to help. |
😕 If we have to go semver-major, so be it. I'm not opposed to skipping v3 (I cannot use v3 until this is solved). But if we go with a major change, then we should take some time to work out what the container interface should be. My work on this specific issue would probably be a very minimal hack just to make things work. I'm really not familiar with all of the pieces of schema code within Fastify. |
As you said in the AJV7 issue, I totally agree that moving AJV out of the dependencies with an abstraction layer would improve and simplify a lot the usage of schemas and the customization of validation/serialization! I don't want to be harsh here or slow down your idea on how to solve this specific issue -- PS: when I worked on it for v3 my target was to avoid the tons of |
I'm not offended. The only thing I'm disappointed about is not yet being able to prioritize fixing this "on the clock" and having to do it on my own time. If you get an itch to work on this before I push up a branch, feel free. But I am not expecting anyone to work on this other than myself. |
I don't think this is accurate. I think the schema container needs to provide schemas, full stop. It is Fastify's responsibility to acquire schemas from that container and use them in whatever context it deems necessary. For input validation, this is rather simply a case of |
I'm experiencing the same issue while trying to use my own AJV instance. I need to define a custom keyword in AJV, and seems like its impossible to do so. |
🐛 Bug Report
When registering routes with schemas that include properties with absolute references to other schemas the following error is generated:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The route schema should resolve any references without crashing.
Your Environment
The text was updated successfully, but these errors were encountered: