Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 22, 2025

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

  • Modified AbstractMediaTypeObjectConverter.parseMediaTypeObject() to preserve the full OpenAPIV3_1.ExampleObject (including summary and description fields) instead of extracting only the value field
  • Changed lines 89 and 91 in AbstractMediaTypeObjectConverter.ts to return the complete example object rather than example.value ?? example

IR to FDR Conversion

  • Updated convertV2HttpEndpointExample() in convertPackage.ts to prefer example.displayName when setting the FDR example name field
  • Added logic to use displayName when present, falling back to the existing shouldUseExampleName behavior for backward compatibility
  • This ensures OpenAPI example summaries are surfaced in the final FDR output used by documentation

Testing

  • Added regression test in packages/cli/register/src/ir-to-fdr-converter/__test__/openapi-from-flag.test.ts following CLAUDE.md instructions
  • Created test fixture with OpenAPI spec from issue OpenAPI example summaries are ignored in latest CLI version #9551
  • Generated snapshot files to validate IR and FDR output
  • Updated snapshots for existing tests (x-code-samples, openapi-from-flag-simple, etc.) to reflect corrected behavior

Root Cause

The bug had two parts:

  1. OpenAPI → IR: In AbstractMediaTypeObjectConverter.ts, example objects were being reduced to just their values when building the examples map. This discarded the summary and description fields. The type signature already indicated it should return Record<string, OpenAPIV3_1.ExampleObject>, but the implementation was incorrectly extracting just the value.

  2. IR → FDR: In convertPackage.ts, the convertV2HttpEndpointExample function only used example names when shouldUseExampleName was true (i.e., when there were duplicate status codes). This meant that even when displayName was preserved in the IR, it wasn't being surfaced in the FDR output, resulting in name: undefined for examples.

Testing

  • Lint checks passed (pnpm run check)
  • Regression test added following CLAUDE.md instructions
  • Test validates that "Partner token" and "User token" appear in FDR output with correct names
  • Test validates that generic names like "Example 1" do NOT appear
  • Snapshot files generated and updated for regression testing
  • All existing tests pass with updated snapshots

Review Checklist

Please verify:

  1. 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.

  2. Backward compatibility: The fix prefers example.displayName when present but falls back to the existing shouldUseExampleName logic. Verify this doesn't break any existing use cases where examples don't have displayName set.

  3. Type compatibility: Confirm that downstream consumers of convertedSchema.examples (in RequestBodyConverter, ResponseBodyConverter, ResponseErrorConverter) correctly handle the full ExampleObject structure.

  4. 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).

  5. 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]

Fixes #9551

The bug was in AbstractMediaTypeObjectConverter.parseMediaTypeObject where
example objects were being reduced to just their values, discarding the
summary and description fields. This caused example names to be lost,
resulting in generic 'Example 1/2/3' labels instead of the user-provided
summary names like 'Partner token' and 'User token'.

The fix preserves the full example object (including summary and description)
instead of extracting only the value field.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 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

devin-ai-integration bot and others added 6 commits November 22, 2025 23:09
Adds test case following CLAUDE.md instructions to verify that OpenAPI
example summaries (defined via examples.<name>.summary) are correctly
preserved through the v3 parser pipeline.

Test validates that:
- Example names 'Partner token' and 'User token' appear in IR
- Generic names like 'Example 1' or 'Example 2' are NOT generated
- FDR output contains the correct example names

Includes fixture with OpenAPI spec from GitHub issue #9551 and
snapshot files for regression testing.

Co-Authored-By: [email protected] <[email protected]>
When converting IR v2 examples to FDR format, prefer example.displayName
over the shouldUseExampleName logic. This ensures OpenAPI example summaries
are always surfaced in the FDR output, fixing the issue where example names
appeared as undefined instead of user-provided summaries like 'Partner token'
and 'User token'.

The fix maintains backward compatibility by falling back to the existing
shouldUseExampleName behavior when displayName is not present.

Fixes #9551

Co-Authored-By: [email protected] <[email protected]>
The gRPC proto test snapshot needs to be updated to reflect the fix that
preserves example.displayName in FDR conversion. The example name is now
'commentsServiceCreatecommentExample' instead of undefined, consistent with
the OpenAPI example fixes.

Co-Authored-By: [email protected] <[email protected]>
Restore the grpc-comments-fdr.snap file from main and apply only the
name field change to preserve example.displayName. This ensures the
EOF format matches the original (no trailing blank line after final }).

Co-Authored-By: [email protected] <[email protected]>
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.

OpenAPI example summaries are ignored in latest CLI version

1 participant