Repository navigation
docs: introduce REST API project pages #1752
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| title: REST API Conversion | ||
| tags: | ||
| - Project | ||
| - REST | ||
| - Users | ||
| --- | ||
|
|
||
| import { ProjectSummary } from '@site/src'; | ||
|
|
||
| {/* <!-- cspell:ignore restapi --> */} | ||
|
|
||
| <ProjectSummary | ||
| projectName="restapi" | ||
| /> | ||
|
|
||
| Moodle's existing web-service system is aging, and has several limitations which make it harder than necessary to use. These mostly revolve around different ways in which it does not follow established protocols, but extend more generally to the shape and nature of REST endpoints, and lack of modern authentication such as OAuth2. | ||
|
|
||
| The foundations to deliver a new REST API have been underway for some time with most parts of that foundation now complete, including Moodle's new Routing system, support for automatic OpenAPI specification generation, OAuth2 and Personal Access Token authentication, and OAuth2 scoping. | ||
|
|
||
| The new REST API is intended to replace the legacy Web Service system gradually, with endpoints added over time rather than promising one-to-one parity. | ||
|
|
||
| User management is the first reference implementation ([MDL-90030](https://tracker.moodle.org/browse/MDL-90030)), with other core services expected to follow including Course, Cohort, Calendar, Messaging, and other core systems, before expanding out to include all Moodle plugins. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: User Endpoints | ||
| tags: | ||
| - Project | ||
| - REST | ||
| - Users | ||
| --- | ||
|
|
||
| import { ProjectSummary } from '@site/src'; | ||
|
|
||
| {/* <!-- cspell:ignore restapi --> */} | ||
|
|
||
| <ProjectSummary | ||
| projectName={["restapi", "users"]} | ||
| /> | ||
|
|
||
| This work covers REST endpoints for managing Moodle user accounts, including listing, viewing, creating, updating, and deleting accounts, alongside password changes and recovery. User custom fields are still under analysis and will be added to this specification later. It is part of the [Moodle REST API project](https://tracker.moodle.org/browse/MDL-90030). | ||
|
|
||
| Explore the endpoint schemas in the **User Endpoints** section of the sidebar, or [download the OpenAPI specification](/projects/restapi/users/openapi.json). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Copyright (c) Moodle Pty Ltd. | ||
| * | ||
| * Moodle is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * Moodle is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| import { spawnSync } from 'node:child_process'; | ||
| import { mkdir, readdir } from 'node:fs/promises'; | ||
| import { | ||
| dirname, extname, join, relative, resolve, | ||
| } from 'node:path'; | ||
|
|
||
| const schemaDirectory = resolve('static/schema'); | ||
| const outputDirectory = resolve('src/schema'); | ||
|
|
||
| const findSchemaFiles = async (directory) => { | ||
| const entries = await readdir(directory, { withFileTypes: true }); | ||
| const files = []; | ||
|
|
||
| for (const entry of entries) { | ||
| const path = join(directory, entry.name); | ||
|
|
||
| if (entry.isDirectory()) { | ||
| files.push(...await findSchemaFiles(path)); | ||
| } else if (entry.isFile() && extname(entry.name) === '.json') { | ||
| files.push(path); | ||
| } | ||
| } | ||
|
|
||
| return files; | ||
| }; | ||
|
|
||
| const schemaFiles = (await findSchemaFiles(schemaDirectory)).sort(); | ||
|
|
||
| if (schemaFiles.length === 0) { | ||
| throw new Error(`No JSON schemas found in ${schemaDirectory}`); | ||
| } | ||
|
|
||
| for (const schemaFile of schemaFiles) { | ||
| const outputPath = join( | ||
| outputDirectory, | ||
| relative(schemaDirectory, schemaFile).replace(/\.json$/, '.d.ts'), | ||
| ); | ||
|
|
||
| await mkdir(dirname(outputPath), { recursive: true }); | ||
|
|
||
| const { error, status } = spawnSync('json2ts', [schemaFile, outputPath], { | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| if (error) { | ||
| throw error; | ||
| } | ||
|
|
||
| if (status !== 0) { | ||
| throw new Error(`json2ts failed to generate types for ${schemaFile}`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* eslint-disable */ | ||
| /** | ||
| * This file was automatically generated by json-schema-to-typescript. | ||
| * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
| * and run json-schema-to-typescript to regenerate this file. | ||
| */ | ||
|
|
||
| export interface JSONSchemaForTheMoodleProjectList { | ||
| projects: { | ||
| [k: string]: Project; | ||
| }; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * This interface was referenced by `undefined`'s JSON-Schema definition | ||
| * via the `patternProperty` ".*". | ||
| */ | ||
| export interface Project { | ||
| children?: { | ||
| [k: string]: Project; | ||
| }; | ||
| /** | ||
| * The parent project that this project relates to | ||
| */ | ||
| parentProject?: string; | ||
| title: string; | ||
| /** | ||
| * The current status | ||
| */ | ||
| status: "Pending" | "In Progress" | "Complete" | "Abandoned"; | ||
| owners?: Person[]; | ||
| discussionLinks?: Link[]; | ||
| issueLinks?: Link[]; | ||
| /** | ||
| * Indicates if the project is a collection of sub-projects | ||
| */ | ||
| isCollection?: boolean; | ||
| /** | ||
| * Indicates if the project has an OpenAPI specification | ||
| */ | ||
| hasOpenApi?: boolean; | ||
| } | ||
| export interface Person { | ||
| /** | ||
| * The name of the person | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * The Github username of the person | ||
| */ | ||
| githubUsername?: string; | ||
| } | ||
| export interface Link { | ||
| /** | ||
| * The link | ||
| */ | ||
| link?: string; | ||
| /** | ||
| * A summary title of the content in the link | ||
| */ | ||
| title?: string; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.