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: initialize repository #2

Merged
merged 12 commits into from
Nov 29, 2021
3 changes: 1 addition & 2 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:
pull_request_review:
types:
- submitted

jobs:

autoapprove:
Expand Down Expand Up @@ -56,4 +55,4 @@ jobs:
env:
APPROVALS: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADD_LABEL: "autoapproved"
ADD_LABEL: "autoapproved"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.vscode
coverage
lib
*.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright The Linux Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<h5 align="center">
<br>
<a href="https://www.asyncapi.org"><img src="https://github.com/asyncapi/parser-nodejs/raw/master/assets/logo.png" alt="AsyncAPI logo" width="200"></a>
<br>
<em><b>Server API</b></em>
</h5>
<p align="center">
<em>Server API providing official AsyncAPI tools</em>
</p>

---

## :loudspeaker: ATTENTION:

This package is still under development and has not published and reached version 1.0.0 yet. This means that its API may contain breaking changes until we're able to deploy the first stable version and begin semantic versioning.

---

<!-- toc is generated with GitHub Actions do not remove toc markers -->
smoya marked this conversation as resolved.
Show resolved Hide resolved

<!-- toc -->

- [Requirements](#requirements)
- [Development](#development)
- [Contributing](#contributing)

<!-- tocstop -->

## Requirements

- [NodeJS](https://nodejs.org/en/) >= 14

## Development

1. Setup project by installing dependencies `npm install`
2. Write code and tests.
3. Make sure all tests pass `npm test`

## Contributing

Read [CONTRIBUTING](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md) guide.
magicmatatjahu marked this conversation as resolved.
Show resolved Hide resolved
132 changes: 132 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
openapi: 3.1.0

info:
version: 0.1.0
title: AsyncAPI Server API
description: Server API providing official AsyncAPI tools
contact:
name: AsyncAPI Initiative
email: [email protected]
url: https://asyncapi.com/
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html

servers:
- url: https://api.asyncapi.com/v1

paths:
/generator:
post:
summary: Generate the given AsyncAPI template.
operationId: generateTemplate
tags:
- generator
- template
externalDocs:
name: Website for the AsyncAPI Generator
url: https://www.asyncapi.com/tools/generator
requestBody:
description: Template details to be generated.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Template'
responses:
'200':
description: Template succesfully generated.
content:
application/json:
schema:
$ref: '#/components/schemas/Template'
'400':
description: Failed to generate the given template due to invalid AsyncAPI document.
content:
application/json:
schema:
$ref: '#/components/schemas/Problem'
'422':
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if this is the right code if someone gives the wrong body shape - e.g. not allowed template field or invalid AsyncAPI. Any thoughts?

Copy link
Member

@smoya smoya Oct 19, 2021

Choose a reason for hiding this comment

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

422 is used whenever the syntaxis is correct and understandable by your server, meaning the JSON or YAML is valid, but semantically it isn't, like your example of not allowed template field. So in this case, makes sense to me.

However, for the other example invalid AsyncAPI, 400 status code fits better since it will mean the syntaxis is wrong.

So I think we can add both status codes so we can differentiate the source of the errors.

description: Failed to generate the given template due to invalid parameters.
content:
application/json:
schema:
$ref: '#/components/schemas/Problem'
default:
description: Unexpected problem.
content:
application/json:
schema:
$ref: '#/components/schemas/Problem'

components:
schemas:
AsyncAPIDocument:
description: AsyncAPI document in JSON or YAML
type: # can be sent as normal JSON or stringified JSON/YAML
- string
- object
minLength: 1
minProperties: 1
additionalProperties: true
jonaslagoni marked this conversation as resolved.
Show resolved Hide resolved
Template:
type: object
required:
- asyncapi
- template
properties:
asyncapi:
$ref: '#/components/schemas/AsyncAPIDocument'
template:
type: string
description: Template name to be generated.
enum:
- 'html'
- 'markdown'
Comment on lines +79 to +84
Copy link
Member Author

Choose a reason for hiding this comment

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

In first iteration we will only support these two templates.

parameters:
magicmatatjahu marked this conversation as resolved.
Show resolved Hide resolved
type: object
description: |
Template parameters to be generated. Each template has different parameters that you should check in the documentation,
which is usually located in the template's repository.
This field is optional but may be required for some templates.
minProperties: 1
additionalProperties: true
Problem:
type: object
properties:
type:
type: string
format: uri
description: |
An absolute URI that identifies the problem type. When dereferenced,
it SHOULD provide human-readable documentation for the problem type
(e.g., using HTML).
default: 'about:blank'
example: 'https://api.asyncapi.com/problem/invalid-template-parameters'
title:
type: string
description: |
A short, summary of the problem type. Written in english and readable.
example: Invalid AsyncAPI document.
status:
type: integer
format: int32
description: |
The HTTP status code generated by the origin server for this occurrence
of the problem.
minimum: 100
maximum: 600
exclusiveMaximum: true
example: 422
detail:
type: string
description: |
A human readable explanation specific to this occurrence of the problem.
example: Connection to database timed out
instance:
type: string
format: uri
description: |
An absolute URI that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.
additionalProperties: true
Loading