Skip to content
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

Create JSON Schema for YAML File #192

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

Create JSON Schema for YAML File #192

wants to merge 45 commits into from

Conversation

mkdjr
Copy link
Contributor

@mkdjr mkdjr commented Jul 29, 2024

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)

@EpicEricEE
Copy link

The specification is not fully up to date as the fields added in #102 (abstract, annote and genre) aren't included and are thus also missing here.

@mkdjr
Copy link
Contributor Author

mkdjr commented Aug 2, 2024

The specification is not fully up to date as the fields added in #102 (abstract, annote and genre) aren't included and are thus also missing here.

Thanks for pointing this out! I added them to the schema and started a PR to add them to the documentation (#194).

Copy link
Member

@reknih reknih left a 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.

Comment on lines 76 to 82
"title": {
"type": "string",
"description": "The title of the item.",
"examples": [
"Rick Astley: How An Internet Joke Revived My Career"
]
},
Copy link
Member

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, short

Copy link
Contributor Author

@mkdjr mkdjr Feb 24, 2025

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.

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?

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.

@Freed-Wu
Copy link

Freed-Wu commented Jan 25, 2025

And remember upload it to schemastore 😄

@jassielof
Copy link

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?

@PgBiel
Copy link
Contributor

PgBiel commented Feb 20, 2025

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.

@mkdjr
Copy link
Contributor Author

mkdjr commented Feb 24, 2025

Finally got back around to working on this! There are three is one things on my mind right now w.r.t. improving the schema so that it can be published.

Person Fields

Do all fields referring to individuals (author, editor, affiliated) have the same subfields (name, given-name, prefix, suffix, alias)?

If so, I can reference a common subschema for fields of this type.

2025-02-24: Addressed by @jassielof's improvements to the schema.

Affiliated Roles

After working on making the values of the type field case insensitive, I realized that the role field for affiliated individuals may also need to be case insensitive.

Is this the case?

2025-02-24: Addressed by @jassielof's improvements to the schema.

Tests

I added tests for validating the schema itself, as well as validating basic.yml. I put the tests under tests/schema.rs and added jsonschema as a development dependency in cargo.toml.

Let me know if any of that should be changed to comply with the package's architecture.

jassielof and others added 18 commits February 24, 2025 17:11
…-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.
gwennlbh added a commit to gwennlbh/shapemaker that referenced this pull request Mar 22, 2025
@gwennlbh
Copy link

We should probably also mention # yaml-language-server: $schema=... and include it in the examples.

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)

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.

JSONschema for bibliography file
7 participants