Managing API Documentation

1. Generating OpenAPI Specifications

Example: OpenAPI 3.1 spec

openapi: 3.1.0
info:
  title: Orders API
  version: 2.0.0
servers:
  - url: https://api.example.com/v2
paths:
  /orders/{id}:
    get:
      summary: Get order
      parameters:
        - { name: id, in: path, required: true, schema: { type: string } }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Order" }

2. Configuring Swagger UI Integration

SettingValue
UI route/docs
Spec URL/openapi.json
Try-it-outEnable for non-destructive
OAuth flowEmbed PKCE in UI
ThemeCustom CSS

3. Using ReDoc Integration

Aspectvs Swagger UI
LayoutThree-column, read-focused
SearchBuilt-in, no plugin
ThemingObject-based config
Try-it-outPro version only

4. Setting Up API Documentation Endpoints

EndpointReturns
/openapi.jsonSpec (machine-readable)
/openapi.yamlYAML variant
/docsSwagger UI
/redocReDoc UI
/.well-known/openapiDiscovery (proposed)

5. Implementing Auto-Discovery

MethodDetail
Code annotationsSpring @Operation, FastAPI types
Gateway introspectionBuild spec from route configs
Service registry pullEach service exposes its spec
Spectral lintCI gates on schema quality

6. Configuring Documentation Versioning

StrategyURL
Per major/docs/v1, /docs/v2
SwitcherDropdown in UI
Git tagsMatch spec to release tag
ChangelogAuto-diff between versions

7. Using Markdown Documentation

UseDetail
GuidesGetting started, tutorials
OpenAPI descriptionCommonMark supported
SDK pagesPer-language quickstart
ToolsDocusaurus, Mintlify, Mkdocs

8. Setting Up Code Examples

Example: x-codeSamples in OpenAPI

paths:
  /orders:
    post:
      x-codeSamples:
        - lang: curl
          source: |
            curl -X POST https://api.example.com/orders \
              -H "Authorization: Bearer $TOKEN" \
              -d '{"sku":"abc","qty":1}'
        - lang: javascript
          source: |
            const r = await fetch("/orders", {
              method: "POST",
              headers: { Authorization: `Bearer ${token}` },
              body: JSON.stringify({ sku: "abc", qty: 1 })
            });

9. Implementing Interactive Documentation

FeatureTool
Live consoleSwagger UI, Postman
Auto-generated tokensDev portal sandbox
Embedded playgroundGraphiQL, Apollo Sandbox
Mock responsesPrism, MockServer

10. Configuring Documentation Access Control

AudienceVisibility
Public APIsAnonymous OK
Partner APIsLogin + NDA
Internal APIsVPN or SSO
Beta featuresx-internal: true filter