Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 121 additions & 3 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3304,7 +3304,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Toolkit'
$ref: '#/components/schemas/ToolkitWithItems'
"401":
$ref: '#/components/responses/Unauthorized'
"404":
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -3381,7 +3452,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Toolkit'
$ref: '#/components/schemas/ToolkitWithItems'
"401":
$ref: '#/components/responses/Unauthorized'
"403":
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 23 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: <code>toolkit_number</code>, <code>thumbnail_image_url</code>, <code>cover_image_url</code>, <code>cover_image_alt</code>, <code>darken_thumbnail_image</code>, <code>darken_cover_image</code> and its page <code>url</code>" },
{ code: "200", cls: "response-2xx", desc: "The Toolkit: <code>toolkit_number</code>, <code>thumbnail_image_url</code>, <code>cover_image_url</code>, <code>cover_image_alt</code>, <code>darken_thumbnail_image</code>, <code>darken_cover_image</code>, its page <code>url</code>, and its <code>checklist_templates</code> and <code>story_labels</code> (each <code>{id, name}</code>)" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" }
])}
Expand Down Expand Up @@ -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: "<code>{errors: [...]}</code>, e.g. an unknown <code>kind</code> or a file that isn't an image" }
], "As <b>Replace</b> 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: "<code>checklist_template</code> or <code>story_label</code>" },
{ name: "item_id", type: "integer", required: true, desc: "The Checklist Template's or story Label's ID" }
], [
{ code: "201", cls: "response-2xx", desc: "<code>{item_type, item_id, name}</code>" },
{ 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: "<code>{errors: [...]}</code>, e.g. an unknown <code>item_type</code>" }
], "As <b>Available Fields</b> 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: "<code>checklist_template</code> or <code>story_label</code>" },
{ 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: "<code>{errors: [...]}</code>, e.g. an unknown <code>item_type</code>" }
])}
</div>
</section>

Expand Down
Loading