Skip to content

Update for json-schema-org#167 #2

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

Merged
merged 1 commit into from
Dec 1, 2016
Merged

Conversation

awwright
Copy link

Some edits for json-schema-org#167

  • This shortens up the true/false definitions some,
  • makes the subschema is either an object or a boolean line informative instead of normative (it's a fact that's already true of all schemas), and
  • adds a line about prohibiting $ref from pointing to not-schemas (objects that are themselves $ref references) to hopefully remove a class of strange behavior, since root schemas shouldn't be $ref references

Copy link
Owner

@handrews handrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor questions/objections but otherwise looks good.

In addition to a boolean value or an object using schema kewyords defined
in the meta-schema, a schema may be represnted by an object containing a "$ref" property.
The value of the $ref is a URI Reference.
The "$ref" keyword is used to reference an externally defined schema, and provides the ability to validate recursive structures through self-reference.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"externally" suggests "external to the JSON Schema document" to me, but I primarily use "$ref" within the same document. What meaning were you going for here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to indicate schemas don't necessarily have to be inside the current one; it wasn't intended to mean exclusively. I'll take this out.

Resolved against the current URI base, it identifies the URI of a schema to use.
The referenced schema MUST NOT itself contain a "$ref" property.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this. While a double (or worse) reference is somewhere between silly and a bad idea, it could easily come up when different people maintain different parts of an ecosystem.

This is the kind of thing that would be caught by a linter rather than spec enforcement. I could support a SHOULD NOT here, though. Would that work for you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue the $ref behavior is only guaranteed for subschemas, this is one way of enforcing that.

The behavior can be done by placing it inside an "allOf" if desired.

But I suppose this is an issue for a... new issue anyways.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow here- when we spoke on IRC the idea was that both booleans and references would be valid schemas anywhere. It's a bit weird to have a schema that's just a reference but there could be a reason for it. I still think SHOULD NOT is more correct, but I think I might be missing part of your point.

@handrews
Copy link
Owner

@awwright not sure how email notifications work when I comment on an "outdated" diff, so putting it here too:

I'm not sure I follow the "only subschemas" line of thought here- when we spoke on IRC the idea was that both booleans and references would be valid schemas anywhere. It's a bit weird to have a schema that's just a reference but there could be a reason for it. I still think SHOULD NOT is more correct, but perhaps I'm just missing part of your point?

@handrews
Copy link
Owner

handrews commented Dec 1, 2016

@awwright Since I have filed json-schema-org#174 for the question of a reference being a valid root schema, I will go ahead and merge this in. We can modify it if we resolve json-schema-org#174 in favor of allow references as root schemas. If it goes the other way, this is a good clarification so might as well get it in now.

@handrews handrews merged commit 2501650 into handrews:bool2 Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants