Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
578e237
feat: WIP Add sns channel bindings
Apr 28, 2023
861ee6f
feat!: separate bindings and allow for custom bindings. (#107)
VisualBean May 3, 2023
222ad97
chore: add readme.md to bindings pack
VisualBean May 3, 2023
44354de
feat: WIP bring in line with new bindings wf
May 4, 2023
d856ccc
feat: WIP fix file overwrite
May 4, 2023
1fac669
feat: WIP further attempts at serde
May 4, 2023
0edd5c9
feat: WIP fix typo
May 4, 2023
e7bc0df
feat: WIP more node work
May 4, 2023
980bf81
feat: WIP switch to display enum
May 5, 2023
8221472
feat: WIP fixed lists
May 5, 2023
ab5550f
feat: WIP fix write issues
May 5, 2023
286e64d
feat: WIP remove commented function
May 5, 2023
b8aceea
feat: WIP Complete SNS body
May 5, 2023
d0f0ceb
feat: WIP finish SNS channel binding
May 5, 2023
41ea55d
feat: WIP Add basic SNS operation serialization
May 10, 2023
11755d5
refactor: binding improvement
VisualBean May 11, 2023
9c0f0c6
Merge branch 'main' into feat-add-sns-aws-bindings
May 11, 2023
33769c3
feat: WIP Add sns op fix fields
May 11, 2023
6a9266f
feat: WIP Add correct required properties
May 11, 2023
6bcf4e2
feat: WIP remove constants
May 11, 2023
b4d3a56
feat: WIP move to block scoped namespaces
May 11, 2023
0e1a445
ci: pull_request_target
VisualBean May 12, 2023
2690f4c
ci: add build and test run for forks (#110)
VisualBean May 12, 2023
a7c3305
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean May 12, 2023
b244161
ci: delete new workflow
VisualBean May 12, 2023
7f10a91
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean May 12, 2023
eedb2fa
fix: update AsyncApiTextReader class name (#109)
gokerakc May 12, 2023
e948e3d
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec May 12, 2023
21caee9
feat: fix identifier fixed fields bug
May 15, 2023
e120788
feat: correct type property to be required
May 16, 2023
783a1d2
feat: rename ordering to match spec
May 16, 2023
e01e26c
chore: add bindings to labeler
VisualBean May 18, 2023
30b87fb
test: add 'any' example
VisualBean May 18, 2023
7a28082
Merge remote-tracking branch 'origin/main' into main
VisualBean May 18, 2023
a09cdac
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec May 18, 2023
2277518
feat: add any filter policy handling
May 18, 2023
ce6d084
feat: correct policy effect casing
May 19, 2023
55f22bd
feat: use write any
May 19, 2023
b589e4f
feat!: separate bindings and allow for custom bindings. (#107)
VisualBean May 3, 2023
d242484
ci: force pre-releases
VisualBean Jun 5, 2023
2e4bf25
chore: update readme with pre-release shields
VisualBean Jun 5, 2023
79f11a8
sync changes
Jun 8, 2023
b4f8cb1
feat: sync with main
Jun 9, 2023
2c934e7
feat: update nested extensible objects and tests
Jun 9, 2023
4a2386a
Merge branch 'main' of github.com:dpwdec/AsyncAPI.NET into main
Jun 9, 2023
ea82b09
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean Jun 9, 2023
bbf391d
feat: merge main
Jun 9, 2023
6c4b0da
feat: integrate StringOrStringList to SNS
Jun 9, 2023
cd94f2c
feat: reformat files
Jun 9, 2023
8a7befe
feat: integrate remote changes
Jun 9, 2023
8f08e2b
feat: update consumer description wording
Jun 12, 2023
57e16d9
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec Jun 12, 2023
da4e8d6
feat: match wording to spec
Jun 12, 2023
c17f85b
Merge remote-tracking branch 'origin/feat-add-sns-aws-bindings' into …
Jun 12, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
paths:
- 'src/LEGO.AsyncAPI/**'
- 'src/LEGO.AsyncAPI.Readers/**'
- 'src/LEGO.AsyncAPI.Writers/**'
- 'src/LEGO.AsyncAPI.Bindings/**'
- ".github/workflows/release-package.yml"
- '!**/*.md'
workflow_dispatch:
Expand All @@ -16,7 +16,7 @@ jobs:
name: Publish NuGet packages
strategy:
matrix:
package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers"]
package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers", "LEGO.AsyncAPI.Bindings"]
steps:
- name: Checkout repository
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
environment: AsyncAPI
strategy:
matrix:
package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers" ]
package-name: [ "LEGO.AsyncAPI", "LEGO.AsyncAPI.Readers", "LEGO.AsyncAPI.Bindings" ]
steps:
- name: Checkout repository
uses: actions/checkout@v1
Expand Down
6 changes: 6 additions & 0 deletions AsyncAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LEGO.AsyncAPI.Bindings", "src\LEGO.AsyncAPI.Bindings\LEGO.AsyncAPI.Bindings.csproj", "{33CA31F4-ECFE-4227-BFE9-F49783DD29A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -32,6 +34,10 @@ Global
{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}.Release|Any CPU.Build.0 = Release|Any CPU
{33CA31F4-ECFE-4227-BFE9-F49783DD29A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33CA31F4-ECFE-4227-BFE9-F49783DD29A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33CA31F4-ECFE-4227-BFE9-F49783DD29A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33CA31F4-ECFE-4227-BFE9-F49783DD29A0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
30 changes: 30 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Binding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings
{
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers.Interface;
using LEGO.AsyncAPI.Readers.ParseNodes;

public abstract class Binding<T> : AsyncApiBinding, IBindingParser<T>
where T : IBinding, new()
{
protected static void ParseMap<T>(
MapNode mapNode,
T domainObject,
FixedFieldMap<T> fixedFieldMap)
{
if (mapNode == null)
{
return;
}

foreach (var propertyNode in mapNode)
{
propertyNode.ParseField(domainObject, fixedFieldMap, null);
}
}

public abstract T LoadBinding(PropertyNode node);
}
}
78 changes: 78 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Bindings.Http;
using LEGO.AsyncAPI.Bindings.Kafka;
using LEGO.AsyncAPI.Bindings.Pulsar;
using LEGO.AsyncAPI.Bindings.Sns;
using LEGO.AsyncAPI.Bindings.WebSockets;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers.Interface;

public static class BindingsCollection
{
public static TCollection Add<TCollection, TItem>(
this TCollection destination,
IEnumerable<TItem> source)
where TCollection : ICollection<TItem>
{
ArgumentNullException.ThrowIfNull(destination);
ArgumentNullException.ThrowIfNull(source);

if (destination is List<TItem> list)
{
list.AddRange(source);
return destination;
}

foreach (var item in source)
{
destination.Add(item);
}

return destination;
}

public static IEnumerable<IBindingParser<IBinding>> All => new List<IBindingParser<IBinding>>
{
Pulsar,
Kafka,
Http,
Sns,
};

public static IEnumerable<IBindingParser<IBinding>> Http => new List<IBindingParser<IBinding>>
{
new HttpOperationBinding(),
new HttpMessageBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Websockets => new List<IBindingParser<IBinding>>
{
new WebSocketsChannelBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Kafka => new List<IBindingParser<IBinding>>
{
new KafkaServerBinding(),
new KafkaChannelBinding(),
new KafkaOperationBinding(),
new KafkaMessageBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Pulsar => new List<IBindingParser<IBinding>>
{
// Pulsar
new PulsarServerBinding(),
new PulsarChannelBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Sns => new List<IBindingParser<IBinding>>
{
new SnsChannelBinding(),
};
}
}
16 changes: 16 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/ChannelBinding{T}.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Bindings
{
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers;
using LEGO.AsyncAPI.Readers.ParseNodes;

public abstract class ChannelBinding<T> : Binding<T>, IChannelBinding
where T : IChannelBinding, new()
{
protected abstract FixedFieldMap<T> FixedFieldMap { get; }

public override T LoadBinding(PropertyNode node) => BindingDeserializer.LoadBinding("ChannelBinding", node.Value, this.FixedFieldMap);
}
}
51 changes: 51 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Http/HttpMessageBinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) The LEGO Group. All rights reserved.

using LEGO.AsyncAPI.Models;

namespace LEGO.AsyncAPI.Bindings.Http
{
using System;
using LEGO.AsyncAPI.Readers;
using LEGO.AsyncAPI.Readers.ParseNodes;
using LEGO.AsyncAPI.Writers;

/// <summary>
/// Binding class for http messaging channels.
/// </summary>
public class HttpMessageBinding : MessageBinding<HttpMessageBinding>
{

/// <summary>
/// A Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type object and have a properties key.
/// </summary>
public AsyncApiSchema Headers { get; set; }

/// <summary>
/// Serialize to AsyncAPI V2 document without using reference.
/// </summary>
public override void SerializeProperties(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();

writer.WriteOptionalObject(AsyncApiConstants.Headers, this.Headers, (w, h) => h.SerializeV2(w));
writer.WriteOptionalProperty(AsyncApiConstants.BindingVersion, this.BindingVersion);
writer.WriteExtensions(this.Extensions);

writer.WriteEndObject();
}

public override string BindingKey => "http";

protected override FixedFieldMap<HttpMessageBinding> FixedFieldMap => new()
{
{ "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } },
{ "headers", (a, n) => { a.Headers = JsonSchemaDeserializer.LoadSchema(n); } },
};

}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Models.Bindings.Http
using LEGO.AsyncAPI.Models;

namespace LEGO.AsyncAPI.Bindings.Http
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Attributes;
using LEGO.AsyncAPI.Readers;
using LEGO.AsyncAPI.Readers.ParseNodes;
using LEGO.AsyncAPI.Writers;

/// <summary>
/// Binding class for http operations.
/// </summary>
public class HttpOperationBinding : IOperationBinding
public class HttpOperationBinding : OperationBinding<HttpOperationBinding>
{
public enum HttpOperationType
{
[Display("request")]
Request,

[Display("response")]
Response,
}
/// <summary>
/// REQUIRED. Type of operation. Its value MUST be either request or response.
/// </summary>
public string Type { get; set; }
public HttpOperationType? Type { get; set; }

/// <summary>
/// When type is request, this is the HTTP method, otherwise it MUST be ignored. Its value MUST be one of GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, CONNECT, and TRACE.
Expand All @@ -27,15 +38,10 @@ public class HttpOperationBinding : IOperationBinding
/// </summary>
public AsyncApiSchema Query { get; set; }

/// <summary>
/// The version of this binding. If omitted, "latest" MUST be assumed.
/// </summary>
public string BindingVersion { get; set; }

/// <summary>
/// Serialize to AsyncAPI V2 document without using reference.
/// </summary>
public void SerializeV2WithoutReference(IAsyncApiWriter writer)
public override void SerializeProperties(IAsyncApiWriter writer)
{
if (writer is null)
{
Expand All @@ -44,37 +50,22 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)

writer.WriteStartObject();

writer.WriteRequiredProperty(AsyncApiConstants.Type, this.Type);
writer.WriteRequiredProperty(AsyncApiConstants.Type, this.Type.GetDisplayName());
writer.WriteOptionalProperty(AsyncApiConstants.Method, this.Method);
writer.WriteOptionalObject(AsyncApiConstants.Query, this.Query, (w, h) => h.SerializeV2(w));
writer.WriteOptionalProperty(AsyncApiConstants.BindingVersion, this.BindingVersion);

writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}

public void SerializeV2(IAsyncApiWriter writer)
protected override FixedFieldMap<HttpOperationBinding> FixedFieldMap => new()
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

if (this.Reference != null && !writer.GetSettings().ShouldInlineReference(this.Reference))
{
this.Reference.SerializeV2(writer);
return;
}

this.SerializeV2WithoutReference(writer);
}

/// <inheritdoc/>
public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public bool UnresolvedReference { get; set; }

public AsyncApiReference Reference { get; set; }
{ "bindingVersion", (a, n) => { a.BindingVersion = n.GetScalarValue(); } },
{ "type", (a, n) => { a.Type = n.GetScalarValue().GetEnumFromDisplayName<HttpOperationType>(); } },
{ "method", (a, n) => { a.Method = n.GetScalarValue(); } },
{ "query", (a, n) => { a.Query = JsonSchemaDeserializer.LoadSchema(n); } },
};

BindingType IBinding.Type => BindingType.Http;
public override string BindingKey => "http";
}
}
Loading