Skip to content

Conversation

@johnlettman
Copy link
Contributor

This PR creates several schemas covering all definition YAML files in the OpenPrintTag standard.

image image image image

These schemas can be useful for enforcing standards and criteria for valid information in the definitions, while also instructing editors and IDEs about the valid fields, their contents, and their type information. Further, many editors can use these schemas to provide contextual information for each field -- notably, descriptions and hints.

A small but nice feature is the ability to enforce certain naming schemes. For example, all tags use the format of my_tag_name with lowercase characters and underscores separating each word. A simple regular expression ensures a stand-out, such as MyTAG--NAME would not be considered valid.

Additionally, the schemas formalize the structure of each file. They can serve as a source of truth for what is considered valid and required for a definition.

Lastly, tools such as pre-commit can use these schemas to check whether an addition adheres to the conventions before a commit or within a pull request.


Currently, the schemas are namespaced to https://specs.openprinttag.org/schema/. The PR uses generate.py to insert the schemas into docs, which appear to push to specs.openprinttag.org:

# copy definition schemas
shutil.copytree(os.path.join(vars.data_dir, "schema"), f"{out_dir}/schema")

In each data definition, the yaml-language-server used by most editors and IDEs to perform YAML inspections is configured to use a relative path to reference the schemas. This could theoretically be changed to use the namespace URL; however, since they are packaged with the repository, it seems more sensible to keep them relative.

Copy link
Collaborator

@CZDanol CZDanol left a comment

Choose a reason for hiding this comment

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

I'm sorry, I don't have enough time to do a proper review. The idea sounds good, found some nitpicks on a quick skim.

# this pattern enables vendored and versioned mime types, e.g.,
# - application/vnd.openprinttag.v2
# - application/vnd.openprinttag+cool-feature
pattern: "^application/vnd\\.openprinttag(\\.[a-z0-9]+|\\+[a-z0-9]+)*$"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's restrict this to only application/. Even us (Prusa) are using this format for some other things than just openprinttag ;)

Plus, vnd.openprinttag vendor tree is now registered by us, so it's not something anyone can use for their own spinoffs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean "application/vnd.openprinttag" strictly and no sub-vendoring stuff, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(potentially) Fixed in johnlettman@7067d2a

(squashed)

@johnlettman
Copy link
Contributor Author

I'm sorry, I don't have enough time to do a proper review.

No worries at all.
This is not important or life changing, just a neat little feature if done correctly, and on that topic:

found some nitpicks on a quick skim.

Will fix all, thank you!

johnlettman added a commit to johnlettman/pr-prusa3d-openprinttag that referenced this pull request Nov 18, 2025
johnlettman added a commit to johnlettman/pr-prusa3d-openprinttag that referenced this pull request Nov 18, 2025
johnlettman added a commit to johnlettman/pr-prusa3d-openprinttag that referenced this pull request Nov 18, 2025
This commit creates several schemas covering all definition YAML files in the OpenPrintTag standard.

These schemas can be useful in enforcing certain standards and criteria for valid information in the definitions while also instructing editors and IDEs as to the valid fields, their contents, and their type information. Further, many editors can use these schemas to provide contextual information about each field -- of note, descriptions and hints.

A small, but nice feature, is the ability to enforce certain naming schemes. For example, all tags use the format of `my_tag_name` with lowercase characters an underscores separating each word. A simple regular expression ensures a stand-out, such as `MyTAG--NAME` would not be considered valid.

Additionally, the schemas formalize the structure of each file. They can provide a source of truth as to what is considered valid and required for a definition.

Lastly, tools such as `pre-commit` can use these schemas to check whether an addition fits the conventions prior to a commit or within a pull request.

fix(schema): make `mime_type` const "application/vnd.openprinttag"

Fix for prusa3d#93 (comment)

fix(schema): use "Identifier" verbiage for `key` across schemas

Fix for prusa3d#93 (comment)

fix(schema): drop `required: required` from `fields`

Fix for prusa3d#93 (comment)
@johnlettman
Copy link
Contributor Author

Rebasing to resolve conflicts.

TheDelta and others added 7 commits November 25, 2025 13:28
This commit adds the `color_rgba` type, a simple alias to `bytes` with a `max_length` of 4.

The more explicit use of `color_rgba` as a type can signal to implementing libraries that the data within the field could be interpreted as a color.

This can enable features such as encoding or displaying the color in a different format, performing color operations, and so on.
Maximum allowed value is 320.
Authored by MartinPoupa, I've just tweaked the wording a little.

BFW-8092

Co-Authored-By: MartinPoupa <[email protected]>
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.

3 participants