@Sgs and @Urbanecm_WMF discussed the T358799: CommunityConfiguration: Switch to generating schemas from PHP classes rather than committing them as JSON files directly patches during the synchronous code review meeting. Within that task, we're shifting from storing JSON schemas as JSON files on the disk to representing JSON schemas as PHP classes. This means we'll be supporting a certain subset of the JSON Schema standard, as defined us (this is to make the schemas more predictable, and done as a response to feedback from MediaWiki team's Principal Engineers).
It is questionable whether we need to mark top-level keys in the JSON schema as required. On one hand, it might make sense to ensure a given feature is actually configured within CommunityConfiguration. On the other hand, there are a couple of arguments against declaring fields as required:
- We're unable to guarantee configuration will be always available (the store might be temporarily unavailable for an outage, or it might be corrupted and present invalid value, etc.), so client extensions will need to handle missing configuration, even for fields marked as required (in other words, we always provide either valid configuration or nothing at all, but we're unable to guarantee we'll always return a valid configuration). This decreases the usefulness of declaring something as required.
- Upon deployment, configuration pages will not exist. Those non-existing pages will be likely unable to provide any values marked as required. Same applies for schema changes, although that could be handleable by a migration logic.
@Sgs also raised the question of declaring fields as required for objects that are not at the top-level. While the arguments in the list above are partially valid as well, their validity is somewhat limited (we might still find ourself unable to provide any community configuration, but that would also make the top-level key unavailable as well). For that reason, we might want to behave differently for top-level and non-top level keys.
Within this task, we should decide on the right approach towards the required keys and if needed, fill in new tasks to implement any changes of behaviour.