Skip to content

Commit 39d5bf9

Browse files
committed
fix: update gRPC stream type display labels in ApiEndpointDocumentationElement
- Modified the display logic for gRPC stream types to use simplified labels (UNARY, CLIENT, SERVER, BIDIRECTIONAL) instead of the previous capitalized format. - Updated corresponding test cases to validate the new label format for gRPC stream types.
1 parent 89e213d commit 39d5bf9

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/ApiEndpointDocumentationElement.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,15 @@ export class ApiEndpointDocumentationElement extends AmfHelperMixin(LitElement)
555555
// If it's gRPC, add stream type information
556556
if (isGrpc && typeof this._getGrpcStreamType === 'function') {
557557
operationData.grpcStreamType = this._getGrpcStreamType(op);
558-
operationData.grpcStreamTypeDisplay = typeof this._getGrpcStreamTypeDisplayName === 'function'
559-
? this._getGrpcStreamTypeDisplayName(operationData.grpcStreamType)
560-
: operationData.grpcStreamType;
558+
559+
// Map stream type to simplified display labels (without "streaming")
560+
const labelMap = {
561+
'unary': 'UNARY',
562+
'client_streaming': 'CLIENT',
563+
'server_streaming': 'SERVER',
564+
'bidi_streaming': 'BIDIRECTIONAL'
565+
};
566+
operationData.grpcStreamTypeDisplay = labelMap[operationData.grpcStreamType] || 'UNARY';
561567

562568
// Map stream type to HTTP method for consistent colors
563569
const colorMethodMap = {

test/api-endpoint-documentation.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ describe('ApiEndpointDocumentationElement', () => {
532532

533533
const firstLabel = methodLabels[0];
534534
const labelText = firstLabel.textContent.trim();
535-
// The display name from AmfHelperMixin returns capitalized format (e.g., "Unary", "Client Streaming")
536-
const validGrpcTypes = ['Unary', 'Client Streaming', 'Server Streaming', 'Bidirectional'];
535+
// Simplified labels without "streaming" keyword
536+
const validGrpcTypes = ['UNARY', 'CLIENT', 'SERVER', 'BIDIRECTIONAL'];
537537
const isValidGrpcType = validGrpcTypes.some(type => labelText.includes(type));
538538
assert.isTrue(isValidGrpcType, `should display a valid gRPC stream type, got: ${labelText}`);
539539
});

0 commit comments

Comments
 (0)