fix(openapi): Preserve example summaries in v3 OpenAPI importer #10804
+1,000
−16
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
Closes #9551
Fixes a bug where OpenAPI example summaries (defined via
examples.<name>.summary) were being ignored in the v3 OpenAPI importer, causing the CLI to display generic "Example 1/2/3" labels instead of user-provided names like "Partner token" and "User token".Changes Made
OpenAPI to IR Conversion
AbstractMediaTypeObjectConverter.parseMediaTypeObject()to preserve the fullOpenAPIV3_1.ExampleObject(includingsummaryanddescriptionfields) instead of extracting only thevaluefieldAbstractMediaTypeObjectConverter.tsto return the complete example object rather thanexample.value ?? exampleIR to FDR Conversion
convertV2HttpEndpointExample()inconvertPackage.tsto preferexample.displayNamewhen setting the FDR examplenamefielddisplayNamewhen present, falling back to the existingshouldUseExampleNamebehavior for backward compatibilityTesting
packages/cli/register/src/ir-to-fdr-converter/__test__/openapi-from-flag.test.tsfollowing CLAUDE.md instructionsRoot Cause
The bug had two parts:
OpenAPI → IR: In
AbstractMediaTypeObjectConverter.ts, example objects were being reduced to just their values when building theexamplesmap. This discarded thesummaryanddescriptionfields. The type signature already indicated it should returnRecord<string, OpenAPIV3_1.ExampleObject>, but the implementation was incorrectly extracting just the value.IR → FDR: In
convertPackage.ts, theconvertV2HttpEndpointExamplefunction only used example names whenshouldUseExampleNamewas true (i.e., when there were duplicate status codes). This meant that even whendisplayNamewas preserved in the IR, it wasn't being surfaced in the FDR output, resulting inname: undefinedfor examples.Testing
pnpm run check)Review Checklist
Please verify:
Snapshot changes are intentional: Multiple test snapshots were updated (x-code-samples, openapi-from-flag-simple, multiple-security-headers, etc.) to show example names instead of
undefined. Confirm these changes reflect the correct behavior and don't indicate unintended side effects.Backward compatibility: The fix prefers
example.displayNamewhen present but falls back to the existingshouldUseExampleNamelogic. Verify this doesn't break any existing use cases where examples don't have displayName set.Type compatibility: Confirm that downstream consumers of
convertedSchema.examples(inRequestBodyConverter,ResponseBodyConverter,ResponseErrorConverter) correctly handle the fullExampleObjectstructure.Coverage: The test covers request body examples. Consider whether response body examples might have the same issue (though they likely follow the same code path).
displayName usage: The fix affects all v2 examples with displayName set, not just OpenAPI examples. Verify this is the desired behavior across all example sources.
Link to Devin run: https://app.devin.ai/sessions/7745e59c5e534fa1bc5f6393a8ef43f4
Requested by: [email protected]