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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ demo/models/flattened/*.json
!demo/models/avro.json
!demo/models/avro2.json
!demo/models/grpc-test.json
!demo/models/grpc-test-compact.json

.idea/
.sfdx
Expand Down
1 change: 1 addition & 0 deletions demo/element/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ApicApplication extends DemoBase {
constructor() {
super();
this.apis = [
['grpc-test', 'gRPC API'],
['google-drive-api', 'Google Drive API'],
['httpbin', 'HTTPbin API'],
['data-type-fragment', 'RAML data type fragment'],
Expand Down
1,045 changes: 1,045 additions & 0 deletions demo/models/grpc-test-compact.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions demo/standalone/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ApicApplication extends DemoBase {
constructor() {
super();
this.apis = [
['grpc-test', 'gRPC API'],
['google-drive-api', 'Google Drive API'],
['httpbin', 'HTTPbin API'],
['oAuth2', 'oAuth2'],
Expand Down
3 changes: 2 additions & 1 deletion demo/themed/anypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ class ApicApplication extends DemoBase {
super();
this.apis = [
['grpc-test', 'gRPC API'],
['agents-api', 'Agents API'],
['agents-api-compact', 'Agents API Compact'],
['google-drive-api', 'Google Drive API'],
['httpbin', 'HTTPbin API'],
['data-type-fragment', 'RAML data type fragment'],
['demo-api', 'Demo API'],
['APIC-538', 'APIC-538'],
['agents-api', 'Agents API Compact'],
];
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api-console",
"description": "The API Console to automatically generate API documentation from RAML and OAS files.",
"version": "6.6.57",
"version": "6.6.58",
"license": "CPAL-1.0",
"main": "index.js",
"module": "index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
"@anypoint-web-components/anypoint-button": "^1.1.1",
"@api-components/amf-helper-mixin": "^4.5.36",
"@api-components/api-console-ext-comm": "^3.0.0",
"@api-components/api-documentation": "^6.1.7",
"@api-components/api-documentation": "^6.1.8",
"@api-components/api-navigation": "^4.3.20",
"@api-components/api-request": "^0.3.8",
"@api-components/api-summary": "^4.6.16",
Expand Down
3 changes: 2 additions & 1 deletion src/ApiConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
const webApi = this._computeApi(amf);
this.webApi = webApi;
this.methodName = this._computeMethodName(this.selectedShape, webApi);
if (!this._isWebAPI(amf)) {
// Hide try-it panel for gRPC APIs or non-WebAPI models
if (!this._isWebAPI(amf) || this._isGrpcApi(amf)) {
this._noTryItValue = true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/ApiConsoleApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ export class ApiConsoleApp extends ApiConsole {
*/
async _processModelChange() {
super._processModelChange();
// Update try-it panel visibility based on API type (gRPC detection)
this._updateRenderInlineTyit();
this.apiTitle = this._computeApiTitle(this.webApi);
await this.updateComplete;
if (window.history.state) {
Expand Down
50 changes: 50 additions & 0 deletions test/api-console.amf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const selectOperation = (element, endpointName, operationName) => {

describe('ApiConsole', () => {
const asyncApi = 'async-api';
const grpcApi = 'grpc-test';
const multiServer = 'multi-server';
const apic553 = 'APIC-553';
const apic554 = 'APIC-554';
Expand Down Expand Up @@ -212,6 +213,55 @@ describe('ApiConsole', () => {
});
});

describe('gRPC API', () => {
[
new ApiDescribe('Regular model'),
new ApiDescribe('Compact model', true),
].forEach(({ label, compact }) => {
describe(label, () => {
let amf;
let element;

before(async () => {
amf = await AmfLoader.load({ compact, fileName: grpcApi, flattened: false });
});

beforeEach(async () => {
element = await amfFixture(amf);
await aTimeout(0);
});

it('should have _noTryItValue set to true for gRPC API', () => {
assert.isTrue(element._noTryItValue, '_noTryItValue should be true for gRPC API');
});

it('should detect gRPC API correctly', () => {
const isGrpc = element._isGrpcApi(amf);
assert.isTrue(isGrpc, 'Should detect gRPC API');
});

it('should hide try-it button when selecting a method', async () => {
const webApi = AmfLoader.lookupWebApi(amf);
const endpoints = element._computeEndpoints(webApi);
if (endpoints && endpoints.length > 0) {
const operations = element._computePropertyArray(
endpoints[0],
element.ns.aml.vocabularies.apiContract.supportedOperation
);
if (operations && operations.length > 0) {
element.selectedShape = operations[0]['@id'];
element.selectedShapeType = 'method';
await nextFrame();
await nextFrame();

assert.isTrue(element._noTryItValue, 'Try-it button should be hidden for gRPC API method');
}
}
});
});
});
});

describe('APIC-553', () => {
[
new ApiDescribe('Regular model'),
Expand Down