Repository navigation
docs(proxy): generate experimental proxy API reference - #2542
Conversation
Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
|
Staged Fern docs preview: https://nvidia-preview-pr-2542.docs.buildwithfern.com/nemo/guardrails |
[Low impact] The latest changes appear safe to merge; no actionable new issue was found. SummaryThis PR generates the experimental proxy API reference and guard-contract pages from the bound Python declarations.
|
|
No actionable comments were generated in the recent review.
|
| 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
Possibly related PRs
- NVIDIA-NeMo/Guardrails#2475: Adds the existing deterministic OpenAPI exporter and Fern generation and publishing pipeline extended here.
- NVIDIA-NeMo/Guardrails#2508: Documents the same experimental proxy routes and provider behavior.
- NVIDIA-NeMo/Guardrails#2467: Adds
create_proxy_application, which this exporter uses to generate the proxy OpenAPI document.
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: 
5 · 
1
-
Failed checks: 1 warning Passed checks: 5 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, andgit 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
left a comment
There was a problem hiding this comment.
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 👍🏻
Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
|
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 Ready to merge from my side once the remaining CI checks pass. Thanks for the improvements! |
|
looks good, thanks @miyoungc ! hiding Try it for now makes sense, i'll merge this |
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: falseuntil 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:
fern/proxy-openapi-overlay.ymlandgit diff --check: passed.make docs-fern: 0 errors and 566 warnings. The warnings have not been compared with a fresh base build.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
Codex assisted with implementation, tests, documentation, rendered-output checks, and review. Human sign-off is pending.
Checklist
Summary by CodeRabbit
New Features
Documentation