feat: add copy operationId function #10496
Open
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
This PR adds convenient operationId copying functionality to Swagger UI, providing users with two intuitive ways to copy operationId values:
Key Features:
displayOperationId
is enabled and operationId existsoriginalOperationId
overoperationId
UI/UX Improvements:
Motivation and Context
Problem Statement
Currently, Swagger UI only provides a copy button for API paths, but developers frequently need to copy operationId values for:
User Pain Points
Solution Benefits
Context
This enhancement is particularly valuable for:
How Has This Been Tested?
Testing Environment
displayOperationId: true
enabledManual Testing Scenarios
1. Basic Functionality Testing
originalOperationId
takes precedence overoperationId
when both exist2. Visual Feedback Testing
3. Edge Cases and Error Handling
displayOperationId: false
4. Integration Testing
5. Cross-browser Compatibility
Screenshots (if appropriate):
click green button to copy operationId easier.
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests
描述
此 PR 为 Swagger UI 添加了便捷的 operationId 复制功能,为用户提供两种直观的复制 operationId 值的方式:
主要功能:
displayOperationId
且存在 operationId 时显示originalOperationId
而非operationId
UI/UX 改进:
动机和背景
问题陈述
目前,Swagger UI 仅为 API 路径提供复制按钮,但开发者经常需要复制 operationId 值用于:
用户痛点
解决方案优势
背景
此增强功能对以下用户特别有价值:
如何测试
测试环境
displayOperationId: true
手动测试场景
1. 基本功能测试
originalOperationId
优先于operationId
2. 视觉反馈测试
3. 边界情况和错误处理
displayOperationId: false
时功能被禁用4. 集成测试
5. 跨浏览器兼容性