-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add a pointer argument to GenericSchemaDocument constructor. #1393
base: master
Are you sure you want to change the base?
Conversation
The patch is incomplete, when a I'm fixing this and will propose a new patch soon (with a test case). |
Fixed (hopefully) in latest proposal. |
I will review the code in a while. Thanks. |
@miloyip This is a very useful enhancement. I have the same requirement and am going to see if it works for my scenario. Please consider merging. |
@ylavic your PR makes this change to
Please may I ask why the second call is to |
Not sure where the need for With this PR, when a As a side note, I think that (with this PR still) using &Pointer("#") is functionally equivalent to NULL (for most cases where the |
This allows to parse schemas embedded in a non-schema Document, while still following $refs(s) based on the root of the original Document. Swagger files are examples of non-schema JSON files embedding schemas.
Rebased on current The optional |
@ylavic Thanks for reply. I think you are right about it being a brute force approach for documents that are not pure JSON schemas. However, when you take Because this area of code is affected by id/$ref, my PR #1848 includes the changes in this PR (not sure if you spotted that). |
A
Document
can embed JSON schemas but not be a schema itself as a whole (e.g. a Swagger file, see sample below).This PR allows to create a
SchemaDocument
from aPointer
into the sourceDocument
(some schema part), while local$ref
s still resolve from the root of the sourceDocument
.For instance, with the below swagger sample (approximative):
One can:
For the change to be minimal, this first proposed patch adds an optional
Pointer
argument (lastly) to the existingGenericSchemaDocument
constructor.It may be easier for the caller if a new
GenericSchemaDocument
constructor with a non optionalPointer
as second argument were provided, to avoid the NULLs and zeros above...