Skip to content

Commit 3039448

Browse files
authored
feat!: split out definitions (#128)
1 parent 53c76a8 commit 3039448

File tree

377 files changed

+25597
-10695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+25597
-10695
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
.nyc_output
33
.vscode
4-
coverage
4+
coverage

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
![npm](https://img.shields.io/npm/v/@asyncapi/specs?style=for-the-badge) ![npm](https://img.shields.io/npm/dt/@asyncapi/specs?style=for-the-badge)
22

3+
> If you are currently using version 2, check out [migration guideline to version 3](./migrations/Migrate%20to%20version%203.md). You might be able to update it without any change.
34
# AsyncAPI
45

5-
This package provides all the versions of the AsyncAPI schema.
6+
This is a mono repository, which provides all the JSON Schema documents for validating AsyncAPI documents.
67

78
## Installation
89

@@ -37,3 +38,28 @@ const asyncapi = versions['1.1.0'];
3738

3839
// Do something with the schema.
3940
```
41+
42+
## Repository structure
43+
This is the current project structure explained.
44+
- [./definitions](./definitions) - contain all the individual schemas that will automatically be bundled together to provide the schemas in [./schemas](./schemas).
45+
- [./tools/bundler](./tools/bundler) - is the tool that bundles all the individual schemas together.
46+
- [./schemas](./schemas) - contain all automatically bundled and complete schemas for each AsyncAPI version. These schemas should **NOT** be manually changed as they are automatically generated. Any changes should be done in [./definitions](./definitions).
47+
48+
## Schema Bundling
49+
Changes should not be done manually to the schemas in [./schemas](./schemas), but instead be done in their individual definitions located in [./definitions](./definitions).
50+
51+
These definitions are automatically bundled together on new releases through the npm script `prepublishOnly`, which ensures the project is build. This is where the [bundler](./tools/bundler) is called.
52+
53+
For example, for [2.2.0](./definitions/2.2.0), the [bundler](./tools/bundler/index.js) starts with the [asyncapi.json](definitions/2.2.0/asyncapi.json) file and recursively goes through all references (`$ref`) to create the [appropriate bundled version](./schemas/2.2.0.json).
54+
55+
### Creating a new version
56+
To create a new version, simply run the following command:
57+
```
58+
npm run startNewVersion --new-version=x.x.x
59+
```
60+
Where `x.x.x` is the new version you want to create.
61+
62+
The manual process of creating a new version is to:
63+
1. Duplicate the latest version (`y.y.y`) under definitions (so we have the correct base to make changes from).
64+
2. Rename the folder to the new version (`x.x.x`).
65+
3. Search and replace in the new duplicated folder for `y.y.y` and replace it with `x.x.x`.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"type": "object",
3+
"required": [
4+
"type",
5+
"name",
6+
"in"
7+
],
8+
"properties": {
9+
"type": {
10+
"type": "string",
11+
"enum": [
12+
"httpApiKey"
13+
]
14+
},
15+
"name": {
16+
"type": "string"
17+
},
18+
"in": {
19+
"type": "string",
20+
"enum": [
21+
"header",
22+
"query",
23+
"cookie"
24+
]
25+
},
26+
"description": {
27+
"type": "string"
28+
}
29+
},
30+
"patternProperties": {
31+
"^x-": {}
32+
},
33+
"additionalProperties": false,
34+
"$schema": "http://json-schema.org/draft-04/schema#",
35+
"id": "http://asyncapi.com/definitions/1.0.0/APIKeyHTTPSecurityScheme.json"
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"type": "object",
3+
"required": [
4+
"type",
5+
"scheme"
6+
],
7+
"properties": {
8+
"scheme": {
9+
"type": "string",
10+
"enum": [
11+
"bearer"
12+
]
13+
},
14+
"bearerFormat": {
15+
"type": "string"
16+
},
17+
"type": {
18+
"type": "string",
19+
"enum": [
20+
"http"
21+
]
22+
},
23+
"description": {
24+
"type": "string"
25+
}
26+
},
27+
"patternProperties": {
28+
"^x-": {}
29+
},
30+
"additionalProperties": false,
31+
"$schema": "http://json-schema.org/draft-04/schema#",
32+
"id": "http://asyncapi.com/definitions/1.0.0/BearerHTTPSecurityScheme.json"
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"oneOf": [
3+
{
4+
"$ref": "http://asyncapi.com/definitions/1.0.0/NonBearerHTTPSecurityScheme.json"
5+
},
6+
{
7+
"$ref": "http://asyncapi.com/definitions/1.0.0/BearerHTTPSecurityScheme.json"
8+
},
9+
{
10+
"$ref": "http://asyncapi.com/definitions/1.0.0/APIKeyHTTPSecurityScheme.json"
11+
}
12+
],
13+
"$schema": "http://json-schema.org/draft-04/schema#",
14+
"id": "http://asyncapi.com/definitions/1.0.0/HTTPSecurityScheme.json"
15+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"not": {
3+
"type": "object",
4+
"properties": {
5+
"scheme": {
6+
"type": "string",
7+
"enum": [
8+
"bearer"
9+
]
10+
}
11+
}
12+
},
13+
"type": "object",
14+
"required": [
15+
"scheme",
16+
"type"
17+
],
18+
"properties": {
19+
"scheme": {
20+
"type": "string"
21+
},
22+
"description": {
23+
"type": "string"
24+
},
25+
"type": {
26+
"type": "string",
27+
"enum": [
28+
"http"
29+
]
30+
}
31+
},
32+
"patternProperties": {
33+
"^x-": {}
34+
},
35+
"additionalProperties": false,
36+
"$schema": "http://json-schema.org/draft-04/schema#",
37+
"id": "http://asyncapi.com/definitions/1.0.0/NonBearerHTTPSecurityScheme.json"
38+
}

definitions/1.0.0/Reference.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"type": "object",
3+
"required": [
4+
"$ref"
5+
],
6+
"properties": {
7+
"$ref": {
8+
"type": "string",
9+
"format": "uri"
10+
}
11+
},
12+
"$schema": "http://json-schema.org/draft-04/schema#",
13+
"id": "http://asyncapi.com/definitions/1.0.0/Reference.json"
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"type": "object",
3+
"additionalProperties": {
4+
"type": "array",
5+
"items": {
6+
"type": "string"
7+
}
8+
},
9+
"$schema": "http://json-schema.org/draft-04/schema#",
10+
"id": "http://asyncapi.com/definitions/1.0.0/SecurityRequirement.json"
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"oneOf": [
3+
{
4+
"$ref": "http://asyncapi.com/definitions/1.0.0/userPassword.json"
5+
},
6+
{
7+
"$ref": "http://asyncapi.com/definitions/1.0.0/apiKey.json"
8+
},
9+
{
10+
"$ref": "http://asyncapi.com/definitions/1.0.0/X509.json"
11+
},
12+
{
13+
"$ref": "http://asyncapi.com/definitions/1.0.0/symmetricEncryption.json"
14+
},
15+
{
16+
"$ref": "http://asyncapi.com/definitions/1.0.0/asymmetricEncryption.json"
17+
},
18+
{
19+
"$ref": "http://asyncapi.com/definitions/1.0.0/HTTPSecurityScheme.json"
20+
}
21+
],
22+
"$schema": "http://json-schema.org/draft-04/schema#",
23+
"id": "http://asyncapi.com/definitions/1.0.0/SecurityScheme.json"
24+
}

definitions/1.0.0/X509.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"type": "object",
3+
"required": [
4+
"type"
5+
],
6+
"properties": {
7+
"type": {
8+
"type": "string",
9+
"enum": [
10+
"X509"
11+
]
12+
},
13+
"description": {
14+
"type": "string"
15+
}
16+
},
17+
"patternProperties": {
18+
"^x-": {}
19+
},
20+
"additionalProperties": false,
21+
"$schema": "http://json-schema.org/draft-04/schema#",
22+
"id": "http://asyncapi.com/definitions/1.0.0/X509.json"
23+
}

0 commit comments

Comments
 (0)