Example API
A fictional API included to show what Duvlify renders from an OpenAPI document. It does not exist, and every page in this tab is an example.
Every page in this tab is generated from one file:
src/openapi.config.ts.
The pages carry only the method and path of one operation. The build reads
everything else from the spec: the parameters, the request body, the response
shapes, the response tabs, and the request samples on the right.
To document your own API, replace that file and rewrite these pages. See API reference pages for the procedure.
What this example shows
Query parameters and pagination
An enum, an integer with bounds and a default, and a cursor.
A request body
Required and optional fields, with lengths and defaults.
A path parameter
The simplest shape, plus a 404 response.
The published spec
The same document, served whole for anything writing code.
Authentication
The spec declares one security scheme, and the build shows it on every endpoint page. This example uses a bearer token:
curl https://api.example.com/v1/widgets \
-H "Authorization: Bearer sk_example_..."Errors
Every error in this example returns the same shape. The code is stable, so a
caller branches on it. The message is one sentence for a person, and its
wording can change.
{
"error": {
"code": "widget_not_found",
"message": "No widget with this id exists."
}
}| Status | Meaning |
|---|---|
401 | The API key is missing, malformed or revoked. |
404 | No widget with this id exists. |
422 | A field failed validation. error.field names it. |