-
-
Notifications
You must be signed in to change notification settings - Fork 74
Create JSON Schema for YAML File #192
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
base: main
Are you sure you want to change the base?
Conversation
…, move description to root of `parent` schema
|
The specification is not fully up to date as the fields added in #102 ( |
reknih
left a comment
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.
I found a few mismatches with basic.yml. I think that before merging this, we should at a test that checks whether basic.yml (which is normative) passes the schema. We can do this using jsonschema.
hayagriva.schema.json
Outdated
| "title": { | ||
| "type": "string", | ||
| "description": "The title of the item.", | ||
| "examples": [ | ||
| "Rick Astley: How An Internet Joke Revived My Career" | ||
| ] | ||
| }, |
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.
Does not support the object mode:
title:
value: "ZygOS: Achieving Low Tail Latency for Microsecond-Scale Networked Tasks"
verbatim: true
# also possible: sentence-case, title-case, shortThere 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.
Do sentence-case and title-case still need to be handled? I just saw that they were removed for any formattable string in 0.4.0. Is that still the case?
If so, basic.yml might need updating, as it lists certain title entries with those fields.
hayagriva/tests/data/basic.yml
Line 42 in edec836
| sentence-case: There’s a lot we still don’t know about Libra |
There's also an entry in basic.yml that uses a translation field. Is that still in use?
hayagriva/tests/data/basic.yml
Line 227 in edec836
| translation: Renaissance, The Unrooted |
Feel free to point me towards somewhere in the codebase where I could investigate myself; It's been a while since I've worked on this and don't want to be too burdensome with questions.
|
And remember upload it to schemastore 😄 |
|
I'd like to contribute to this PR, since I like Hayagriva and am currently working with it for my thesis. How could I help? |
We don't have a confirmation yet as to whether these changes will be merged or whether further modifications could be needed, so we can't guarantee a speedy merge, but if you're willing to pick up this work, you're free to address the reviews in your own branch and submit a new PR. |
|
Finally got back around to working on this! There Person Fields
2025-02-24: Addressed by @jassielof's improvements to the schema. Affiliated Roles
2025-02-24: Addressed by @jassielof's improvements to the schema. TestsI added tests for validating the schema itself, as well as validating Let me know if any of that should be changed to comply with the package's architecture. |
…-insensitive. Typst `#bibliography()` with a Hayagriva reference doesn't automatically defaults to `Misc` if no type is specified (it asks for a type to be specified). Aside from that, the types are not fully case-insensitive. If the type is "ArticlE", it'll throw error asking for it to be either "Article" or "article".
…rmat.md specifications, but rather all roles are lowercase. Both commits can be easily reverted in case the Typst validation is fixed as specified in the file-format.md specifications. Otherwise the changes will be kept to comply with the current Typst validation.
|
We should probably also mention It works with the redhat yaml LSP, which I used on nvim before and also works on VS Code (both combined must cover a substential part of Typst users, outside of Typst.app) |
|
https://github.com/sourcemeta/jsonschema reports some issues on the https://github.com/mkdjr/hayagriva/blob/0c640417cfb35067c13f1ee0ce0ee35f57a897fb/hayagriva.schema.json file, so you might want to fix some of them: $ curl -fsSLO https://github.com/mkdjr/hayagriva/raw/0c640417cfb35067c13f1ee0ce0ee35f57a897fb/hayagriva.schema.json
$ ./jsonschema version
9.3.4
$ ./jsonschema lint hayagriva.schema.json | sed -e 's/'"$(printf '%s\n' "$PWD" | sed -e 's/[\/&]/\\&/g')"'/./g'
./hayagriva.schema.json:
Only include instances in the `examples` array that validate against the schema (blaze/valid_examples)
at schema location "/definitions/affiliatedList"
Invalid example instance at index 0
The value was expected to be of type array but it was of type object
at instance location ""
at evaluate path "/type"
./hayagriva.schema.json:
Only include instances in the `examples` array that validate against the schema (blaze/valid_examples)
at schema location "/definitions/entry"
Invalid example instance at index 0
The value was expected to be an object that defines the property "type"
at instance location ""
at evaluate path "/required"
./hayagriva.schema.json:
Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)
at schema location "/definitions/roleType"
./hayagriva.schema.json:
Only include instances in the `examples` array that validate against the schema (blaze/valid_examples)
at schema location "/definitions/serialNumber/oneOf/1"
Invalid example instance at index 0
The value was expected to be of type object but it was of type string
at instance location ""
at evaluate path "/type"
./hayagriva.schema.json:
Only include instances in the `examples` array that validate against the schema (blaze/valid_examples)
at schema location "/definitions/url/oneOf/1"
Invalid example instance at index 0
The value was expected to be an object that defines the property "value"
at instance location ""
at evaluate path "/required"It's arguably not super important, because
But I'm still posting the linter output here in case you find it useful. |
there are some inconsistencies with the official docs that have been commented in the schema. specially against typst
|
Some updates with the schema and also support for the new chapter field. In any case the YAML version is available in my repository: https://github.com/jassielof/json-schemas/blob/main/docs/hayagriva.yaml For testing the schema in your Hayagriva YAML, at least with Red Hat's YAML extension in VS Code one can add the following line atop of the file: or using VS Code settings: "yaml.schemas": {
// Replace this with the URL from above
"https://jassielof.github.io/json-schemas/docs/hayagriva.schema.json": [
// These for automatic file association to the given schema, these should work for bib.hay, bib.haya, bibliograhy.hay.yml, and such. An official extension by Hayagriva would be good to have as a side note.
"**/*.{hay,haya,hayagriva}",
"**/*.{hay,haya,hayagriva}.{yml,yaml}" // Only these will work, since Typst requires the bibliography to have a YAML extension
]
},
Feedback is highly appreciated, so for any issues, please comment them here so I can solve them. A related issue to the comments is: #346. The schemas (both this and for |
Co-author: @jassielof
I took a pass at creating a JSON schema based on the Hayagriva specification. This will likely close #33!
Please provide any and all feedback! This is my first time creating a JSON schema.
This PR might be related to issue #134.
Outstanding Items (copied from below for convenience)
tests/schema.rscompliant with the package's architecture?titlefield still accept atranslatorsub-field (see: Create JSON Schema for YAML File #192 (comment))?