• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 2 months ago

Reviews

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

Repository Details

React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue

AsyncAPI React Component

React component for AsyncAPI 2.0 specification. Available also as a Web Component.


⚠️ We are in the process of rewriting the component under the next branch. The current version 0.X.X is in the maintenance mode, we are focusing mainly on the next branch. Check out releases with next suffix in the release tag or the next tag on NPM.


All Contributors npm npm

Overview

A official React component for AsyncAPI 2.0 specification. It allows you to render the documentation of your asynchronous API provided in the AsyncAPI specification format and validate this specification. You can fully restyle the component using your own styles.

CAUTION: This package only supports AsyncAPI 2.0 specification. If you use 1.x, we recommend that you upgrade to the latest AsyncAPI version using the Node.js or Go converters.

Prerequisites

  • react (version 16.8.0 or higher)

Installation

Run this command to install the component in your project:

npm install --save @asyncapi/react-component

Check out this simple sandbox application that uses the React component:

Edit asyncapi-react-component-in-action

Props

The list of props for the AsyncAPI React component includes:

  • schema: string | AsyncApiInterface | FetchingSchemaInterface

    The schema property is required and contains AsyncAPI specification. Use the string type, the AsyncApiInterface type, or the FetchingSchemaInterface object to fetch the schema from an external resource. For more information on what it contains and what it should look like, read AsyncAPI Specification.

  • config?: Partial<ConfigInterface>

    The config property is optional and contains configuration for the AsyncAPI component. For more information on the available configuration options, read the Configuration Modification document. This property is concatenated with the default configuration.

    NOTE: The Partial<T> type means that every field in the T type is optional.

Features

For a list and description of features offered by the AsyncAPI React component, see this directory.

Styles

To use default styles import them as follows:

import "@asyncapi/react-component/lib/styles/fiori.css";

For information on how to change styles, read the Style Modification document.

Playground

This repository comes in with a Playground application. Test it to see the component in action and play with it before you use it in your application.

You can also run the Playground application locally by following this instruction from the development guide.

Web Component

If you are not using React you may want to use the @asyncapi/web-component component as a plain web component in any other web framework of your choice or as an element of a static HTML webpage. This is achieved by making use of web-react-components.

When invoked as an independent entity, Web Component takes the following props (as it is still a React component):

  • schema is a schema property from the React component,

    NOTE: Since version 0.19.0 specifying a schema object can be omitted. schema.url and schema.requestOptions can be replaced with schemaUrl and schemaFetchOptions properties accordingly.

  • config is an optional config property from the React component,
  • schemaUrl property is a string, specific to Web Component, containing a URL to fetch an AsyncAPI Schema from. It is a wrapper for schema.url property in schema object under the hood,

    NOTE: If schemaUrl property is specified, the schema.url property of the React component will be ignored.

  • schemaFetchOptions property is an optional object of RequestInit type in JSON format, specific to Web Component, containing additional fetching options. It is a wrapper for schema.requestOptions property in schema object, which are both needed only in case process of fetching from a URL is any different from a usual browser request,

    NOTE: If schemaFetchOptions property is specified, schema.requestOptions property of the React component will be ignored. If schemaUrl property is NOT specified, schemaFetchOptions will be ignored itself and schema.url/schema.requestOptions properties of the React component must be used in this case.

  • cssImportPath property is the path to styles. Default version from unpkg.com contains guaranteed minimum styling for the Web Component,
  • webcomponentsjs is a series of polyfills to make code runnable in old browsers. It is optional if you do not intend to support any.
<!-- Remove 'webcomponentsjs' if no support for older browsers is required -->
<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js"></script>
<script src="https://unpkg.com/@asyncapi/[email protected]/lib/asyncapi-web-component.js" defer></script>

<asyncapi-component
  schemaUrl="https://raw.githubusercontent.com/asyncapi/asyncapi/master/examples/2.0.0/streetlights.yml"
  schemaFetchOptions='{"method":"GET","mode":"cors"}' <!-- Remove if it is only a plain browser request -->
  cssImportPath="https://unpkg.com/@asyncapi/[email protected]/lib/styles/fiori.css">
</asyncapi-component>

NOTE: If a Web Component is called with no properties at all, error will be shown on page.

NOTE: If there are several Web Components on one page, each one will be rendered using its own properties.

Installation

Run this command to install the component in your project:

npm install --save @asyncapi/web-component

Check out this simple sandbox application that uses the Web Component in Angular project:

Edit asyncapi-web-component-in-action

Using in Angular

To use component in Angular, follow these steps:

  1. Update AppModule by adding the CUSTOM_ELEMENTS_SCHEMA to the schemas array in the NgModule metadata:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@NgModule({
  ...
  schemas: [
    CUSTOM_ELEMENTS_SCHEMA,
  ]
})
export class AppModule {}
  1. Import the @asyncapi/web-component module in an Angular's component where you want to use the web component:
import { Component } from '@angular/core';
import '@asyncapi/web-component/lib/asyncapi-web-component';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ...
}
  1. Use web component in the template as follows:
<asyncapi-component
  [schema]="schema"
  [config]="config"
  [schemaUrl]="schemaUrl"
  [schemaFetchOptions]="schemaFetchOptions"
  [cssImportPath]="cssImportPath">
</asyncapi-component>

where:

  • schema, config, schemaUrl, schemaFetchOptions are Web Component's properties used in any valid combination, as described in Web Component specification,
  • cssImportPath is the path to styles. By default it is assets/asyncapi.css

NOTE: The easiest way to use the default css is to copy the content of the @asyncapi/react-component/lib/styles/fiori.css file to a assets/asyncapi.css file.

Development

For information on how to set up a development environment, write and run tests, follow the naming and architecture convention defined for the project in the Development Guide.

Contribution

If you have a feature request, add it as an issue or propose changes in a pull request (PR). If you create a feature request, use the dedicated Feature request issue template. When you create a PR, follow the contributing rules described in the CONTRIBUTING.md document.

If you have a bug to report, reproduce it in an online code editor. For example, use CodeSandbox. Attach the link to the reproduced bug to your issue. Log the bug using the Bug report template.

Missing features

See the list of features that are still missing in the component:

If you want to help us develop them, feel free to contribute.

Credits

Contributors

Thanks goes to these wonderful people (emoji key):


Maciej UrbaΕ„czyk

πŸ’» πŸ“– πŸ€” 🚧 πŸ‘€ ⚠️ πŸš‡ πŸ› πŸ’‘

Karolina Zydek

πŸ“– πŸ‘€ 🚧

Agata

πŸ’» 🚧

Lukasz Gornicki

πŸ“– πŸ’‘ πŸ€” πŸ’» πŸš‡ πŸ› πŸ“ 🚧

Mateusz PuczyΕ„ski

πŸ’» πŸ“– πŸ€” 🚧 πŸ‘€ ⚠️

Hesyar Uzuner

πŸ› πŸ’»

Marcus Ilgner

πŸ› πŸ’»

Dominik Henneke

πŸ’»

Oliver Sand

πŸ’»

Jakub Iwanowski

πŸ’»

depimomo

⚠️

Sanskar Patro

πŸ’»

danielchu

πŸš‡

Fran MΓ©ndez

πŸ’» 🚧

Claude Gex

πŸ’» πŸ“¦ πŸ€”

c-pius

πŸ’» πŸ›

Viacheslav Turovskyi

πŸ“– πŸ’»

195858

πŸ’»

Aayush Kumar Sahu

πŸ’»

Dale Lane

πŸ’» πŸ€”

Michal Gornicki

πŸ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

spec

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
JavaScript
4,215
star
2

generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
JavaScript
758
star
3

website

AsyncAPI specification website
TypeScript
453
star
4

modelina

A library for generating typed models based on inputs such as AsyncAPI, OpenAPI, and JSON Schema documents with high customization
TypeScript
312
star
5

cli

CLI to work with your AsyncAPI files. You can validate them and in the future use a generator and even bootstrap a new file. Contributions are welcomed!
TypeScript
184
star
6

studio

Visually design your AsyncAPI files and event-driven architecture.
TypeScript
167
star
7

saunter

Saunter is a code-first AsyncAPI documentation generator for dotnet.
C#
145
star
8

parser-js

AsyncAPI parser for Javascript (browser-compatible too).
TypeScript
116
star
9

community

AsyncAPI community-related stuff.
98
star
10

glee

Glee β€” The AsyncAPI framework that will make you smile again :)
TypeScript
88
star
11

bindings

AsyncAPI bindings specifications
71
star
12

jasyncapi

/jay-sync-api/ is a Java code-first tool for AsyncAPI specification
Kotlin
67
star
13

java-spring-template

Java Spring template for the AsyncAPI Generator
Java
66
star
14

html-template

HTML template for AsyncAPI Generator. Use it to generate a static docs. It is using AsyncAPI React component under the hood.
JavaScript
63
star
15

parser-go

It parses AsyncAPI documents.
Go
55
star
16

spec-json-schemas

AsyncAPI schema versions
JavaScript
54
star
17

github-action-for-cli

GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
Shell
46
star
18

go-watermill-template

Go template for the AsyncAPI Generator using Watermill module
JavaScript
46
star
19

nodejs-template

This template generates a server using your AsyncAPI document. It supports multiple different protocols, like Kafka or MQTT. It is designed in the way that generated code is a library and with it's API you can start the server, send messages or register a middleware for listening incoming messages. Runtime message validation included.
JavaScript
40
star
20

java-spring-cloud-stream-template

Java Spring Cloud Stream template for the AsyncAPI Generator
JavaScript
31
star
21

avro-schema-parser

An AsyncAPI schema parser for Avro 1.x schemas.
TypeScript
31
star
22

bundler

Combine multiple AsyncAPI specification files into one.
TypeScript
30
star
23

.github

Location of all reusable community health files
29
star
24

vs-asyncapi-preview

VSCode AsyncAPI Preview Extension
TypeScript
28
star
25

server-api

Server API providing official AsyncAPI tools
TypeScript
26
star
26

markdown-template

Markdown template for the AsyncAPI Generator
JavaScript
26
star
27

diff

Diff is a library that compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly information like breaking changes.
TypeScript
26
star
28

python-paho-template

Python Paho template for the AsyncAPI generator
JavaScript
25
star
29

nodejs-ws-template

Node.js WebSockets template for the AsyncAPI Generator. It showcases how from a single AsyncAPI document you can generate a server and a client at the same time.
JavaScript
23
star
30

conference-website

Website for the AsyncAPI online conference
JavaScript
23
star
31

ts-nats-template

Node.js/Typescript template for NATS
JavaScript
21
star
32

converter-go

Convert AsyncAPI documents from older to newer versions with Golang
Go
20
star
33

generator-react-sdk

Generator React SDK enabling the AsyncAPI generator to support React as the rendering engine for templates.
TypeScript
19
star
34

dotnet-nats-template

.NET template for NATS
JavaScript
18
star
35

converter-js

Convert to or migrate between AsyncAPI versions with the converter
TypeScript
18
star
36

template-for-generator-templates

This is a GitHub repository template for generator templates to make it much easier to start writing your own generator template.
JavaScript
18
star
37

simulator

Asynchronous traffic simulation application using async-api
TypeScript
16
star
38

EDAVisualiser

View your system, events, applications through different perspectives
TypeScript
15
star
39

optimizer

AsyncAPI offers many different ways to reuse certain parts of the document like messages or schemas definitions or references to external files, not to even mention the traits. There is a need for a tool that can be plugged into any workflows and optimize documents that are generated from code, but not only.
TypeScript
14
star
40

tck

(WIP) Test Compatibility Suite for AsyncAPI
Java
13
star
41

chatbot

The project's aim is to develop a chatbot that can help people create spec documents without knowing the specification.To get started with, the bot will consume the spec, JSON schema and serves the user as an expert. So based on a set of questions and answers it will generate an AsyncApi spec document according to the use cases.
JavaScript
12
star
42

openapi-schema-parser

An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.
TypeScript
12
star
43

extensions-catalog

Catalog of extensions for AsyncAPI specification
11
star
44

shape-up-process

This repo contains pitches and the current cycle bets. More info about the Shape Up process: https://basecamp.com/shapeup
JavaScript
11
star
45

java-template

Java template for the AsyncAPI Generator
JavaScript
10
star
46

jasyncapi-idea-plugin

/jay-sync-api/-idea-plugin is a IDEA plugin for AsyncAPI specification
Kotlin
10
star
47

dotnet-rabbitmq-template

This template is for generating a .NET C# wrapper for the RabbitMQ client based on your AsyncAPI document.
JavaScript
10
star
48

brand

AsyncAPI brand guidelines and strategy
8
star
49

parser-api

Global API definition for all AsyncAPI Parser implementations.
8
star
50

problem

Library that implements the Problem interface. Reference https://www.rfc-editor.org/rfc/rfc7807
TypeScript
7
star
51

php-template

PHP Template for AsyncAPI generator
PHP
7
star
52

training

All about trainings, workshops, courses, etc.
6
star
53

raml-dt-schema-parser

AsyncAPI schema parser for RAML data types
TypeScript
5
star
54

enterprise-patterns

Enterprise patterns using AsyncAPI
4
star
55

protobuf-schema-parser

Schema parser for Protobuf compatible with AsyncAPI JS Parser
TypeScript
4
star
56

template-for-go-projects

This is a repository template for golang projects
Makefile
2
star
57

generator-filters

Library with reusable generator filters that you can use in your templates
JavaScript
2
star
58

generator-hooks

Library with reusable generator hooks that you can use in your templates
JavaScript
1
star