feat(data): create a schema for definitions#93
feat(data): create a schema for definitions#93johnlettman wants to merge 8 commits intoOpenPrintTag:mainfrom
Conversation
CZDanol
left a comment
There was a problem hiding this comment.
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.
data/schema/config.yaml
Outdated
| # 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]+)*$" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
You mean "application/vnd.openprinttag" strictly and no sub-vendoring stuff, correct?
There was a problem hiding this comment.
(potentially) Fixed in johnlettman@7067d2a
(squashed)
No worries at all.
Will fix all, thank you! |
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 OpenPrintTag#93 (comment) fix(schema): use "Identifier" verbiage for `key` across schemas Fix for OpenPrintTag#93 (comment) fix(schema): drop `required: required` from `fields` Fix for OpenPrintTag#93 (comment)
7067d2a to
6fa48cc
Compare
|
Rebasing to resolve conflicts. |
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.
BFW-8077
BFW-8092
Authored by MartinPoupa, I've just tweaked the wording a little. BFW-8092 Co-Authored-By: MartinPoupa <58166333+MartinPoupa@users.noreply.github.com>
This PR creates several schemas covering all definition YAML files in the OpenPrintTag standard.
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_namewith lowercase characters and underscores separating each word. A simple regular expression ensures a stand-out, such asMyTAG--NAMEwould 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-commitcan 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 usesgenerate.pyto insert the schemas intodocs, which appear to push tospecs.openprinttag.org:https://github.com/prusa3d/OpenPrintTag/blob/7db85ec0fdf7b8a6910366ddbd0bd23941bb84f1/docs_src/generate.py#L90-L91
In each
datadefinition, theyaml-language-serverused 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.