-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Fix id handling #178
base: master
Are you sure you want to change the base?
Fix id handling #178
Conversation
* Refactor JSON::Schema#initialize to move schema URI generation into its own method, #generate_schema_uri. * Refactor JSON::Schema#base_uri to do less path munging itself. * Fix ListOptionTest, which was relying on seemingly unintended behaviour where JSON::Schema's constructor was modifying a URI in-place, thus appending a '#' to the URI used in the test. As JSON::Schema's constructor doesn't modify its arguments anymore, this test started to fail.
This generates absolute URN URIs for schemas as necessary, rather than relative ones. Using relative URIs causes errors given schemas that should actually be valid. BadSchemaRefTest has been altered to use a reference to an invalid URI, rather than a valid relative URI.
@@ -50,14 +38,23 @@ def self.stringify(schema) | |||
end | |||
|
|||
def base_uri |
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.
Unless you introduced a new usage I haven't noticed, I think this method has been entirely unused since the first commit of this project. I propose just deleting it unless anyone has a reason to keep it. =)
Seems okay. I don't really grok why a schema would ever define a fragment as its top-level id, tho. I find it very difficult to reason about the Correct Behavior ™️ of the |
This introduces a few refactors and changes which fixes handling of what validates as a valid Draft 4 schema:
json-schema
validation to show it's a valid schema:It also validates against the Java
json-schema-validator
.Before these changes, trying to use the provided example schema would result in an exception:
This PR refactors some things and fixes the issue.