Skip to content

docs(proxy): generate experimental proxy API reference - #2542

Merged
Pouyanpi merged 6 commits into
developfrom
miyoungc/sdr-1839-proxy-api-reference
Nov 5, 2026
Merged

Pouyanpi merged 6 commits into
developfrom
miyoungc/sdr-1839-proxy-api-reference

Conversation

@miyoungc

@miyoungc miyoungc commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Generate the experimental Guardrails proxy API reference from the registered FastAPI routes for the built-in OpenAI provider. Export a deterministic example deployment without starting the proxy or contacting a provider, and generate the reference during documentation builds, previews, publishing, and historical snapshot preparation.

The new Chat Completions and Responses pages describe the proxy's guard boundary separately from upstream provider requirements. Policy labels distinguish guarded, constrained, disabled, and opaque fields; generated guard-contract pages retain request, response, and stream declarations. The reference includes examples, documented errors, deployment-specific URLs, and links to the existing proxy guides. Existing guide and API reference routes are preserved.

The hooks-server portion is separate in #2541. Both changes touch shared documentation generation code; whichever merges second will need to reconcile that integration. The proxy API Explorer (Try it) is hidden with x-fern-explorer: false until connection setup, CORS, and credential input are ready in the separate Try it follow-up (#2492).

Related Issue(s)

SDR-1839: Implement automated API reference generation for Guardrails hooks server and proxy, assigned to Miyoung Choi. The directing human confirmed SDR-1839 as the tracking issue for this contribution and explicitly authorized implementation and PR creation. This PR covers the proxy portion of that ticket.

Verification

Latest local validation for the Try it change:

  • Pre-commit on fern/proxy-openapi-overlay.yml and git diff --check: passed.
  • make docs-fern: 0 errors and 566 warnings. The warnings have not been compared with a fresh base build.
  • Local Fern preview: both proxy endpoint pages returned HTTP 200 with no Try it button, retaining examples and guard-contract links. The main Guardrails API retained its existing Try it control.
  • Structured review: no actionable findings.

Earlier validation on the initial implementation commit (c89b88a2e) passed 4 focused exporter tests and all 21 documentation-script tests, including Fern conversion, existing reference routes/examples, historical generation, and publish failure handling. That script-test run used a temporary file-descriptor limit of 4096 for the preview watcher.

CI has started again on the latest commit; current results are in the PR checks.

AI Assistance

  • No AI tools were used.
  • AI tools were used; a human reviewed and can explain every change (tool: Codex).

Codex assisted with implementation, tests, documentation, rendered-output checks, and review. Human sign-off is pending.

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This PR links to a triaged issue assigned to me.
  • My PR title follows the project commit convention.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • I've noted any verification beyond CI and any checks I couldn't run.
  • I did not update generated changelog files manually.
  • I addressed all CodeRabbit, Greptile, and other review comments, or replied with why no change is needed.
  • @mentions of the person or team responsible for reviewing proposed changes.

Summary by CodeRabbit

  • New Features

    • Added an Experimental Proxy API reference covering guarded chat-completion and Responses endpoints, with request and response examples.
    • Documented provider-native responses, possible upstream errors, and configuration-dependent inspection.
  • Documentation

    • Added the proxy API to the API reference navigation, including displayed error information.

Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
@github-actions github-actions Bot added status: needs triage New issues that have not yet been reviewed or categorized. size: L labels Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@miyoungc miyoungc added status: in progress Issues that are currently being worked on. status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). and removed status: needs triage New issues that have not yet been reviewed or categorized. labels Oct 30, 2026
@miyoungc
miyoungc marked this pull request as ready for review October 30, 2026 20:41
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The latest changes appear safe to merge; no actionable new issue was found.

Summary

This PR generates the experimental proxy API reference and guard-contract pages from the bound Python declarations.

  • The built-in OpenAI proxy routes have generated API and guard-contract reference pages.
  • Docs generation now includes the proxy reference across builds, publishing, and snapshots.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Bound Python declarations] --> B[Proxy reference exporter]
  B --> C[OpenAPI specification]
  B --> D[Guard-contract pages]
  C --> E[Proxy documentation overlay]
  E --> F[Fern reference pages]
  D --> F
Loading

Reviews (4) · Last reviewed commit: "docs(proxy): hide Try it in generated re..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8d027fd and c89b88a.

Files selected for processing: 13
  • .github/workflows/docs-build.yaml
  • .github/workflows/guardrails-api-spec.yml
  • .gitignore
  • Makefile
  • docs/index.yml
  • fern/proxy-openapi-overlay.yml
  • scripts/cache-fern-ref-sdk.mjs
  • scripts/export_proxy_openapi.py
  • scripts/tests/cache-fern-ref-sdk.test.mjs
  • scripts/tests/docs-publish.test.mjs
  • scripts/tests/proxy-openapi-reference.test.mjs
  • scripts/watch-fern-preview.mjs
  • tests/server/test_export_proxy_openapi.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Walkthrough

This change adds a script to export the built-in proxy’s OpenAPI specification, connects the export to the Fern generation and publishing workflows, and adds an experimental proxy API reference for chat completions and Responses.

Changes: Proxy OpenAPI reference

Layer / File(s) Summary
Generate and validate the proxy specification
scripts/export_proxy_openapi.py, tests/server/test_export_proxy_openapi.py
The new script generates the proxy OpenAPI schema, writes it to the default or specified path, and checks existing output for changes. Tests cover schema content, determinism, check mode, route prefixes, and example validation.
Integrate export into the Fern pipeline
Makefile, scripts/cache-fern-ref-sdk.mjs, scripts/tests/cache-fern-ref-sdk.test.mjs, scripts/tests/docs-publish.test.mjs, .github/workflows/docs-build.yaml, .github/workflows/guardrails-api-spec.yml, .gitignore, scripts/watch-fern-preview.mjs
The build and publishing scripts run the proxy exporter. Workflow filters include proxy-related files, the API-spec workflow runs the exporter tests, and preview triggers ignore the generated specification.
Document the proxy API reference
docs/index.yml, fern/proxy-openapi-overlay.yml, scripts/tests/proxy-openapi-reference.test.mjs, tests/server/test_export_proxy_openapi.py
The API navigation links the generated specification and overlay. The overlay documents chat-completions and Responses operations, with examples and route, streaming, and inspection details. Tests check generated reference content and validate overlay examples.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant Makefile
  participant Exporter as export_proxy_openapi.py
  participant Spec as fern/proxy-openapi.yml
  participant Fern as Fern IR generation
  Makefile->>Exporter: run proxy OpenAPI export
  Exporter->>Spec: write generated specification
  Fern->>Spec: read specification for IR generation
Loading

Possibly related PRs

Suggested labels: documentation, temp: guardrails-proxy

Suggested reviewers: pouyanpi, tgasser-nv, m-misiura

Merge Risk: Minimal · up to c89b8

The proxy reference is regenerated during documentation builds. No merge-blocking issue was identified; normal CI checks remain appropriate.

Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: generating experimental proxy API reference documentation.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Test Results For Major Changes Passed The PR contains a substantial documentation-generation feature and adds exporter and integration tests. The description documents test results for tests/server/test_export_proxy_openapi.py (4 passed…
Full details: Test Results For Major Changes

Explanation

The PR contains a substantial documentation-generation feature and adds exporter and integration tests. The description documents test results for tests/server/test_export_proxy_openapi.py (4 passed), make test-docs-scripts (21 passed), make docs-fern (0 errors), preview checks, pre-commit, and git diff --check. The change does not affect numerics, convergence, or runtime performance, so no performance comparison is required.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 7 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Explain the bound request policies with colored Fern badges and distinguish
proxy constraints from provider requirements. Correct Fern's null-only type
display for explicitly marked proxy fields while retaining optionality and
the exported validation assertions.

Document conditional output inspection, provider-native response excerpts,
and streaming failures after headers. Cover policy annotations and nested
fields through offline exporter and Fern conversion checks.

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Render request, response, and stream declarations from the bound native
OpenAI endpoints with stable section anchors, separate object and union
scopes, linked policy badges, and the unmodified exported contract.

Link the concise endpoint references to these pages and keep runtime
streaming guidance in the canonical proxy guides. Generate pages alongside
OpenAPI during builds, publishing, and snapshot preparation, check them for
staleness, and ignore generated writes in the preview watcher.

Validate offline export fidelity, nullable constraints, missing-page checks,
Fern conversion, publishing and snapshot generation, and preview behavior.

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
Keep Try it available while excluding disabled fields from Fern's editable
request parameter list. Preserve their original null-only declarations in
the generated contract reference and leave runtime validation unchanged.

Replace raw annotation JSON in contract tables with readable rules,
simplify nullable type labels, and keep detailed declarations in the exact
export. Leave the server origin unspecified pending deployment setup.

Validate field filtering through Fern conversion, unchanged validation
assertions through offline exports, and the dialogs and table layouts in
Chrome without sending inference requests.

Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>

@Pouyanpi Pouyanpi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @miyoungc for putting this together, this is GREAT 🚀 having the reference generated from the proxy routes is really helpful.

I pushed some improvements for policy labels, disabled-field visibility, links to the guard contracts, and table readability. please feel free to adjust or drop anything that feels out of scope.

the main thing i’d like to preserve is the distinction between the proxy’s guard boundary and the upstream provider API. guarded, constrained, disabled, and opaque fields have different guarantees, so the reference should make those clear and point to the guard contract for details.

We could also hide "Try it" for now and handle connection setup, CORS, and credential input separately, following #2492. curious to hear your thoughts. I'll merge if you're ok with these changes or after you've done another iteration 👍🏻

@miyoungc

miyoungc commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, @Pouyanpi! Your improvements look good, and I agree with keeping the proxy’s guard boundary distinct from the upstream provider API.

I’ve hidden Try it for the proxy reference with x-fern-explorer: false in 31266fb. I verified locally that both proxy pages retain their examples and guard-contract links without the Try it control. Connection setup, CORS, and credential input can stay in the separate follow-up to #2492.

Ready to merge from my side once the remaining CI checks pass. Thanks for the improvements!

@Pouyanpi

Pouyanpi commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

looks good, thanks @miyoungc ! hiding Try it for now makes sense, i'll merge this

@Pouyanpi Pouyanpi removed the status: in progress Issues that are currently being worked on. label Nov 5, 2026
@Pouyanpi Pouyanpi added this to the v0.25.0 milestone Nov 5, 2026
@Pouyanpi
Pouyanpi merged commit 4065fa3 into develop Nov 5, 2026
30 checks passed
@Pouyanpi
Pouyanpi deleted the miyoungc/sdr-1839-proxy-api-reference branch November 5, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants