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

JSON schema: improve non-storage parts #1437

Merged
merged 6 commits into from
Jul 19, 2024
Merged

JSON schema: improve non-storage parts #1437

merged 6 commits into from
Jul 19, 2024

Conversation

mvidner
Copy link
Contributor

@mvidner mvidner commented Jul 4, 2024

Problem

While reviewing #1263 I read the whole schema and saw room for improvement. Small things

Solution

  • disallow additional properties
  • more specific type than string

Testing

Minimal, just making sure the schema itself is valid, by

$ agama profile validate rust/agama-lib/share/examples/profile_gnome.json
The profile is valid

}
}
}
},
"user": {
"title": "First user settings",
"type": "object",
"additionalProperties": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

feature request: I am surprised that we don't allow hashed passwords in the profile

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you are right, that's something we need to implement. I have created a placeholder card in Trello.

@coveralls
Copy link

Coverage Status

coverage: 71.408%. remained the same
when pulling 945c670 on schema-nonstorage
into 7101d0d on master.

@coveralls
Copy link

Coverage Status

coverage: 71.408%. remained the same
when pulling 945c670 on schema-nonstorage
into 7101d0d on master.

@@ -576,7 +605,8 @@
"sizeString": {
"title": "Human readable size (e.g., '2 GiB')",
"type": "string",
"pattern": "^[0-9]+(\\.[0-9]+)?(\\s*([KkMmGgTtPpEeZzYy][iI]?)?[Bb])?$"
"pattern": "^[0-9]+(\\.[0-9]+)?(\\s*([KkMmGgTtPpEeZzYy][iI]?)?[Bb])?$",
"examples": ["2 GiB", "1.5 TB", "1TIB", "1073741824 b", "1073741824"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, here the examples feature really shines because it provides an alternative to the dense regexp

Unfortunately, agama profile validate does not check whether the schema is internally consistent and uses only valid examples. Like, I could use a number here and it would not notice.

@@ -117,7 +129,8 @@
"type": "string"
},
"security": {
"type": "string"
"type": "string",
"examples": ["? maybe this is actually an enum"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXME, need to look up in the code what is valid here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

otherwise npm run fails after the requirements change and we keep working with
an outdated environment: "Cannot find module react-refresh-typescript"
Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

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

I did not know about the examples element. Thanks!

}
}
}
},
"user": {
"title": "First user settings",
"type": "object",
"additionalProperties": false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you are right, that's something we need to implement. I have created a placeholder card in Trello.

"type": "string"
"title": "System language ID",
"type": "string",
"examples": ["en_US"]
Copy link
Contributor

Choose a reason for hiding this comment

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

We support specifying the whole locale (en_US.UTF-8). If no encoding is given (e.g., en_US), we fall back to UTF-8.

@mvidner mvidner merged commit 6321fe0 into master Jul 19, 2024
2 checks passed
@mvidner mvidner deleted the schema-nonstorage branch July 19, 2024 09:37
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
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.

4 participants