Skip to content

Commit 8795da5

Browse files
committed
docs: slim down the readme
1 parent 871976a commit 8795da5

1 file changed

Lines changed: 46 additions & 132 deletions

File tree

‎README.md‎

Lines changed: 46 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,79 @@
11
# AsyncAPI.NET
2-
This serves as the official future of AsyncAPI.NET.
3-
To be able to give the level of support I want, I have had to fork my original work from the The LEGO Group, and create my own.
4-
This is unfortunate, but after much back and not a lot of forth, I have decided that it was time.
52

63
[![Build & Test](https://github.com/ByteBardOrg/AsyncAPI.NET/actions/workflows/ci.yml/badge.svg)](https://github.com/ByteBardOrg/AsyncAPI.NET/actions/workflows/ci.yml)
74

5+
AsyncAPI.NET provides a .NET object model for AsyncAPI documents, JSON/YAML readers and writers, and protocol bindings.
86

9-
The AsyncAPI.NET SDK contains a useful object model for the AsyncAPI specification in .NET along with common serializers to extract raw AsyncAPI JSON and YAML documents from the model as well.
10-
AsyncAPI.NET supports the current releases of the AsyncAPI 2.x and 3.x major versions. Today, serialization emits 2.6 or 3.1.0 respectively.
11-
V2 documents are upgraded to the V3 model during deserialization and can be written back as V2 (see writing examples). The V3 serialization selector is still named `AsyncApiVersion.AsyncApi3_0`.
12-
13-
[CHANGELOG](https://github.com/ByteBardOrg/AsyncAPI.NET/blob/vnext/CHANGELOG.md)
14-
[Getting started guide](https://bytebard.org/AsyncAPI.NET/docs/guides/getting-started)
7+
It supports AsyncAPI 2.x and 3.x. V2 documents are upgraded to the V3-shaped model when read and can be written back as V2. Serialization currently emits **2.6** or **3.1.0**; the V3 selector is still named `AsyncApiVersion.AsyncApi3_0`.
158

16-
## Documentation
17-
The [documentation site](https://bytebard.org/AsyncAPI.NET/) is built with Docusaurus. See [website/README.md](website/README.md) for local development instructions. GitHub Pages must be configured to use GitHub Actions for deployment.
9+
See the **[documentation site](https://bytebard.org/AsyncAPI.NET/)** for guides and examples, or the [changelog](CHANGELOG.md) for release notes.
10+
11+
## Install
1812

19-
## Installation
20-
Generally you want to use Readers and Bindings.
21-
They have however been split to allow for different scenarios without polluting with unnecesary packages.
13+
Install the core model and serializers, plus the readers for JSON/YAML input:
2214

23-
Install the NuGet packages:
24-
### ByteBard.AsyncAPI.NET
25-
[![Nuget](https://img.shields.io/nuget/v/ByteBard.AsyncAPI.NET?label=ByteBard.AsyncAPI.NET&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET/)
26-
[![Nuget](https://img.shields.io/nuget/vpre/ByteBard.AsyncAPI.NET?label=ByteBard.AsyncAPI.NET-Preview&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET/)
15+
```sh
16+
dotnet add package ByteBard.AsyncAPI.NET
17+
dotnet add package ByteBard.AsyncAPI.NET.Readers
18+
```
2719

28-
### ByteBard.AsyncAPI.Readers
29-
[![Nuget](https://img.shields.io/nuget/v/ByteBard.AsyncAPI.NET.Readers?label=ByteBard.AsyncAPI.Readers&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET.Readers/)
30-
[![Nuget](https://img.shields.io/nuget/vpre/ByteBard.AsyncAPI.NET.Readers?label=ByteBard.AsyncAPI.Readers-Preview&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET.Readers/)
20+
For protocol bindings, also install:
3121

32-
### ByteBard.AsyncAPI.Bindings
33-
[![Nuget](https://img.shields.io/nuget/v/ByteBard.AsyncAPI.NET.Bindings?label=ByteBard.AsyncAPI.Bindings&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET.Bindings/)
34-
[![Nuget](https://img.shields.io/nuget/vpre/ByteBard.AsyncAPI.NET.Bindings?label=ByteBard.AsyncAPI.Bindings-Preview&style=for-the-badge)](https://www.nuget.org/packages/ByteBard.AsyncAPI.NET.Bindings/)
22+
```sh
23+
dotnet add package ByteBard.AsyncAPI.NET.Bindings
24+
```
3525

36-
# Example Usage
37-
Main classes to know:
26+
Binding readers require explicit registration; see [protocol bindings](https://bytebard.org/AsyncAPI.NET/docs/bindings).
3827

39-
* AsyncApiStringReader
40-
* AsyncApiStringWriter
41-
* There is an extension on the AsyncApiDocument type which allows Serializing as well (`new AsyncApiDocument().SerializeAsJson()` or `new AsyncApiDocument().SerializeAsYaml()`
28+
## Quick start
4229

43-
## Writing
30+
Parse YAML, check diagnostics, and write JSON (C# 11 or later):
4431

4532
```csharp
46-
var specification =
47-
"""
33+
using System;
34+
using ByteBard.AsyncAPI;
35+
using ByteBard.AsyncAPI.Models;
36+
using ByteBard.AsyncAPI.Readers;
37+
38+
var source = """
4839
asyncapi: 3.1.0
4940
info:
50-
title: UsersAPI
41+
title: Example API
5142
version: 1.0.0
52-
externalDocs:
53-
description: Find more info here
54-
url: https://www.asyncapi.com
55-
tags:
56-
- name: e-commerce
57-
servers:
58-
production:
59-
host: "rabbitmq.in.mycompany.com:5672"
60-
pathname: "/production"
61-
protocol: "amqp"
62-
channels:
63-
UserSignup:
64-
address: "user/signedup"
65-
messages:
66-
UserMessage:
67-
payload:
68-
type: object
69-
properties:
70-
displayName:
71-
type: string
72-
description: Name of the user
73-
operations:
74-
ConsumeUserSignups:
75-
action: receive
76-
channel:
77-
$ref: "#/channels/UserSignup"
43+
channels: {}
7844
""";
79-
var reader = new AsyncApiStringReader();
80-
var document = reader.Read(specification, out var diagnostics);
81-
var v2Document = document.SerializeAsYaml(AsyncApiVersion.AsyncApi2_0);
82-
var v3Document = document.SerializeAsJson(AsyncApiVersion.AsyncApi3_0);
83-
```
8445

46+
var document = new AsyncApiStringReader().Read(source, out var diagnostics);
8547

86-
## Reading
48+
foreach (var error in diagnostics.Errors)
49+
Console.Error.WriteLine($"Error at {error.Pointer}: {error.Message}");
50+
foreach (var warning in diagnostics.Warnings)
51+
Console.Error.WriteLine($"Warning at {warning.Pointer}: {warning.Message}");
8752

88-
There are 3 reader types
89-
1. AsyncApiStringReader
90-
2. AsyncApiTextReader
91-
3. AsyncApiStreamReader
53+
if (diagnostics.Errors.Count > 0)
54+
return;
9255

93-
All 3 supports both json and yaml.
94-
95-
#### StreamReader
96-
```csharp
97-
var httpClient = new HttpClient
98-
{
99-
BaseAddress = new Uri("https://raw.githubusercontent.com/asyncapi/spec/"),
100-
};
101-
102-
var stream = await httpClient.GetStreamAsync("master/examples/streetlights-kafka.yml");
103-
var asyncApiDocument = new AsyncApiStreamReader().Read(stream, out var diagnostic);
56+
Console.WriteLine(document.SerializeAsJson(AsyncApiVersion.AsyncApi3_0));
10457
```
10558

106-
#### StringReader
107-
```csharp
108-
var yaml =
109-
"""
110-
asyncapi: 2.6.0
111-
info:
112-
title: my first asyncapi
113-
channels:
114-
users:
115-
subscribe:
116-
operationId: users
117-
description: my users channel
118-
message:
119-
$ref: '#/components/messages/MyMessage'
120-
components:
121-
messages:
122-
MyMessage:
123-
name: Hello!
124-
""";
125-
126-
var asyncApiDocument = new AsyncApiStringReader().Read(yaml, out var diagnostic);
127-
```
128-
All readers will write warnings and errors to the diagnostics.
129-
130-
131-
## Reference Resolution
132-
Internal references are resolved by default. This includes component and non-component references e.g `#/components/messages/MyMessage` and `#/servers/production`.
133-
External references can be resolved by setting `ReferenceResolution` to `ResolveAllReferences`.
134-
The default implementation will resolve anything prefixed with `file://`, `http://` & `https://`, however a custom implementation can be made, by inhereting from the `IStreamLoader` interface and setting the `ExternalReferenceLoader` in the `AsyncApiReaderSettings`.
135-
External references are always force converted to Json during resolution. This means that both yaml and json is supported - but not other serialization languages.
136-
137-
```csharp
138-
var settings = new AsyncApiReaderSettings { ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences };
139-
var document = new AsyncApiStringReader(settings).Read(json, out var diagnostics);
140-
```
59+
## Documentation
14160

142-
Reference resolution can be disabled by setting `ReferenceResolution` to `DoNotResolveReferences`.
61+
- [Getting started](https://bytebard.org/AsyncAPI.NET/docs/guides/getting-started)
62+
- [Reading documents and diagnostics](https://bytebard.org/AsyncAPI.NET/docs/guides/reading)
63+
- [Schemas](https://bytebard.org/AsyncAPI.NET/docs/guides/schemas): [JSON Schema](https://bytebard.org/AsyncAPI.NET/docs/guides/json-schema) and [Avro](https://bytebard.org/AsyncAPI.NET/docs/guides/avro)
64+
- [References and resolution](https://bytebard.org/AsyncAPI.NET/docs/guides/references)
65+
- [Protocol bindings](https://bytebard.org/AsyncAPI.NET/docs/bindings)
66+
- Extending: [extension parsers](https://bytebard.org/AsyncAPI.NET/docs/guides/custom-extension-parsers), [schema parsers](https://bytebard.org/AsyncAPI.NET/docs/guides/custom-schema-parsers), [bindings](https://bytebard.org/AsyncAPI.NET/docs/guides/custom-bindings), and [validation rules](https://bytebard.org/AsyncAPI.NET/docs/guides/validation-rules)
14367

144-
## Bindings
145-
To add support for reading bindings, simply add the bindings you wish to support, to the `Bindings` collection of `AsyncApiReaderSettings`.
146-
There is a nifty helper to add different types of bindings, or like in the example `All` of them.
68+
## Contributing
14769

148-
```csharp
149-
var settings = new AsyncApiReaderSettings();
150-
settings.Bindings = BindingsCollection.All;
151-
var asyncApiDocument = new AsyncApiStringReader(settings).Read(yaml, out var diagnostic);
152-
```
70+
Contributions and suggestions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) and the [documentation development instructions](website/README.md).
15371

15472
## Attribution
15573

156-
* [OpenAPI.Net](https://github.com/microsoft/OpenAPI.NET) - [MIT License](https://github.com/microsoft/OpenAPI.NET/blob/vnext/LICENSE)
157-
* [YamlDotNet](https://github.com/aaubry/YamlDotNet) - [MIT License](https://github.com/aaubry/YamlDotNet/blob/master/LICENSE.txt)
158-
159-
## Contribution
160-
161-
This project welcomes contributions and suggestions.
162-
Do you want to contribute to the project? Find out how [here](CONTRIBUTING.md).
74+
- [OpenAPI.NET](https://github.com/microsoft/OpenAPI.NET) — [MIT License](https://github.com/microsoft/OpenAPI.NET/blob/vnext/LICENSE)
75+
- [YamlDotNet](https://github.com/aaubry/YamlDotNet) — [MIT License](https://github.com/aaubry/YamlDotNet/blob/master/LICENSE.txt)
16376

16477
## License
165-
[Apache 2.0](https://github.com/ByteBardOrg/AsyncAPI.NET/blob/main/LICENSE.txt)
78+
79+
[Apache 2.0](LICENSE.txt)

0 commit comments

Comments
 (0)