API Fields
The built-in field tag — hand-authored API parameter and response-field rows for references that aren't driven by an OpenAPI spec. One tag renders a labeled row: the field name, its type, required/deprecated badges, an optional default, an optional request-location badge, and a Markdown description. Usage, options, and live examples.
A built-in tag for documenting an API by hand — when there is no OpenAPI spec
driving the page. {% field %} renders one labeled row: the field
name (monospace), its type, required / deprecated badges, an optional
default, an optional location badge (query / path / body / header / cookie), and a
Markdown description written as the block body.
One tag covers both request parameters and response fields, because the two render
identically. The only request-only affordance is the location badge — and a response
field, being just a key in the returned payload, simply omits it.
This is for prose you write yourself. If you already have an OpenAPI spec, reach for
OpenAPI instead — it renders parameter and response
tables straight from the spec, with a “Try it now” form. field is the spec-free
counterpart: drop one row at a time into a guide.
Use it as {% field %} in Markdown, or call it from Python logic
(loops, snippets) via component('aardvark', 'field', …).
What location means
location is the one attribute that makes a row a request parameter. It answers the
question a name and a type can’t: where does this value go in the HTTP request?
location |
Where the value rides | Example |
|---|---|---|
query |
The URL query string | GET /pets?limit=20 |
path |
A URL path segment | GET /pets/{petId} |
header |
A request header | X-Api-Version: 2 |
cookie |
The Cookie header |
Cookie: session=abc |
body |
The request body | {"limit": 20} |
It is the hand-authored mirror of OpenAPI’s in field: a field with location="query"
renders exactly what {% openapi %} shows for in: query. A
response field has no request location, so you just leave location off.
Request parameters
{% field %} takes the field name (the only required attribute),
an optional type, the required and deprecated flags, an optional default, and an
optional location. The block body is the description — full Markdown. Close it with
{% endField %}.
The search term to match against. Case-insensitive; supports AND / OR operators.
querystringThe search term to match against. Case-insensitive; supports AND / OR operators.
Maximum number of results to return. Must be between 1 and 100.
limitinteger20Maximum number of results to return. Must be between 1 and 100.
The unique identifier of the pet, from a prior list response.
petIdstringThe unique identifier of the pet, from a prior list response.
Pins the request to a legacy API version. Deprecated — omit it to use the current version.
X-Api-VersionstringPins the request to a legacy API version. Deprecated — omit it to use the current version.
{% field name="query" type="string" required=true location="query" %}
The search term to match against. Case-insensitive; supports `AND` / `OR` operators.
{% endField %}
{% field name="limit" type="integer" default="20" location="query" %}
Maximum number of results to return. Must be between **1** and **100**.
{% endField %}
{% field name="petId" type="string" required=true location="path" %}
The unique identifier of the pet, from a prior list response.
{% endField %}
{% field name="X-Api-Version" type="string" deprecated=true location="header" %}
Pins the request to a legacy API version. **Deprecated** — omit it to use the current version.
{% endField %}
component('aardvark', 'field', name='query', type='string',
required=True, location='query',
children='The search term to match against. Case-insensitive.')
component('aardvark', 'field', name='limit', type='integer',
default='20', location='query',
children='Maximum number of results to return. Must be between **1** and **100**.')
Response fields
A response field is the same tag with no location — there is nowhere in a request
for it to go. Everything else works identically.
The unique identifier for the object, prefixed with its type (e.g. pet_8xKq…).
idstringThe unique identifier for the object, prefixed with its type (e.g. pet_8xKq…).
The type of object. Always pet for this endpoint.
objectstringThe type of object. Always pet for this endpoint.
The labels attached to this pet. Each entry has an id and a name.
tagsarraydefault: []The labels attached to this pet. Each entry has an id and a name.
The old numeric status code. Deprecated in favor of the string status field.
legacyStatusintegerThe old numeric status code. Deprecated in favor of the string status field.
{% field name="id" type="string" required=true %}
The unique identifier for the object, prefixed with its type (e.g. `pet_8xKq…`).
{% endField %}
{% field name="object" type="string" required=true %}
The type of object. Always **`pet`** for this endpoint.
{% endField %}
{% field name="tags" type="array" default="[]" %}
The labels attached to this pet. Each entry has an `id` and a `name`.
{% endField %}
{% field name="legacyStatus" type="integer" deprecated=true %}
The old numeric status code. **Deprecated** in favor of the string `status` field.
{% endField %}
component('aardvark', 'field', name='id', type='string', required=True,
children='The unique identifier for the object.')
component('aardvark', 'field', name='tags', type='array', default='[]',
children='The labels attached to this pet. Each entry has an `id` and a `name`.')
Request vs response fields
One tag serves both. A request parameter carries a location (query, path, body,
header, or cookie — OpenAPI’s in, where the value rides in the request); a response
field is just a key in the returned payload, so it omits location and shows no location
badge. Nothing else differs — the two render identically.
{% field name="petId" type="integer" required=true location="path" %}
A request parameter — the `location` badge marks where it rides.
{% endField %}
{% field name="id" type="string" %}
A response field — no location, no badge.
{% endField %}
Rich descriptions
The body is full Markdown, so a field description can hold emphasis, links, inline code, and lists — handy for enumerating allowed values or nested shapes:
The lifecycle state of the pet. One of:
available— ready to be adopted.pending— an adoption is in progress.sold— no longer available.
See the status guide for the full state machine.
statusstringThe lifecycle state of the pet. One of:
available— ready to be adopted.pending— an adoption is in progress.sold— no longer available.
See the status guide for the full state machine.
{% field name="status" type="string" required=true %}
The lifecycle state of the pet. One of:
- `available` — ready to be adopted.
- `pending` — an adoption is in progress.
- `sold` — no longer available.
See the status guide for the full state machine.
{% endField %}
Attributes
| Attribute | Valid values | Description |
|---|---|---|
name |
Any string (required) | The field name, shown in monospace. The row’s anchor. |
type |
Any string | The field’s type (string, integer, array, …), shown as dimmed mono text. |
required |
true / false (default) |
Shows a required badge when true. |
deprecated |
true / false (default) |
Shows a deprecated badge when true. |
default |
Any string | Shows default: <value> after the badges. |
location |
query, path, body, header, cookie (or any string) |
A color-coded badge showing where the parameter is sent in the request. Omit it for a response field. |
attr |
{…} |
Raw HTML attributes forwarded onto the rendered field row (see below). |
| (body) | Markdown | The description, written between the open and close tags (children= from Python). |
CSS Selectors
Every row renders the same ApiField island, so one wrapper class targets them all.
[data-aardvark-island="ApiField"] {
/* style every field row on the page */
}
[data-aardvark-island="ApiField"] .aardvark-api-field-name {
/* the monospace field name */
}
[data-aardvark-island="ApiField"] .aardvark-api-field-body {
/* the Markdown description */
}
Injecting Attributes
attr={…} forwards raw HTML attributes (including an id for deep-linking) straight
onto the rendered field row.
Your secret API key. This row carries id="field-api-key" so you can link straight to it.
apiKeystringYour secret API key. This row carries id="field-api-key" so you can link straight to it.
{% field name="apiKey" type="string" required=true location="header" attr={'id': 'field-api-key'} %}
Your secret API key. This row carries `id="field-api-key"` so you can link straight to it.
{% endField %}
component('aardvark', 'field', name='apiKey', type='string', required=True,
location='header', children='Your secret API key.',
attr={'id': 'field-api-key'})