feat(cli): merge OpenAPI examples with x-fern-examples instead of overriding #11761
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refs: Requested by @Ryan-Amirthan
When an OpenAPI spec contains both
x-fern-examplesand standard OpenAPI examples (inrequestBody.content.application/json.examplesandresponses.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
extractOpenAPIExamples()method to extract examples from standard OpenAPIrequestBodyandresponsessectionsgetRequestBodyExamples()to extract request body examples fromapplication/jsoncontentgetResponseBodyExamples()to extract response examples from 200/201/2XX responsesconvertExamples()to merge OpenAPI examples after x-fern-examples (x-fern-examples take precedence by appearing first)examples-endpoint-level,examples-endpoint-level-named, andexamples-schema-levelfixturespackages/cli/registerfor AI examples and human examples preservation testsHuman Review Checklist
"treeList"instead of"base_Example list of trees_200"). Some examples now havedisplayName: undefined,statusCode: undefined, andrequest: undefined. Verify this is expected and doesn't affect API reference renderingrequest: undefinedwhere previously there was request data. Verify this doesn't cause regressions in the API reference displayapplication/jsonexamples are extracted. Other content types are not handledTesting
pnpm run check)