diff --git a/openapi.yaml b/openapi.yaml index 952d504..422b0d4 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -690,7 +690,16 @@ paths: post: tags: [Projects] summary: Add users to a Project - description: Grants roles on a Project. A user can hold Editor, Reporter, and Observer simultaneously. + description: | + Adds users to Projects' teams, as the Project's **Add Users** page does: as Project Managers (`editor_ids`), + Changemakers (`reporter_ids`) or Analysts (`observer_ids`). A user can hold more than one role. + + You must be a Project Manager of every listed Project, or an Organisation Admin of its Organisation. The users + must already be colleagues in the Project's Organisation, unless the Organisation's preference "Allow Project + Managers to add Makerble Users outside the organisation to their project" is on. + + The request is all or nothing: if any Project isn't found (404), isn't yours to manage (403) or any user can't + be added (422), nobody is added to any Project. operationId: addColleague security: [{tokenAuth: []}] requestBody: @@ -730,6 +739,10 @@ paths: description: Users added "401": $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/AddColleagueForbidden' + "404": + $ref: '#/components/responses/NotFound' "422": $ref: '#/components/responses/UnprocessableEntity' @@ -7706,6 +7719,14 @@ components: example: success: false errors: "Permission denied." + AddColleagueForbidden: + description: You aren't a Project Manager of one of the listed Projects or an Organisation Admin of its Organisation. Nobody is added to any of them. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + error: "You don't have permission to add users to project 619." UnprocessableEntity: description: Validation failed content: diff --git a/server.js b/server.js index 982aae9..4b6db9f 100644 --- a/server.js +++ b/server.js @@ -1176,8 +1176,10 @@ function buildDocsPage() { ${endpointCard("POST", "/projects/add_colleague.json", "Add users to a Project", true, [], [ { code: "200", cls: "response-2xx", desc: "Users added successfully" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" }, - { code: "422", cls: "response-4xx", desc: "Validation failed" } - ], "Grant one or more users a role on a Project. A user can hold Editor, Reporter, and Observer simultaneously. Pass user IDs in role_data[].editor_ids, reporter_ids, or observer_ids.")} + { code: "403", cls: "response-4xx", desc: "Not a Project Manager of one of the Projects or an Organisation Admin of its Organisation (e.g. a Changemaker)" }, + { code: "404", cls: "response-4xx", desc: "A Project wasn't found" }, + { code: "422", cls: "response-4xx", desc: "A user can't be added: not a colleague in the Project's Organisation" } + ], "Adds users to Projects' teams, as the Project's Add Users page does: as Project Managers (role_data[].editor_ids), Changemakers (reporter_ids) or Analysts (observer_ids). A user can hold more than one role. You must be a Project Manager of every listed Project or an Organisation Admin of its Organisation, and the users must already be colleagues in that Organisation unless its preference lets Project Managers add users from outside it. It's all or nothing: on any error nobody is added.")} ${endpointCard("GET", "/project_results", "Get Results Canvas figures for Projects", true, [ { name: "project_ids", type: "integer[]", required: false, desc: "Projects to include, as project_ids[]=619 or a JSON array string. Defaults to every Project you can view" }, { name: "start_date", type: "string", required: false, desc: "First Story date to include, YYYY-MM-DD. Omit both dates for all time" },