• Stars
    star
    894
  • Rank 51,071 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An interactive REST console based on RAML/OAS files

The API Console

MuleSoft's API Console is an enterprise grade API Documentation tool. This is an open source version of the console used in Anypoint Platform.

Published on NPM

Tests and publishing

Usage

For best developer experience use one of our tools to use the console in your project depending on your use case:

Version compatibility

As of version 6.0.0, API Console only works with AMF model version 2 (AMF parser >= 4.0.0). For compatibility use any previous version. Note that support for previous versions has been dropped and this is the only version with active development.

Preview and development

  1. Clone the element.
git clone https://github.com/mulesoft/api-console.git
cd api-console
  1. Install dependencies.
npm i
  1. Start local server.
npm start

Documentation

Full documentation is available at https://docs.api-console.io.

Use cases

Two basic use cases for API Console is:

  • standalone application - enables application, full window view
  • web component - lighter version, does not offer general layout and routing support

Stand-alone application

To use API Console as a stand-alone application use api-console-app element provided by api-console-app.js file. The stand-alone application supports routing and layout elements (compared to API Console as an element).

In this mode the console has title bar, drawer that holds the navigation, and main element that holds main scrolling region (the body is not a scrolling region in this case). It also enables mobile view when viewport width threshold is reached (740px). Wide view is enabled for viewport >= 1500px and includes request panel (try it) on the right hand side of currently rendered method.

Additionally the console application includes xhr-simple-request, oauth1-authorization, and oauth2-authorization components.

See demo/standalone/index.html for an example.

Web component

A web component offers rendering documentation view as a default view, on user request the request panel (when try it button is pressed), and contains an always hidden navigation that cannot be triggered from element's UI. The application that hosts the element must provide some kind of an UI for the user to trigger the navigation. Navigation can be opened by setting the navigationOpened property/attribute to true.

Because API console as a web component has no layout element you may want to control the height of the console. It should be set as specific value to properly support navigation drawer. Specific value can also be flex: 1 when flex layout is used.

The API Console element does not include xhr-simple-request, oauth1-authorization, or oauth2-authorization components. This components has to be added to the DOM separately. You can ignore this step when authorization and request events are handled by the hosting application. See full documentation for handling API Console events.

See demo/element/index.html for an example.

Working with AMF model

API console does not offer parsing API file(s) to the data model. This is done by the AMF parser provided by MuleSoft.

For both stand-alone application and the web component version of API console you must set AMF generated model on amf property of the console. The source can be direct result of parsing API spec file by the AMF parser or a JSON+ld model stored in a file. For a performance reasons the later is preferred.

<api-console></api-console>
<script>
{
  const model = await generateApiModel();
  const apic = document.querySelector('api-console');
  apic.amf = model;
  // reset selection
  apic.selectedShape = 'summary';
  apic.selectedShapeType = 'summary';
}
</script>

Styling API Console

Styles can be manipulated by creating a style sheet with CSS variables definition. Each component that has been used to build the console exposes own styling API.

API components ecosystem does not provide detailed documentation for styling API. Because of that when styling the console use Chrome DevTools to read name of a variable with default value to set in the style sheet.

See demo/themed/anypoint-theme.css and demo/themed/dark-theme.css files for an example of styled API Console.

Anypoint compatibility

API Console offers a compatibility property that enables (some) components to switch theme to Anypoint. All form controls in request panel, buttons, icon buttons, and lists are switched to compatibility view automatically when compatibility is set.

Note, that not all components support this property and therefore some styling adjustment may be needed. See demo/themed/anypoint-theme.css for an example of such style sheet.

Required dependencies

Note, the request panel won't run without this dependencies.

API Console bundler and the CLI tool bundles all dependencies into a vendor.js file and adds it to the final application.

Code mirror is not ES6 ready. Their build contains AMD exports which is incompatible with native modules. Therefore the dependencies cannot be imported with the element but outside of it. The component requires the following scripts to be ready before it's initialized (especially body and headers editors):

<script src="node_modules/jsonlint/lib/jsonlint.js"></script>
<script src="node_modules/codemirror/lib/codemirror.js"></script>
<script src="node_modules/codemirror/addon/mode/loadmode.js"></script>
<script src="node_modules/codemirror/mode/meta.js"></script>
<!-- Some basic syntax highlighting -->
<script src="node_modules/codemirror/mode/javascript/javascript.js"></script>
<script src="node_modules/codemirror/mode/xml/xml.js"></script>
<script src="node_modules/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="node_modules/codemirror/addon/lint/lint.js"></script>
<script src="node_modules/codemirror/addon/lint/json-lint.js"></script>

CodeMirror's modes location. May be skipped if all possible modes are already included into the app.

<script>
/* global CodeMirror */
CodeMirror.modeURL = 'node_modules/codemirror/mode/%N/%N.js';
</script>

You may want to add this dependencies to your build configuration to include it into the bundle.

Dependencies for OAuth1 and Digest authorization methods

For the same reasons as for CodeMirror this dependencies are required for OAuth1 and Digest authorization panels to work.

<script src="node_modules/cryptojslib/components/core.js"></script>
<script src="node_modules/cryptojslib/rollups/sha1.js"></script>
<script src="node_modules/cryptojslib/components/enc-base64-min.js"></script>
<script src="node_modules/cryptojslib/rollups/md5.js"></script>
<script src="node_modules/cryptojslib/rollups/hmac-sha1.js"></script>
<script src="node_modules/jsrsasign/lib/jsrsasign-rsa-min.js"></script>

More Repositories

1

api-designer

A web editor for creating and sharing RAML API specifications
JavaScript
1,067
star
2

osprey

Generate Node.JS API middleware from a RAML definition
JavaScript
431
star
3

mule

Mule Community Edition
Java
387
star
4

api-notebook

Interactive API notebook
JavaScript
154
star
5

mule-transport-amqp

Mule AMQP Transport
Java
33
star
6

mule-maven-plugin

Maven plugins for Mule Runtime
Java
33
star
7

mule-migration-assistant

Migration Framework
Java
24
star
8

docs-connectors

Documentation for connectors
22
star
9

docs-mule-runtime

19
star
10

api-policies

Java
18
star
11

mule-api

Java
18
star
12

osprey-cli

The Command Line Interface (CLI) scaffolding tool to generate Osprey-based applications, ideally from a pre-defined RAML API spec, with just a single command.
CoffeeScript
18
star
13

apikit

APIkit is a tool for building REST APIs using MULE Runtime
JavaScript
16
star
14

mule-esb-maven-tools

ESB Maven Tools
Java
15
star
15

mule-db-connector

Java
14
star
16

data-weave-io

Everything that is related to IO support for data weave: file, HTTP, OAS/RAML, GraphQL
DataWeave
12
star
17

mule-cookbook

A basic web service that users can use to learn the features provided by the DevKit and incrementally learn to develop Connectors
Java
11
star
18

mule-http-connector

Java
11
star
19

docs-runtime-manager

11
star
20

mule-extensions-archetype

Java
9
star
21

docs-runtime-fabric

9
star
22

docs-studio

8
star
23

mule-wsc-connector

Java
8
star
24

docs-general

8
star
25

docs-access-management

7
star
26

mule-distributions

Java
6
star
27

mule-common

Mule Metadata shared APIs
Java
6
star
28

git-connector

Mule Git Connector
Java
6
star
29

mule-extensions-parent

Parent POM for SDK based extensions which are not shipped in the Mule distribution
Shell
6
star
30

docs-design-center

6
star
31

docs-dataweave

DataWeave
6
star
32

docs-api-manager

6
star
33

docs-monitoring

5
star
34

mule-oauth-module

Java
5
star
35

mule-ftp-connector

Java
5
star
36

hbase-connector

HBase Connector
Java
5
star
37

docs-object-store

5
star
38

mule-file-commons

Java
5
star
39

linkedin-connector

LinkedIn is a business-related social networking site. Founded in December 2002 and launched in May 2003, it is mainly used for professional networking. This connector allows you to interact with LinkedIn API.
Java
5
star
40

mule-integration-tests

Java
4
star
41

docs-hosting

4
star
42

mule-wsdl-parser

A parser for WSDL files written in kotlin.
Kotlin
4
star
43

mule-extensions-api

Mule Extensions API
Java
4
star
44

mule-assembly-verifier-plugin

Maven Assembly Verifier for Mule Build
Groovy
4
star
45

facebook-connector

Facebook Cloud Connector
Java
4
star
46

api-sync-tool

Tool that synchronizes an API in API platform with local filesystem
JavaScript
4
star
47

mule-objectstore-connector

Java
4
star
48

docs-mq

Java
4
star
49

mule-tool-schema-doc

XSLT
3
star
50

mule-sockets-connector

Java
3
star
51

docs-mule-sdk

3
star
52

mule-xml-module

Java
3
star
53

google-drive-connector

Mule connector for Google Drive API
Java
3
star
54

google-calendar-connector

Mule connector for Google Calendar API
Java
3
star
55

mule-tooling-incubator

Mule Tooling Incubator Projects
Java
3
star
56

docs-munit

3
star
57

docs-anypoint-security

3
star
58

mule-amazon-s3-connector-crud-app-demo

HTML
3
star
59

docs-service-mesh

3
star
60

mule-jms-connector

Java
3
star
61

data-weave-jwt-library

DataWeave
3
star
62

apikit-rest-module

HTML
3
star
63

mule-scripting-module

Java
3
star
64

google-spreadsheets-connector

Mule connector for Google Spreadsheets API
Java
3
star
65

mule-vm-connector

Java
3
star
66

mule-email-connector

Java
3
star
67

docs-composer

3
star
68

apikit-odata-extension

Extension module that enables OData into APIkit rest
Java
3
star
69

mule-custom-properties-providers-module-example

Example of mule module for creating a custom properties provider
Java
3
star
70

docs-exchange

2
star
71

docs-apikit

RAML
2
star
72

docs-visualizer

2
star
73

apikit-rest-scaffolder

Java
2
star
74

docs-functional-monitoring

2
star
75

docs-site-ui

This project produces the UI bundles used by the MuleSoft documentation sites.
Handlebars
2
star
76

docs-partner-manager

2
star
77

docs-connector-devkit

Java
2
star
78

data-weave-mock-data-generators-library

DataWeave
2
star
79

mule-file-connector

Java
2
star
80

mule-validation-module

Java
2
star
81

mule-cookbook-connector

Mule Cookbook Example - Connector Only
Java
2
star
82

api-gateway-custom-policies-examples

2
star
83

data-weave-analytics-library

DataWeave
2
star
84

jira-connector

JIRA is a proprietary issue tracking product, developed by Atlassian, commonly used for bug tracking, issue tracking, and project management.
Java
2
star
85

mule-cookbook-tutorial

Anypoint Devkit Tutorial for the Cookbook Service
Java
2
star
86

hubspot-connector

HubSpot all-in-one marketing software helps more than 8,000 companies in 56 countries attract leads and convert them into customers. A pioneer in inbound marketing, HubSpot aims to help its customers make marketing that people actually love.
Java
2
star
87

docs-gov-cloud

2
star
88

mule-ce-services-parent

Shell
2
star
89

docs-gateway

2
star
90

mule-compression-module

Java
2
star
91

mule-tooling-mock-connector

Mule Tooling Mock Connector
Java
2
star
92

documentum-connector

Documentum is an enterprise content management platform. Documentum provides management capabilities for all types of content. The core of Documentum is a repository in which the content is stored securely under compliance rules and a unified environment, although content may reside on multiple servers and physical storage devices within a networked environment. Documentum provides a suite of services, such as document management, collaboration, search, content classification, input management, Business Process Management (BPM), customer communication management, and Web content management.
Java
2
star
93

mule-http-service

Java
2
star
94

mule-soap-service

Java
1
star
95

apikit-rest-metadata-api

Java
1
star
96

mule3-tutorial-connector

1
star
97

mule-json-module

Java
1
star
98

mule-servicenow-connector-operations-demo

HTML
1
star
99

mule-module-maven-plugin

Maven plugin to work with mule modules
Java
1
star
100

mule-spring-module

Java
1
star