-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Update "format" and "content*" for new JSON Schema #2200
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
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c30d42
Update "format" and "content*" for new JSON Schema
handrews bee0974
"format" is an annotation
handrews 9135acd
Fix broken table, type, in Encoding Object
handrews 25d808e
Fix format of `format`
handrews dcf9878
Remove unneeded detail on "format"
handrews 7f49b70
Remove "byte" and "binary" formats altogether.
handrews e673a5b
Harmonize JSON Schema content* + Media Type Object
handrews 3c0a067
Fix typos from review
handrews 8105a91
Remove stray {}
handrews b48c032
Fix inconsistencies contentMediaType and Encoding Object
handrews 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
"format" is an annotation
- Loading branch information
commit bee097486732ad6ddc2d72035935c6680d803e05
There are no files selected for viewing
This file contains hidden or 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
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.
In the company I work for we use UUIDs to identify resources so
type: string format: uuid
is super common in our schemas. And we do leverage that information for a number of things.It seems that this note is motivated by the current implementations in the wild, which does not seem like a good reason to include it to a standard. If these validators start improving would this note go away? At what point? How many good validators out there would it make it happen?
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.
@jcarres-mdsol
uuid
and all other formats that are no longer explicitly listed are now part of JSON Schema proper. See Section 7.3.5 "Resource Identifiers" under theformat
keyword's specification foruuid
and also how it relates to URNs of the formurn:uuid:
.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.
@jcarres-mdsol As for validators actually validating
format
, no, that's not going to happen. I don't mean that in a "we (the JSON Schema project) decided it shouldn't happen", I mean it in "this has been a problem for years, and after talking with numerous maintainers of major implementations, it is 100% clear thatformat
is a confusing mess that will not be validated consistently no matter how much the spec says it should be." At some point you have to bow to reality and figure out a way forward, and saying that by default implementations MUST NOT attempt to validate using theformat
keyword was the only possible way to produce consistent default behavior. This is explained in detail in the JSON Schema draft's release notes.The problem with
format
is that it tries to do a huge number of things, and be open-ended to any extension anyone wants to throw in there. There's not even agreement on what fully validatingformat
would involve. My hope is that with re-usable extension vocabularies being a thing, people will design vocabularies with keywords that validate specific things, instead of shoving them into this all-purpose-but-never-reliable keyword.So an
isUuid
keyword would be straightforward to implement b/c UUIDs are well-specified. For something likeemail
, where there's no consensus on what "valid email" means, people could create keywords with specific criteria.isProbablyEmail
might just check for an@
in the string (this is what several validators actually do right now).isEmailByRegex
might specify validation against a specific regex (instead of what happens now, which is that each validator comes up with its own incredibly complex regex that they probably got from a web site somewhere).isEmailBySomeLibraryName
would define what library to use to validate, etc.These keywords would then be supported or not, which could be detected/enforced using the
$vocabulary
mechanism, and would reliably provide whatever level of validation they specify. You could require support forisUuid
but not require any sort of email validator, for example- that would be likely to be supported. As would keywords for RFC 3339 date and time values, which are likewise well-specified.Ultimately, I hope to deprecate
format
because it's always been a compatibility nightmare. But that will only happen if enough replacement vocabularies are developed and adopted widely enough to be a viable migration path.Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for the detailed response. Hopefully the plan will go as expected. I'm worried about the complexity of all this, I wonder if people will shy away from vocabularies and just keep shoveling everything into format anyways. But time will tell.
Thanks for your efforts!
Uh oh!
There was an error while loading. Please reload this page.
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.
@jcarres-mdsol we're definitely starting to see people understand the utility of the vocabulary concept on our slack. But really, if enough people accept vocabularies as a solution here, we'll deprecate/remove
format
. If they don't, we won't. [EDIT: although we may look for other ways to do so]