Skip to content

Conversation

@Ryan-Amirthan
Copy link
Contributor

@Ryan-Amirthan Ryan-Amirthan commented Jan 26, 2026

Description

Refs: Requested by @Ryan-Amirthan

When an OpenAPI spec contains both x-fern-examples and standard OpenAPI examples (in requestBody.content.application/json.examples and responses.200.content.application/json.examples), previously only the x-fern-examples were displayed in the API reference. This PR changes the behavior to show both sets of examples.

Link to Devin run: https://app.devin.ai/sessions/a6f0f3945923431fab433900b42bf310

Changes Made

  • Added extractOpenAPIExamples() method to extract examples from standard OpenAPI requestBody and responses sections
  • Added getRequestBodyExamples() to extract request body examples from application/json content
  • Added getResponseBodyExamples() to extract response examples from 200/201/2XX responses
  • Modified convertExamples() to merge OpenAPI examples after x-fern-examples (x-fern-examples take precedence by appearing first)
  • Request and response examples are matched by index (1st request example pairs with 1st response example)
  • Updated test snapshots for examples-endpoint-level, examples-endpoint-level-named, and examples-schema-level fixtures
  • Updated test snapshots in packages/cli/register for AI examples and human examples preservation tests
  • Added changelog entry (version 3.51.0)
  • Updated README.md generator (if applicable)

Human Review Checklist

  • Index-based matching: Request/response examples are matched by index. Verify this heuristic is acceptable for cases where the number of request examples differs from response examples
  • Snapshot structure changes: The updated snapshots show a simpler example structure (e.g., "treeList" instead of "base_Example list of trees_200"). Some examples now have displayName: undefined, statusCode: undefined, and request: undefined. Verify this is expected and doesn't affect API reference rendering
  • Potential data loss: Some snapshots show examples with request: undefined where previously there was request data. Verify this doesn't cause regressions in the API reference display
  • Potential duplicates: If x-fern-examples and OpenAPI examples contain similar content, both will now be shown. Consider if deduplication is needed
  • Content type limitation: Only application/json examples are extracted. Other content types are not handled

Testing

  • Lint checks pass (pnpm run check)
  • Test snapshots updated (v3-importer-tests and register package)
  • All CI checks passing
  • Manual testing with ryanstep-config repo to verify examples appear correctly in API reference

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants