-
Notifications
You must be signed in to change notification settings - Fork 12
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
[#353] Validation of external $ref property values should show error … #358
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8af6235
[#353] Validation of external $ref property values should show error …
ghillairet 9800da7
Merge branch 'master' into task/353
ghillairet f4420aa
Merge branch 'master' into task/353
ghillairet b1bd92e
[#353] Validation of external $ref property values should show error …
ghillairet 692270e
[#353] Validation of external $ref property values should show error …
ghillairet 8a3cec3
Merge branch 'master' into task/353
ghillairet e31f70a
Manually merge master into task/353
tfesenko 3d73a61
Merge branch 'master' into task/353
tfesenko 4b65e77
[#353] Validation of external $ref property values should show error …
ghillairet 4f7bc39
Merge branch 'master' into task/353
tfesenko 00d892b
[#353] Validation of external $ref property values should show error …
ghillairet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,9 +79,9 @@ public boolean isInvalid() { | |
} | ||
|
||
/** | ||
* Returns true if the reference points to an existing JSON document and the pointer to an existing node inside that | ||
* document. | ||
* Returns true if the reference cannot be resolved and the pointer points to an inexistent element. | ||
* | ||
* @param document | ||
* @param baseURI | ||
* @return true if the reference can be resolved. | ||
*/ | ||
|
@@ -100,19 +100,13 @@ public boolean isMissing(JsonDocument document, URI baseURI) { | |
* If the resolution of the referenced node fails, this method returns null. If the pointer does not points to an | ||
* existing node, this method will return a missing node (see JsonNode.isMissingNode()). | ||
* | ||
* @param document | ||
* @param baseURI | ||
* @return referenced node | ||
*/ | ||
public JsonNode resolve(JsonDocument document, URI baseURI) { | ||
if (resolved == null) { | ||
|
||
final JsonNode doc; | ||
if (isLocal()) { | ||
doc = document.asJson(); | ||
} else { | ||
doc = manager.getDocument(resolveURI(baseURI)); | ||
} | ||
|
||
JsonNode doc = getDocument(document, baseURI); | ||
if (doc != null) { | ||
try { | ||
resolved = doc.at(pointer); | ||
|
@@ -223,4 +217,19 @@ public static JsonPointer getPointer(ObjectNode node) { | |
} | ||
} | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Javadoc for /**
* Returns true if the reference points to an existing JSON document and the pointer to an existing node inside that
* document.
*
* @param baseURI
* @return true if the reference can be resolved.
*/
public boolean isMissing(JsonDocument document, URI baseURI) {
if (isInvalid()) {
return false;
}
JsonNode resolved = resolve(document, baseURI);
return resolved == null || resolved.isMissingNode();
} It returns true if the reference cannot be resolved and the pointer points to an inexistent element. |
||
* Returns the JSON document that contains the node referenced by this reference. | ||
* | ||
* @param document | ||
* @param baseURI | ||
* @return referenced node | ||
*/ | ||
public JsonNode getDocument(JsonDocument document, URI baseURI) { | ||
if (isLocal()) { | ||
return document.asJson(); | ||
} else { | ||
return manager.getDocument(resolveURI(baseURI)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are passing an entire URL to
JsonDocumentManager.getDocument(URL)
which includes both thefile
andref
parts.JsonDocumentManager.getDocument(URL)
has a table whose keys areURL
s in a form we are passing the here. As a result, for two different refs from the same external model will load the model twice. For example, for thebeamup_path_estimates_price.yaml
from the Multi-file Beamup (v3) example thedocuments
map will contain a different JsonNode model for each parameter:But it should be a single entry for
<...>/Multi-file%20Beamup%20(v3)/models/components/beamup_parameters.yaml
!We should fix
JsonDocumentManager.getDocument(URL)
.