Previous: Base, mini, standard, and full API resources | Next: Contributing a pull request
Endpoint definitions are located in the content/paths/
folder. Every endpoint
is written as a YAML file.
-
Determine the
operationId
andtag
of theendpoint
. -
Based on those answer, create a file in
content/paths/{tag}__{operationId}.yml
-
Add the default content to the file:
- The
operationId
- A short
title
to give the endpoint a short human-readable name. Please do not usea
,an
, orthe
in the title, and ideally start the title withCreate
,Update
,List
,Get
, orDelete
. - A
description
to further elaborate on the title. - A single tag listed under
tags
, and a reference to the same tag inx-box-tag
. These tags need to match the name and ID of a tags listed incontent/common/tags.yml
. - A list of query, header, or path
parameters
- An optional
requestBody
for anyPOST
orPUT
endpoints. - A list of responses, with at least 1 response in the
2XX
range, and adefault
response that points to aClientError
.
- The
The operationId
is determined as follows:
Steps | |
---|---|
Take the full verb and path of the endpoint. | GET /2.0/files/{file_id}/metadata/{metadata_id} |
Remove the version number. | GET /files/{file_id}/metadata/{metadata_id} |
Replace any variable in the path with id . |
GET /files/id/metadata/id |
Replace any / (except for trailing one) with a _ . |
GET _files_id_metadata_id |
Lower case the verb and append to the path. |
get_files_id_metadata_id |
---
operationId: get_files_id
summary: Get file information
tags:
- Files
x-box-tag: files
description: |-
Retrieves the details about a file.
parameters:
- $ref: '../attributes/file_id.yml'
- $ref: '../attributes/fields.yml'
responses:
200:
description: |-
Returns a file object.
Not all available fields are returned by default. Use the
[fields](#param-fields) query parameter to explicitly request
any specific fields.
content:
application/json:
schema:
$ref: '#/components/schemas/File'
404:
description: |-
Returned if the file is not found, or the user does not
have access to the file.
content:
application/json:
schema:
$ref: '#/components/schemas/ClientError'
default:
description: |-
An unexpected client error.
content:
application/json:
schema:
$ref: '#/components/schemas/ClientError'
Almost every endpoint has a list of parameters
or a requestBody
with a list
of properties
. Please make sure that every parameter or property:
- has a
type
and an optionalformat
, for examplestring
anddate*time
. - has a
description
and a realisticexample
- has an
enum
of values if the returned values are only a limited list
To learn more about the OpenAPI specification and creating endpoints, we recommend reading the following resources.
- OpenAPI Specification 3.0 (OAS3)
- Path objects