section

restBody

Wire value: "restBody"

Appears on: Documentation Topic

1. How swift-docc-render consumes this

restBody is one of the section kinds a REST-symbol page's primaryContentSections array can contain (alongside restParameters, restHeaders, restCookies, restEndpoint, restResponses, and the ordinary symbol sections). The dispatch table lives in PrimaryContent.vue, which keys a componentFor(section) lookup and a parallel propsFor(section) lookup off section.kind, using the SectionKind constant map defined in constants/PrimaryContentSection.js:

componentFor(section) {
  return {
    ...
    [SectionKind.restBody]: RestBody,
    ...
  }[section.kind];
},
propsFor(section) {
  const { bodyContentType, content, mimeType, parameters, title, ... } = section;
  return {
    ...
    [SectionKind.restBody]: {
      bodyContentType,
      content,
      mimeType,
      parts: parameters,
      title,
    },
    ...
  }[kind];
},

Note the rename on the way in: the wire's parameters array becomes the parts prop on the component. The target component is RestBody.vue, whose template renders two stacked pieces: a single-row "parameters table" describing the body itself (its declared type and free-form content description), followed — only v-if="parts.length" — by a second, multi-row table headed "Parts" that lists the individual multipart/form-data parameters when the body is multipart-encoded:

<section>
  <LinkableHeading :anchor="anchor">{{ title }}</LinkableHeading>
  <ParametersTable :parameters="[bodyParam]" :changes="bodyChanges" keyBy="key">
    ...
  </ParametersTable>
  <template v-if="parts.length">
    <h3>{{ $t('sections.parts') }}</h3>
    <ParametersTable :parameters="parts" class="parts" :changes="partsChanges">
      ...
    </ParametersTable>
  </template>
</section>

The first table is fed a synthetic single-element array, bodyParam, built in a computed property from the section's own bodyContentType/content/mimeType props (keyed by a constant string ChangesKey = 'restRequestBody', used only to look up API-diff highlighting) — the body itself is presented through the exact same ParametersTable/row-slot machinery used for the real parts list, just with one synthetic row standing in for "the body as a whole." Each part row shows the part's name and declaration tokens in the "symbol" column, and in the "description" column: an optional "(Required)" / "(Read only)" text prefix, the free-form content markup (via ContentNode), the part's own mimeType, and any attributes (rendered by ParameterAttributes.vue).

The section also participates in the on-this-page navigation: in onThisPageRegistrator.js, restBody is grouped with the other primary-content-anchor kinds (properties, restCookies, restEndpoint, restHeaders, restParameters, restResponses) to register a level-2 on-this-page entry titled from the section's own title field, anchored via anchorize(section.title) — the same anchor computed inside RestBody.vue itself for its LinkableHeading.

See also: Localization fallback — how $t()/locale-key lookup works across every kind that uses it.

2. Example JSON and rendered mockup

Real fixture, from swift-docc's test suite: Tests/SwiftDocCTests/Rendering/Rendering Fixtures/rest-symbol.json (lines 251–295), a multipart/form-data request body with one part. A second, minimal fixture (title/mimeType/bodyContentType only, no content or parameters) appears inline in Tests/SwiftDocCTests/Rendering/RESTBodyRenderSectionTests.swift lines 17–24.

{
  "kind": "restBody",
  "title": "Parts",
  "mimeType": "multipart/form-data",
  "bodyContentType": [
    {
      "kind": "identifier",
      "text": "form-data"
    }
  ],
  "content": [
    {
      "type": "paragraph",
      "inlineContent": [
        {
          "type": "text",
          "text": "The article’s Apple News Format JSON document and other assets."
        }
      ]
    }
  ],
  "parameters": [
    {
      "name": "Any Key",
      "type": [
        {
          "kind": "text",
          "text": "binary"
        }
      ],
      "required": true,
      "mimeType": "application/octet-stream",
      "content": [
        {
          "type": "paragraph",
          "inlineContent": [
            {
              "type": "text",
              "text": "Assets, such as images."
            }
          ]
        }
      ]
    }
  ]
}

Parts

form-data
The article’s Apple News Format JSON document and other assets.

Parts

Any Key
(Required) Assets, such as images.
Content-Type: application/octet-stream

mockup: body-level row (declaration tokens + description) followed by an optional "Parts" sub-table, one row per multipart parameter — both rendered with the same parameter-table layout

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/RESTBodyRenderSection (lines 2917–2955), one branch of the DocumentationPrimaryRenderSection discriminated union (lines 2507–2546); cross-checked against the generated Components.Schemas.RESTBodyRenderSection struct in Sources/DocCArchive/generated/Types.swift (lines 6577–6627).

FieldTypeRequiredEnum values / defaultNote
kind string yes "restBody" (sole enum value) Discriminator. Generated as a dedicated KindPayload frozen enum with the single case restBody. Unlike mentions, this section does carry an explicit discriminator on the wire, so CodableContentSection (swift-docc, Model/Rendering/RenderNode/CodableContentSection.swift line 62) and the generated oneOf decoder both dispatch on it directly rather than trying candidates in sequence.
title string yes — Always the literal string "HTTP Body" in practice — swift-docc's HTTPBodySectionTranslator hard-codes this value when building the section (see §1/§3 authoring note); the fixture above uses "Parts", showing the schema itself places no constraint on the string.
mimeType string yes — Free-form MIME type string for the body's content encoding (e.g. multipart/form-data, application/json). No enum constraint in the schema.
bodyContentType array of DeclarationToken yes — A tokenized type declaration (same token shape used throughout declarations sections: kind one of keyword/attribute/number/string/identifier/typeIdentifier/genericParameter/text/internalParam/externalParam/label, plus optional identifier, preciseIdentifier, highlight). Generated as [Components.Schemas.DeclarationToken1] (a duplicate-suffixed name from OpenAPI merging, structurally identical to DeclarationToken).
content array of RenderBlockContent no — Free-form Markdown-derived block content describing the body as a whole (e.g. the paragraph in the example above). Optional in both the JSON Schema and the generated struct ([RenderBlockContent]?).
parameters array of TypedProperty no — Present only when the body is a multipart encoding with named parts. Each TypedProperty carries name, type (declaration tokens), optional typeDetails, content, attributes, mimeType, readOnly, required, deprecated, introducedVersion. On the render-render side this array is passed to RestBody.vue as the parts prop (renamed, see §1). swift-docc's Swift-side model (RESTBodyRenderSection.swift line 33) types this field as [RenderProperty]?, its own name for the same wire shape.

Authoring-side note: unlike most section kinds, there is no Markdown/directive syntax an author writes directly to produce a restBody section. swift-docc's HTTPBodySectionTranslator builds the section by reading a symbol's httpBodySection (populated from a SymbolGraph symbol mixin, typically produced by converting an OpenAPI specification into a symbol graph upstream of DocC), filtering its parameters to those with a "body" source and a backing symbol, and hard-coding title: "HTTP Body" — there is no corresponding case in Sources/SwiftDocC/Model/Rendering/Symbol/RESTBodyRenderSection.swift (the plain data struct, lines 14–49) for an author-facing directive, and no matching .docc catalog article was found describing one.

DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift are still stub placeholders (the HTML transformer returns a hardcoded <!-- what? --> comment and the Markdown transformer returns an empty string) — neither has any kind-specific handling for restBody (or any other render section) today. A future implementation would need to render the body's own declaration/content row plus, conditionally, the parameters list as a sub-table, mirroring RestBody.vue's two-table structure.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM shape, from RestBody.vue's template and the shared ParametersTable.vue it delegates to:

SCSS: RestBody.vue carries its own <style lang="scss" scoped> block (importing docc-render/styles/_core.scss) with two rules: .part-name { font-weight: $font-weight-bold; }, and a .content { display: inline; :deep(p:first-child) { display: inline; } } rule that keeps an inline "(Required)"/"(Read only)" text prefix on the same line as the first paragraph of part description text. The shared ParametersTable.vue supplies the actual grid layout — .param-symbol (text-align: right, collapsing to left-aligned under the small breakpoint), .param-content (padding-left: 1rem), and .param + .param { margin-top: var(--spacing-param); } for inter-row spacing. It also defines the diff-highlight styling applied when API-change tracking flags a row via .changed/.changed-{added|removed|changed} classes (using the change-highlight-target()/change-highlight-end-spacing() mixins), driven by the bodyChanges/partsChanges computed properties keyed off the constant string 'restRequestBody'.

CSS custom properties consumed: --spacing-param (defined as rem(28px) in src/styles/base/_typography.scss line 48) for vertical spacing between parameter rows, and --colors-grid (falling back to --color-grid), consumed one level up by the parent PrimaryContent.vue for the shared top border above the whole primary-content column — not specific to restBody itself.

5. Modern CSS-only alternative

NOT APPLICABLE

Current behavior: RestBody.vue has exactly one piece of conditional rendering — a v-if="parts.length" template guard that omits the "Parts" heading and sub-table entirely when the wire's parameters array is empty or absent — plus two small computed-property data transforms (building the synthetic bodyParam row, and looking up any API-diff highlight data keyed by 'restRequestBody'). None of this is interactive: there is no click handler, no toggle, no post-mount state change, and no show/hide behavior triggered by user action. The v-if is equivalent to a server/build-time conditional include (present the "Parts" table only if there are parts to show), and the row/column layout is static grid markup with no runtime state at all.

Because there is no client-side state transition to reproduce, none of the stateful-CSS mechanisms (<details>/<summary>, checked radio + sibling selector, :target, the Popover API, <dialog>, :has()) apply here — they all exist to hold or toggle state in the DOM in response to user interaction, and this section has no such state to hold. A static site generator (or a future DocCArchive HTML transformer) can reproduce the v-if="parts.length" behavior by simply omitting the "Parts" heading and sub-table markup at build time when the parameters array is empty, and can lay out the body-row and parts-table grid with plain CSS grid or flexbox — none of it depends on CSS or JavaScript running in the browser.