diff --git a/openapi.yaml b/openapi.yaml index ed96eb2..264ff32 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3304,7 +3304,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Toolkit' + $ref: '#/components/schemas/ToolkitWithItems' "401": $ref: '#/components/responses/Unauthorized' "404": @@ -3338,7 +3338,78 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Toolkit' + $ref: '#/components/schemas/ToolkitWithItems' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/ForbiddenError' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + + /toolkits/{id}/items: + post: + tags: [Toolkits] + summary: Add a Checklist Template or story Label to a Toolkit + description: | + Adds one of your organisation's Checklist Templates, or a story Label, to a Toolkit, as + Available Fields does on the Create/Edit Collection page. Inside a Toolkit, a checklist step + can then count the Toolkit's own Surveys, Contact Forms and story Labels as done, so those steps + arrive already set up when the Toolkit is installed. The user must be able to edit the + Toolkit, and the item must belong to one of their organisations (a story Label may also be + their own). Adding an item the Toolkit already has changes nothing. + operationId: addToolkitItem + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/ResourceId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToolkitItemRequest' + example: + item_type: checklist_template + item_id: 42 + responses: + "201": + description: The item, now in the Toolkit + content: + application/json: + schema: + $ref: '#/components/schemas/ToolkitItem' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/ForbiddenError' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + + delete: + tags: [Toolkits] + summary: Take a Checklist Template or story Label out of a Toolkit + description: | + Takes a Checklist Template or story Label out of a Toolkit. The item itself stays as it is. The + user must be able to edit the Toolkit. + operationId: removeToolkitItem + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/ResourceId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToolkitItemRequest' + example: + item_type: story_label + item_id: 7 + responses: + "204": + description: Taken out of the Toolkit "401": $ref: '#/components/responses/Unauthorized' "403": @@ -3381,7 +3452,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Toolkit' + $ref: '#/components/schemas/ToolkitWithItems' "401": $ref: '#/components/responses/Unauthorized' "403": @@ -25810,6 +25881,53 @@ components: type: string format: date-time + ToolkitWithItems: + description: One Toolkit, with its Checklist Templates and story Labels + allOf: + - $ref: '#/components/schemas/Toolkit' + - type: object + properties: + checklist_templates: + type: array + description: The Toolkit's Checklist Templates, by name + items: + $ref: '#/components/schemas/ToolkitItemName' + story_labels: + type: array + description: The Toolkit's story Labels (Labels in the database), by name + items: + $ref: '#/components/schemas/ToolkitItemName' + + ToolkitItemName: + type: object + properties: + id: + type: integer + name: + type: string + + ToolkitItemRequest: + type: object + required: [item_type, item_id] + properties: + item_type: + type: string + enum: [checklist_template, story_label] + description: A Checklist Template, or a story Label (Label in the database) + item_id: + type: integer + + ToolkitItem: + type: object + properties: + item_type: + type: string + enum: [checklist_template, story_label] + item_id: + type: integer + name: + type: string + ToolkitList: type: object properties: diff --git a/server.js b/server.js index 31a4c76..aeb713a 100644 --- a/server.js +++ b/server.js @@ -1509,7 +1509,7 @@ function buildDocsPage() { ${endpointCard("GET", "/toolkits/{id}", "Get a Toolkit", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" } ], [ - { code: "200", cls: "response-2xx", desc: "The Toolkit: toolkit_number, thumbnail_image_url, cover_image_url, cover_image_alt, darken_thumbnail_image, darken_cover_image and its page url" }, + { code: "200", cls: "response-2xx", desc: "The Toolkit: toolkit_number, thumbnail_image_url, cover_image_url, cover_image_alt, darken_thumbnail_image, darken_cover_image, its page url, and its checklist_templates and story_labels (each {id, name})" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" } ])} @@ -1537,6 +1537,28 @@ function buildDocsPage() { { code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" }, { code: "422", cls: "response-4xx", desc: "{errors: [...]}, e.g. an unknown kind or a file that isn't an image" } ], "As Replace does on Site Overview › Manage Toolkits.")} + ${endpointCard("POST", "/toolkits/{id}/items", "Add a Checklist Template or story Label to a Toolkit", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" }, + { name: "item_type", type: "string", required: true, desc: "checklist_template or story_label" }, + { name: "item_id", type: "integer", required: true, desc: "The Checklist Template's or story Label's ID" } + ], [ + { code: "201", cls: "response-2xx", desc: "{item_type, item_id, name}" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "You can see the Toolkit but not edit it" }, + { code: "404", cls: "response-4xx", desc: "Not found: the Toolkit, or an item that isn't one of your organisations'" }, + { code: "422", cls: "response-4xx", desc: "{errors: [...]}, e.g. an unknown item_type" } + ], "As Available Fields does on the Create/Edit Collection page. A Checklist Template's steps can then count the Toolkit's own Surveys, Contact Forms and story Labels as done, so they arrive already set up when the Toolkit is installed. Adding an item the Toolkit already has changes nothing.")} + ${endpointCard("DELETE", "/toolkits/{id}/items", "Take a Checklist Template or story Label out of a Toolkit", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" }, + { name: "item_type", type: "string", required: true, desc: "checklist_template or story_label" }, + { name: "item_id", type: "integer", required: true, desc: "The Checklist Template's or story Label's ID" } + ], [ + { code: "204", cls: "response-2xx", desc: "Taken out; the item itself stays" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "You can see the Toolkit but not edit it" }, + { code: "404", cls: "response-4xx", desc: "Not found, or the Toolkit doesn't have that item" }, + { code: "422", cls: "response-4xx", desc: "{errors: [...]}, e.g. an unknown item_type" } + ])}