Add JSON schema for Development Container Template Metadata#350
Add JSON schema for Development Container Template Metadata#350benblank wants to merge 3 commits intodevcontainers:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
| }, | ||
| "required": [ | ||
| "id", | ||
| "name", |
There was a problem hiding this comment.
Is name required? It might be, but we don't have it written down it seems. It is optional for features.
There was a problem hiding this comment.
Hmm. It isn't marked as required in devContainerFeature.schema.json now that I look at it, but it is on the implementors page. I'm not yet familiar enough with the spec to know which is accurate, but I suppose the other should be updated to match. 🙂
There was a problem hiding this comment.
@joshspicer Should we make name required in the features schema? Would a feature work if it had no name currently? If not, we would know that making it required in the schema won't break anyone. :)
There was a problem hiding this comment.
In the tooling name is not required. For example when we build the READMEs in devcontainers/action it will use id if name is not available.
That said, we should probably just make it required since it's useful as a display name in our tooling and it's provided by default in our devcontainers/feature-starter template.
One thing to note - if we add name as required in the schema for Features, this validation code when publishing with the devcontainers/action will fail if the Feature is missing name.
There was a problem hiding this comment.
It seems safer to update the spec to make it optional then. We could break existing features as you point out.
One advantage of not making it required is that it is easier to write one-off features for prototyping or testing. We would still want features going into the index to have good names for the UI. 🤷♂️
chrmarti
left a comment
There was a problem hiding this comment.
Thanks for the PR! Looks great overall, I have left a few comments for consideration / discussion.
We should then also update https://github.com/devcontainers/action to use this schema similarly to how it uses the schema for features.
We could add the features and templates schemas to VS Code like we do for the main schema here: https://github.com/microsoft/vscode/blob/75b1639461b53dc51380a61532aabdd502c4c718/extensions/configuration-editing/package.json#L142
|
El jue., 21 de diciembre de 2023 1:47 p. m., Ben Blank <
***@***.***> escribió:
… ***@***.**** commented on this pull request.
------------------------------
In schemas/devContainerTemplate.schema.json
<#350 (comment)>:
> @@ -0,0 +1,182 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "Development Container Template Metadata",
+ "description": "Development Container Template Metadata (devcontainer-template.json). See https://containers.dev/implementors/templates/ for more information.",
+ "definitions": {
+ "Template": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "$schema": {
I just pushed a new commit to the PR which adds this.
—
Reply to this email directly, view it on GitHub
<#350 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A65ALOP2JMICH4CDYRD6QGDYKSG6NAVCNFSM6AAAAABAUKUTBCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOOJTGU3TAOBWGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
- The schema for features has been updated to use "oneOf" semantics instead of "anyOf" semantics for option types. (This should have no practical effect, but clarifies intent.) - For templates, the schema no longer requires a string option to have "proposals" when "enum" is absent. (This matches the behavior of the features schema.)
| "type": "object" | ||
| }, | ||
| "FeatureOption": { | ||
| "anyOf": [ |
I've made an attempt at creating the JSON schema for Template metadata which I requested in #349.
Some notes:
devContainerFeature.schema.json, on the theory that Template metadata has more in common with Feature metadata than it does Development Container metadata.id,name, andversionare required for Feature metadata, I've assumed those same three properties are required for Template metadata.enumandproposals; see the points below).defaultproperty may only be a string, I've assumed that it should instead be a boolean when thetypeproperty is"boolean".enumandproposalsproperties of options:enumnorproposalsare relevant to boolean options, so have forbidden them.enumcannot be an empty array, on the theory that because free-form values are not allowed, it would make it impossible to set a valid value for that option.proposals, as free-form values are allowed.Apologies for the verbose description; I'm only getting started with Development Containers and want to make sure that any mistakes I've made are easy to spot. 😅