Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up and simplification #112

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
122 changes: 8 additions & 114 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,145 +1,39 @@
# Extensions catalog

This is a placeholder for definitions of AsyncAPI specification extensions and bindings objects.
This is a placeholder for definitions of AsyncAPI specification extensions.

#### Index:

<!-- TOC depthFrom:2 depthTo:2 -->

- [What's an extension?](#whats-an-extension)
- [Examples of extension definition](#examples-of-extension-definition)
- [Types of extensions](#types-of-extensions)
- [Usage in an AsyncAPI document](#usage-in-an-AsyncAPI-document)
- [Twitter Extension](./extensions/twitter/)
- [Adding your extension to the catalog](#adding-your-extension-to-the-catalog)
- [Questions?](#questions)

<!-- /TOC -->

## What's an extension?
## What's an extension?

Extensions are the mechanism AsyncAPI has to allow you use custom or protocol-specific features. Extensions follow a separate release cycle and everyone can create their own. This repository is meant to contain a list of official and community supported extensions.

## Examples of extension definition

> Both, JSON or YAML, are supported formats. Please, take into account that only the subset of YAML that can be translated to JSON is allowed.

### Twitter

This is the definition of a generic extension that allows you to add information about your team/company Twitter account.

```yaml
id: twitter
type: generic # Means it's an "x-" type of extension. In this case, x-twitter.
title: Twitter information
description: This extension allows you to place the Twitter account of the team/company in charge of the API.
version: '0.1.0'
author: Mike Ralphson
contributors:
- Fran Mendez <fmvilas@gmail.com> (fmvilas.com)
definitions:
- hooks:
- 'info' # JMESPath query to indicate where this extension is allowed in the AsyncAPI document. In this case, it's only allowed in the "info" object.
schema:
type: string
pattern: '^@?(\\w){1,15}$'
examples:
- example: '@PermittedSoc'
```

#### Usage in an AsyncAPI document

```yaml
asyncapi: '2.0.0'
info:
title: My wonderful API
version: '12.4.2'
x-twitter: '@wonderapi'
...
```

### HTTP Binding

This is the example definition of an HTTP bindings extension.

```yaml
id: http
type: bindings # Means it's a "bindings" type of extension.
title: HTTP Binding Extension
description: This object allows you to define HTTP-specific details in AsyncAPI.
version: '0.1.0'
author: Fran Mendez <fmvilas@gmail.com> (fmvilas.com)
definitions:
- hooks: # JMESPath queries to indicate where this extension is allowed in the AsyncAPI document. In this case, it's allowed in all the operation (publish/subscribe) objects.
- 'channels.*.subscribe'
- 'channels.*.publish'
schema: # This is the schema that validates the extension content. It's in JSON Schema Draft 07.
type: object
required:
- version
properties:
version:
type: string
const: '0.1.0' # It's a good idea to specify what version of the extension are you using. It will facilitate things to tooling and will allow you to have different versions of the same extension in a single document.
response:
type: object
additionalProperties: false
properties:
headers:
type: object
additionalProperties: true
propertyNames:
type: string
pattern: '^[a-zA-Z0-9\\.\\-_]+$'
request:
type: object
additionalProperties: false
properties:
headers:
type: object
additionalProperties: true
propertyNames:
type: string
pattern: '^[a-zA-Z0-9\\.\\-_]+$'
examples:
- description: Usage for HTTP streaming APIs.
example:
http:
version: '0.1.0'
response:
headers:
Transfer-Encoding: chunked
Trailer: '\\r\\n'
```


#### Usage in an AsyncAPI document
AsyncAPI extensions are those that are preceeded by `x-`, e.g., `x-twitter`, and they can be placed anywhere in the AsyncAPI document.

```yaml
asyncapi: '2.0.0'
...
channels:
/tweets:
subscribe:
bindings:
http:
version: '0.1.0'
response:
headers:
Transfer-Encoding: chunked
Trailer: '\\r\\n'
...
```

## Types of extensions

Extensions can be of type `generic` or `bindings`.

Generic extensions are those that are preceeded by `x-`, e.g., `x-twitter`, and they can be placed anywhere in the AsyncAPI document.

Bindings extensions are those that live inside a `bindings` object and are related to protocol-specific functionality or characteristics. E.g., `http`, `kafka`, `amqp`, etc. As opposed to generic extensions, these can only be applied in a very limited set of places, namely, where the `bindings` is allowed, i.e., a channel object, an operation object or a message object.

## Adding your extension to the catalog

If you'd like to add your extension to the catalog, please submit a pull request to this repository. Make sure the extension doesn't exist already, in which case it would be better to improve the existing one so everybody benefits from it.



## Questions?

If you have questions, please submit an issue to this repository or [join our Slack workspace](https://join.slack.com/t/asyncapi/shared_invite/enQtNDY3MzI0NjU5OTQyLWU4ZGU2MTg1MDIyZDFjMTI2YjkxYTdlMzc1NjgzYTAxZDM1YTg1NDhhMTE2NDliMjlhZjYxNzk0ZTE5ZGU1ZTg).
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

47 changes: 0 additions & 47 deletions extensions/http/0.1.0.yaml

This file was deleted.

117 changes: 0 additions & 117 deletions extensions/sqs/0.1.0.yml

This file was deleted.

16 changes: 0 additions & 16 deletions extensions/twitter/0.1.0.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions extensions/twitter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Twitter extension
This document defines how to describe twitter extension on AsyncAPI.

## Twitter Object
The twitter object must contains :

Field Name | Type | Description
---|:---:|---
<a name="extensionId"></a>`id` | string | **Required**. Id of the extension.
<a name="extensionTitle"></a>`title` | string |**Required**. The title of the extension.
<a name="extensionDescription"></a>`description` |string| The description of the twitter extension.
<a name="extnesionPayload"></a>`payload` | Json Object |**Required**. A JSON object containing the detail of the twitter account.
Comment on lines +9 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<a name="extensionId"></a>`id` | string | **Required**. Id of the extension.
<a name="extensionTitle"></a>`title` | string |**Required**. The title of the extension.
<a name="extensionDescription"></a>`description` |string| The description of the twitter extension.
<a name="extnesionPayload"></a>`payload` | Json Object |**Required**. A JSON object containing the detail of the twitter account.
<a name="extensionId"></a>`id` | string | **Required**. Id of the extension.
<a name="extensionTitle"></a>`title` | string |**Required**. The title of the extension.
<a name="extensionDescription"></a>`description` |string| The description of the Twitter extension.
<a name="extensionPayload"></a>`payload` | Json Object |**Required**. A JSON object containing the detail of the Twitter account.

Comment on lines +9 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we simply merge this object with the payload one? We could just add schema and examples right into this object.




<a name="payloadObject"></a>
## Payload Object
Field Name | Type | Description
---|:---:|---
<a name="extensionSchema"></a>`schema` | Schema Object |**Required**. A Schama object containing the detail of the twitter account. | **Required** The schema of the twitter account. We provide the pattern and the thpe of the payload.
<a name="extensionExamples"></a>`examples` | string |**Required**. An array of examples.


## Example

```yaml
id: twitter
title: Twitter information
description: This extension allows you to place the Twitter account of the team/company in charge of the API.
payload:
schema:
type: string
pattern: '^@?(\\w){1,15}$'
examples:
- example: '@PermittedSoc'
```
Loading