Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@api-components/api-method-documentation",
"description": "A HTTP method documentation build from AMF model",
"version": "5.2.30",
"version": "5.2.31",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand Down
66 changes: 0 additions & 66 deletions src/ApiUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,72 +365,6 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {

// ========== gRPC Support Methods ==========

/**
* Checks if the given operation is a gRPC operation
* @param {Object} operation Operation model
* @return {boolean}
*/
_isGrpcOperation(operation) {
if (!operation) {
return false;
}

// Check for gRPC-specific methods
const method = this._getValue(operation, this.ns.aml.vocabularies.apiContract.method);
if (method && typeof method === 'string' && ['publish', 'subscribe', 'pubsub'].includes(method.toLowerCase())) {
return true;
}

// Check for gRPC media type in request
const expects = this._computeExpects(operation);
if (expects) {
const payloadKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.payload);
const payloads = this._ensureArray(expects[payloadKey]);

if (payloads && payloads.length > 0) {
const mediaType = this._getValue(payloads[0], this.ns.aml.vocabularies.core.mediaType);
if (mediaType && typeof mediaType === 'string' &&
(mediaType === 'application/grpc' || mediaType === 'application/grpc+proto')) {
return true;
}
}
}

return false;
}

/**
* Gets the gRPC stream type for an operation
* @param {Object} operation Operation model
* @return {string} Stream type: 'unary', 'client_streaming', 'server_streaming', or 'bidi_streaming'
*/
_getGrpcStreamType(operation) {
if (!operation) {
return 'unary';
}

const method = this._getValue(operation, this.ns.aml.vocabularies.apiContract.method);

if (!method || typeof method !== 'string') {
return 'unary';
}

// Map methods to gRPC stream types
const methodLower = method.toLowerCase();
switch (methodLower) {
case 'publish':
return 'client_streaming';
case 'subscribe':
return 'server_streaming';
case 'pubsub':
return 'bidi_streaming';
case 'post':
case 'get':
default:
return 'unary';
}
}

/**
* Gets the display name for a gRPC stream type
* @param {string} streamType Stream type
Expand Down
12 changes: 12 additions & 0 deletions test/api-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ describe('<api-url>', () => {
it('should compute method', () => {
assert.equal(element._method, 'PUBLISH');
});

it('should render PUBLISH as the displayed method label', async () => {
await waitUntil(() => element.shadowRoot.querySelector('.method-label'));
const label = element.shadowRoot.querySelector('.method-label');
assert.equal(label.textContent.trim(), 'PUBLISH');
});
});

describe('APIC-560', () => {
Expand Down Expand Up @@ -159,6 +165,12 @@ describe('<api-url>', () => {
assert.equal(element.shadowRoot.querySelector('.async-server-name').textContent, expectedServer);
});

it('should render SUBSCRIBE as the displayed method label', async () => {
await waitUntil(() => element.shadowRoot.querySelector('.method-label'));
const label = element.shadowRoot.querySelector('.method-label');
assert.equal(label.textContent.trim(), 'SUBSCRIBE');
});

it('should only render url value when no operation selected', async () => {
element.amf = amf
element.operation = undefined
Expand Down
Loading