Tangly v0.2 ships richer code blocks, page chrome, and more — see what's new

API

ParamField, ResponseField, RequestExample, ResponseExample, OpenApi viewers — for hand-rolled and generated API docs.

~ 4 min read

ComponentUse for
<ParamField>Document a single request parameter (path/query/body/header)
<ResponseField>Document a single response field
<RequestExample>Wrap one or more request snippets
<ResponseExample>Wrap one or more response snippets
<OpenApiEndpoint>Native Tangly viewer for one operation, with try-it-out
<OpenApiRedoc>Embed Redoc for one operation
<OpenApiScalar>Embed Scalar for one operation
<OpenApiStoplight>Embed Stoplight Elements for one operation

If you have an OpenAPI spec, point at it from docs.json (api.openapi) and Tangly auto-generates pages — these components are for manual reference pages or for embedding a single operation in prose.

ParamField

Documents one request parameter. The location flag (path/query/body/header) is mutually exclusive — set exactly one.

PropTypeDefaultDescription
pathstringParam is in the URL path. The string is the param name.
querystringParam is in the query string.
bodystringParam is in the request body.
headerstringParam is in a request header.
typestringType label, e.g. string, integer, string[].
requiredbooleanfalseRenders a “required” badge.
defaultstringDefault value, monospaced.
deprecatedbooleanfalseRenders a “deprecated” badge.
mdx
<ParamField path="userId" type="string" required>
  ID of the user. Always a UUIDv4.
</ParamField>

<ParamField query="limit" type="integer" default="20">
  Page size, max 100.
</ParamField>

<ParamField body="email" type="string" required deprecated>
  Use `contact.email` instead.
</ParamField>
userId string path required

ID of the user. Always a UUIDv4.

limit integer query default: 20

Page size, max 100.

email string body required deprecated

Use contact.email instead.

ResponseField

Documents one response field. Same shape as <ParamField> minus the location flags. Pass name (or any of the location aliases — they all act as the field name).

PropTypeDefaultDescription
namestringField name.
typestringType label.
requiredbooleanfalseRenders a “required” badge.
defaultstringDefault value.
deprecatedbooleanfalseRenders a “deprecated” badge.
mdx
<ResponseField name="id" type="string" required>
  Stable identifier. Never reused.
</ResponseField>

<ResponseField name="meta" type="object">
  Implementation hint — see [Meta](#meta) for the inner shape.
</ResponseField>
id string required

Stable identifier. Never reused.

meta object

Implementation hint — see Meta for the inner shape.

For nested fields, wrap a child set in <Expandable>.

RequestExample

Container for one or more request snippets, with a labeled header. Most useful with a <CodeGroup> inside so the reader can flip between cURL/JS/Python.

mdx
<RequestExample>
  <CodeGroup>
    ```bash curl
    curl https://api.example.com/v1/users/42 \
      -H "Authorization: Bearer $TOKEN"
    ```
    ```ts ts
    await fetch("https://api.example.com/v1/users/42", {
      headers: { Authorization: `Bearer ${token}` }
    })
    ```
    ```py python
    requests.get(
      "https://api.example.com/v1/users/42",
      headers={"Authorization": f"Bearer {token}"},
    )
    ```
  </CodeGroup>
</RequestExample>

ResponseExample

Same shape as <RequestExample>, but labeled “Response example.”

mdx
<ResponseExample>
  ```json
  {
    "id": "u_abc123",
    "name": "Ada Lovelace",
    "createdAt": "2026-04-29T00:00:00Z"
  }
  ```
</ResponseExample>

OpenApiEndpoint

Native Tangly OpenAPI viewer. Renders one operation with summary, parameters, responses, and a built-in try-it-out form. The spec can be a URL or a path under your project root.

PropTypeDefaultDescription
specstringURL or project-relative path to the OpenAPI document
methodstringHTTP method (get/post/…)
pathstringOpenAPI path template, e.g. /users/{id}
baseUrlstring(first server)Override the base URL — falls back to the first servers[0].url in the spec
authMethod"bearer" | "basic" | "key" | "none"(from docs.json)Auth scheme for the try-it form
authNamestringHeader name when authMethod="key"
mdx
<OpenApiEndpoint
  spec="/openapi.json"
  method="get"
  path="/users/{id}"
/>

The Try it panel sends a real cross-origin fetch. CORS rules apply — if your server doesn’t allow the docs origin, you’ll see a CORS error in the response panel.

OpenApiRedoc

Embeds Redoc for one operation. Standalone bundle is loaded lazily from CDN on first paint.

PropTypeDefaultDescription
specstringURL to the OpenAPI document
methodstringHTTP method
pathstringOpenAPI path
mdx
<OpenApiRedoc spec="/openapi.json" method="get" path="/users/{id}" />

OpenApiScalar

Embeds Scalar for one operation. Lazy-loaded ESM bundle (~50KB gzipped).

mdx
<OpenApiScalar spec="/openapi.json" method="post" path="/users" />

Same prop shape as <OpenApiRedoc>.

OpenApiStoplight

Embeds Stoplight Elements for one operation. Lazy-loaded styles + web components from CDN.

mdx
<OpenApiStoplight spec="/openapi.json" method="delete" path="/users/{id}" />

Same prop shape as <OpenApiRedoc>.

Picking a viewer

The four OpenAPI components are interchangeable in usage — pick the one that matches your aesthetic. Or skip them entirely and let docs.json api.viewer pick the global default; Tangly will then auto-generate full pages from the spec.

ViewerBundleTry-it
<OpenApiEndpoint>Native (no CDN)Built-in
<OpenApiRedoc>~150KBNo
<OpenApiScalar>~50KBYes (Scalar UI)
<OpenApiStoplight>~200KBNo

Source

Last updated Edit this page
↑↓ navigate open esc close