-
Notifications
You must be signed in to change notification settings - Fork 8
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
Generate JSON schema #63
Conversation
Fix some style issues in our Sphinx extension, as reported by flake8.
Add directives to our custom-domain extension to declare objects and attributes, and use these to specify the schema. In addition to providing a slightly more structured way to specify attribute parameters, this also makes it possible to create a data model of the schema which we will eventually use to generate a JSON schema that can be used to partially validate CPS JSON.
Note: I think the generated schema is okay, and Python |
Could you add the default version to the schema and ideally the example values? |
Currently the description of the platform attribute is duplicated and as a result the longer description is ignored. The format of the website should be
Nitpick, but can you arrange the properties in a meaningful order? Can you commit the schema? |
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.
No objections. I'm OK with merging this.
It would be handy to publish the schema somewhere... either in the docs somehow or maybe as a GitHub release.
The machinery of generating that schema is probably less interesting than the output itself.
Eventually, it would be nice to see how the schema differs between the base and head commits of a PR to confirm that we're matching roughly semver expectations with respect to the CPS version number, but let's not let perfect be the enemy of the good, etc.
@autoantwort, thanks for the feedback! (Also, sorry about the delay in replying.) I'm not following you here, though; are you talking about That said, I may punt on this (and other changes) in the interest of making progress. It will be beneficial to have something even if it's not perfect, but we can and should continue to make refinements.
What is "meaningful"? Right now they are in the order "core", "supplemental", with each of those in lexicographical order. It should be straight-forward to remove the core/supplemental split and have purely lexicographical order, but anything else is difficult to specify and maintain. Anyway, the intent is that the schema is not the canonical source of truth, but a useful tool mostly targeting automated uses.
Do you mean this? --- a/cps.schema.json
+++ b/cps.schema.json
@@ -488,6 +488,7 @@
},
"website@0": {
"description": "Specifies the URI at which the package's website may be found.",
+ "format": "uri",
"$ref": "#/definitions/types/string"
}
} (Note: I ran the generated schema through
I'd rather not; checking in generated files is generally undesirable, and I don't see how it's especially helpful when, once this lands, the schema will be available via the published pages. I'd really prefer to avoid the added workflow pain of trying to keep a generated-but-checked-in file up to date. If you just want to know what it looks like without having to generate it yourself, see https://github.com/cps-org/cps/files/15203794/cps.schema.json. Once/if this lands, it'll be accessible via the published Pages (see also reply to Bret, below).
Once this lands, it should be accessible from the same location as the rest of the published Pages. Adding a link should be done, but that can be a follow-up.
That's... technically do-able. Generating a diff from GHA should be easy if we can use the published copy as the comparison target. (Otherwise we need a second build, which is somewhat annoying.) Presenting said diff in a useful way might be challenging. (I agree we shouldn't do that in this PR, especially as I'd prefer to use the published copy as the "original", which means generation has to land before comparison can be tested.) |
Sorry that was unclear. I mean the default value of a field. For example here (
I still want/prefer the generated documentation (in addition) to the current form. But I can add this in a following PR.
Yes
Imo yes. It is a benefit if you can directly read the file if you have to (Ideally you never have, but...).
This is also ok. I only want a way so that I can provide the
If you commit the schema you don't have the problem. And I guess you have to run the generator anyway to get the schema for the website. So adding a |
Using the structured information extracted from the documentation (see previous commit), build and write a JSON schema. This also introduces a new utility library to convert build the schema description from the set of objects and attributes.
586a175
to
b2e7671
Compare
Okay, since Bret already 👍'd this, I'm going to merge it as-is (with one tiny tweak; see below) so follow-ups are easier to review. @autoantwort, I may not be able to get
Makes sense. The generated schema already has an
Perhaps, but I still don't think it's worth making it more complicated to make changes.
Sure; in fact, I had this in the back of my head as a follow-up already. However, please make it part of |
Add machinery to generate a JSON schema from the documentation. The schema can be used to validate CPS JSON.
As a side benefit to changing how attributes are declared to be more machine-readable, it is also slightly easier to specify common properties of an attribute.
Supersedes #25. Unlike that proposal, this retains reST (with only modest changes aside from all descriptions gaining a level of indent) as the source of truth, so does not introduce new errors and retains superior editability. It should also be somewhat more robust, as there is less human-written textual duplication.