Skip to content

Commit

Permalink
refactor: remove streetlight example for testing (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored May 28, 2020
1 parent e6525dc commit 891c680
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 216 deletions.
5 changes: 5 additions & 0 deletions docs/authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

The AsyncAPI generator has been built with extensibility in mind. The package uses a set of default templates to let you generate documentation and code. However, you can create and use your own templates. In this section, you learn how to create your own one.

To work on a template, you need an AsyncAPI specification file that you can use for testing. For this purpose, you can use [this](test/docs/dummy.yml) dummy file as it's purpose is to cover as many features of AsyncAPI as possible. Do not copy this file to your template but use it directly from this repo like this: `ag https://raw.githubusercontent.com/asyncapi/generator/master/test/docs/dummy.yml ./your-template`

> In case you find some features missing or other possible improvements in the dummy file, suggest changes. The goal is to build a file that all templates can use and check their specification features coverage.
## Common assumptions

1. A template is a directory in your file system.
Expand All @@ -17,6 +21,7 @@ The AsyncAPI generator has been built with extensibility in mind. The package us
- `asyncapi` that is a parsed spec file object. Read the [API](https://github.com/asyncapi/parser-js/blob/master/API.md#AsyncAPIDocument) of the Parser to understand to what structure you have access in this parameter.
- `originalAsyncAPI` that is an original spec file before it is parsed.
- `params` that contains the parameters provided when generating.

## File templates

It is possible to generate files for each specific object in your AsyncAPI documentation.
Expand Down
247 changes: 247 additions & 0 deletions test/docs/dummy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
asyncapi: '2.0.0'

externalDocs:
description: Find more info here
url: https://www.asyncapi.com

info:
title: Dummy example with all spec features included
version: '0.0.1'
description: |
This is an example of AsyncAPI specification file that is suppose to include all possible features of the AsyncAPI specification. Do not use it on production.
It's goal is to support development of documentation and code generation with the [AsyncAPI Generator](https://github.com/asyncapi/generator/) and [Template projects](https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate)
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
contact:
name: API Support
url: http://www.asyncapi.com/support
email: [email protected]
x-twitter: '@AsyncAPISpec'

tags:
- name: root-tag1
externalDocs:
description: External docs description 1
url: https://www.asyncapi.com/
- name: root-tag2
description: Description 2
externalDocs:
url: "https://www.asyncapi.com/"
- name: root-tag3
- name: root-tag4
description: Description 4
- name: root-tag5
externalDocs:
url: "https://www.asyncapi.com/"

servers:
dummy-mqtt:
url: mqtt://localhost
protocol: mqtt
description: dummy MQTT broker
bindings:
mqtt:
clientId: guest
cleanSession: true
dummy-amqp:
url: amqp://localhost:{port}
protocol: amqp
description: dummy AMQP broker
protocolVersion: "0.9.1"
variables:
port:
enum:
- '15672'
- '5672'
security:
- user-password: []
dommy-kafka:
url: http://localhost:{port}
protocol: kafka
description: dummy Kafka broker
variables:
port:
default: '9092'

defaultContentType: application/json

channels:
dummy/channel/with/{dummy}/parameter/create:
description: Dummy channel description.
parameters:
dummy:
$ref: '#/components/parameters/dummy'
publish:
summary: Inform whenever something dummy is created.
description: |
Longer description.
Still dummy though.
operationId: receiveNewDummyInfo
tags:
- name: oparation-tag1
externalDocs:
description: External docs description 1
url: https://www.asyncapi.com/
- name: oparation-tag2
description: Description 2
externalDocs:
url: "https://www.asyncapi.com/"
- name: oparation-tag3
- name: oparation-tag4
description: Description 4
- name: oparation-tag5
externalDocs:
url: "https://www.asyncapi.com/"
traits:
- $ref: '#/components/operationTraits/kafka'
message:
$ref: '#/components/messages/dummyCreated'

dummy/channel/without/parameter:
bindings:
amqp:
is: routingKey
subscribe:
operationId: receiveSystemInfo
message:
$ref: '#/components/messages/dummyInfo'

components:
messages:
dummyCreated:
name: dummyCreated
title: Dummy created message
summary: This is just a dummy create message
tags:
- name: message-tag1
externalDocs:
description: External docs description 1
url: https://www.asyncapi.com/
- name: message-tag2
description: Description 2
externalDocs:
url: "https://www.asyncapi.com/"
- name: message-tag3
- name: message-tag4
description: Description 4
- name: message-tag5
externalDocs:
url: "https://www.asyncapi.com/"
headers:
type: object
properties:
my-custom-app-header:
type: string
payload:
$ref: "#/components/schemas/dummyCreated"
dummyInfo:
name: dummyInfo
title: Dummy system info
summary: This is just a dummy info message
description: |
More description for a dummy message.
It is a dummy system info message.
traits:
- $ref: '#/components/messageTraits/commonHeaders'
payload:
$ref: "#/components/schemas/dummyInfo"
examples:
- one:
prop1: option1
sentAt: 2020-01-26T13:00:00Z
- two:
prop1: option1
sentAt: 2020-01-31T13:24:53Z

schemas:
dummyCreated:
type: object
properties:
prop1:
type: integer
minimum: 0
description: Dummy prop1
prop2:
type: string
description: Dummy prop2
sentAt:
$ref: "#/components/schemas/sentAt"
additionalProperties: false
dummyInfo:
type: object
properties:
prop1:
type: string
enum:
- option1
- option2
description: Dummy prop1
sentAt:
$ref: "#/components/schemas/sentAt"
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.

securitySchemes:
user-password:
type: userPassword
apiKey:
type: apiKey
in: user
description: Provide your API key as the user and leave the password empty.
supportedOauthFlows:
type: oauth2
description: Flows to support OAuth 2.0
flows:
implicit:
authorizationUrl: 'https://authserver.example/auth'
scopes:
'dummy:created': Ability to create dummy message
'dymmy:read': Ability to read dummy info
password:
tokenUrl: 'https://authserver.example/token'
scopes:
'dummy:created': Ability to create dummy message
'dymmy:read': Ability to read dummy info
clientCredentials:
tokenUrl: 'https://authserver.example/token'
scopes:
'dummy:created': Ability to create dummy message
'dymmy:read': Ability to read dummy info
authorizationCode:
authorizationUrl: 'https://authserver.example/auth'
tokenUrl: 'https://authserver.example/token'
refreshUrl: 'https://authserver.example/refresh'
scopes:
'dummy:created': Ability to create dummy message
'dymmy:read': Ability to read dummy info
openIdConnectWellKnown:
type: openIdConnect
openIdConnectUrl: 'https://authserver.example/.well-known'

parameters:
dummy:
description: The ID of the new dummy message.
schema:
type: string

messageTraits:
commonHeaders:
headers:
type: object
properties:
my-app-header:
type: integer
minimum: 0
maximum: 100

operationTraits:
kafka:
bindings:
kafka:
clientId: my-app-id
Loading

0 comments on commit 891c680

Please sign in to comment.