question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add title and description annotations to JSON Schema elements

See original GitHub issue

From https://json-schema.org/understanding-json-schema/reference/generic.html#annotations

JSON Schema includes a few keywords, titledescriptiondefaultexamples that aren’t strictly used for validation, but are used to describe parts of a schema.

None of these “annotation” keywords are required, but they are encouraged for good practice, and can make your schema “self-documenting”.

The title and description keywords must be strings. A “title” will preferably be short, whereas a “description” will provide a more lengthy explanation about the purpose of the data described by the schema.

Currently, there is confusion over what certain variables in CSL JSON are supposed to containing. Setting title and description would be helpful in addressing this. Also it would allow for a single authoritative source of CSL JSON field documentation.

examples might also be helpful, but probably not as pressing:

New in draft 6 The examples keyword is a place to provide an array of examples that validate against the schema. This isn’t used for validation, but may help with explaining the effect and purpose of the schema to a reader. Each entry should validate against the schema in which is resides, but that isn’t strictly required. There is no need to duplicate the default value in the examples array, since default will be treated as another example.

However, the test suite could extract and test the examples, so examples could also help improve test coverage.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
dhimmelcommented, May 28, 2020

Do you have in mind a specific approach to this? What would a fragment look like?

Take for example:

https://github.com/citation-style-language/schema/blob/c194326df31e39b1eb3d48c0162f157af47147a6/csl-data.json#L64-L66

One could imagine the following documentation:

 "journalAbbreviation": { 
     "title": "Journal Abbreviation (deprecated)",
     "description": "Abbreviation for the journal name, ideally following the ISO 4 standard at https://www.iso.org/standard/3569.html. Use NLM Title Abbreviation when available. This field is deprecated, use container-title-short instead.",
     "type": "string",
     "examples": ["BMC Complement Med Ther", "Jt Dis Relat Surg"]
 }, 

Note that I don’t actually know anything about journalAbbreviation. So really you’d need someone who knows a bit more about CSL JSON usage and design to write this. I get the sense a lot of the meaning of fields has been established by practice, and is not centrally located anywhere.

But once these definitions are written, they can become the authoritative interpretations of these fields. @rmzelle do you know any places where many of these CSL JSON fields are documented?

0reactions
bdarcuscommented, Jun 29, 2020

I imagine we could post it alongside the documentation, on the main CSL site.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic keywords — Understanding JSON Schema 2020-12 ...
Annotations; Comments; Enumerated values; Constant values. This chapter lists some miscellaneous ... The title and description keywords must be strings.
Read more >
Getting Started Step-By-Step - JSON Schema
The title and description annotation keywords are descriptive only. They do not add constraints to the data being validated. The intent of the...
Read more >
Miscellaneous Examples - JSON Schema
Basic #. This example provides a typical minimum you are likely to see in JSON Schema. It contains: $id keyword; $schema keyword; title...
Read more >
Understanding JSON Schema
set the items keyword to a single schema that will be used to validate all ... the annotations title, description, and examples, JSON...
Read more >
A Media Type for Describing JSON Documents - JSON Schema
JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found