mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
28937d4243
Right now we have the information only in docs: - https://docs.moodle.org/dev/Core_APIs - https://moodledev.io/docs/apis And, in fact, we are crawling those pages to get the information from various tools (moodlecheck, CiBoT...). Obviously, that's far from ideal, the source only has the current list of APIs, and there isn't much information there but the names. So we are moving the source of information to be in core, so it can be modified between branches, and contains richer information: - The component the API belongs to, usually a subsystem or core. - If the API can be used as level 2 namespace. - If the API can be used as level 2 namespace out from its component. Note that all that information has NO USES right now in core (and maybe never will), but tools/checkers will benefit enormously by having that information at hand, so we can check for namespaces, categories and other bits way better. Also, once we have this, the APIs dev documents linked above, surely can be improved by being automatically generated and include all the meta-information available. It also includes a very basic json schema validating the basis. It can be tried online @ https://www.jsonschemavalidator.net , or any other tool. PHP requires extra libraries to be able to perform the validation. Covered with unit tests, both api-related functions and structure validation.
31 lines
1.1 KiB
JSON
31 lines
1.1 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://moodle.org/apis.schema.json",
|
|
"title": "APIs",
|
|
"description": "Moodle valid APIs",
|
|
"type": "object",
|
|
"patternProperties": {
|
|
"^[a-z][a-z0-9]+$": {
|
|
"type": "object",
|
|
"properties": {
|
|
"component": {
|
|
"description": "Component the API belongs to, usually a subsystem or core. Null for the 'core' API itself",
|
|
"type": [ "string", "null" ],
|
|
"pattern": "^(core|[a-z][a-z0-9_]+)$"
|
|
},
|
|
"allowedlevel2": {
|
|
"description": "Can the API be used as level 2 namespace",
|
|
"type": "boolean"
|
|
},
|
|
"allowedspread": {
|
|
"description": "Can the API be used out from its own component",
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"minProperties": 3,
|
|
"maxProperties": 3,
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
}
|