Skip to content

Commit

Permalink
chore: pull main into vnext (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: lego-10-01-06[bot] <119427331+lego-10-01-06[bot]@users.noreply.github.com>
  • Loading branch information
VisualBean and lego-10-01-06[bot] authored Jun 14, 2024
1 parent 3355ac9 commit b9de516
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 28 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
name: Publish beta NuGet package
on:
push:
branches: [ main ]
paths:
- 'src/LEGO.AsyncAPI/**'
- 'src/LEGO.AsyncAPI.Readers/**'
- 'src/LEGO.AsyncAPI.Bindings/**'
- ".github/workflows/release-internal.yml"
- '!**/*.md'
workflow_dispatch:

jobs:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [5.2.1](https://github.com/LEGO/AsyncAPI.NET/compare/v5.2.0...v5.2.1) (2024-06-12)


### Bug Fixes

* inline channel parameters should not deserialize as references ([#172](https://github.com/LEGO/AsyncAPI.NET/issues/172)) ([7fd3af0](https://github.com/LEGO/AsyncAPI.NET/commit/7fd3af0e6669d18e805e0bab9cafac819ea64c1d))

# [5.2.0](https://github.com/LEGO/AsyncAPI.NET/compare/v5.1.1...v5.2.0) (2024-03-30)


Expand Down
7 changes: 7 additions & 0 deletions Common.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/LEGO/AsyncAPI.NET</RepositoryUrl>
<PackageTags>asyncapi .net openapi documentation</PackageTags>
<PackageIcon>logo.png</PackageIcon>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\media\logo.png" Pack="true" PackagePath="\" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE.txt" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ The AsyncAPI.NET SDK contains a useful object model for the AsyncAPI specificati
Install the NuGet packages:
### AsyncAPI.NET
[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET?label=AsyncAPI.NET&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET/)
[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET?label=AsyncAPI.NET&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET/)
[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET?label=AsyncAPI.NET-Preview&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET/)

### AsyncAPI.Readers
[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Readers?label=AsyncAPI.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/)
[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET.Readers?label=AsyncAPI.Readers&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/)
[![Nuget](https://img.shields.io/nuget/vpre/AsyncAPI.NET.Readers?label=AsyncAPI.Readers-Preview&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Readers/)

### AsyncAPI.Bindings
[![Nuget](https://img.shields.io/nuget/v/AsyncAPI.NET.Bindings?label=AsyncAPI.Bindings&style=for-the-badge)](https://www.nuget.org/packages/AsyncAPI.NET.Bindings/)
Expand Down
Binary file added media/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions src/LEGO.AsyncAPI.Bindings/LEGO.AsyncAPI.Bindings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LEGO.AsyncAPI.Readers\LEGO.AsyncAPI.Readers.csproj" />
<ProjectReference Include="..\LEGO.AsyncAPI\LEGO.AsyncAPI.csproj" />
Expand Down
6 changes: 0 additions & 6 deletions src/LEGO.AsyncAPI.Readers/LEGO.AsyncAPI.Readers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
<ItemGroup>
<InternalsVisibleTo Include="LEGO.AsyncAPI.Tests" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LEGO.AsyncAPI\LEGO.AsyncAPI.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static partial class AsyncApiV2Deserializer
{ "servers", (a, n) => { a.Servers = n.CreateSimpleList(s => s.GetScalarValue()); } },
{ "subscribe", (a, n) => { a.Subscribe = LoadOperation(n); } },
{ "publish", (a, n) => { a.Publish = LoadOperation(n); } },
{ "parameters", (a, n) => { a.Parameters = n.CreateMapWithReference(ReferenceType.Parameter, LoadParameter); } },
{ "parameters", (a, n) => { a.Parameters = n.CreateMap(LoadParameter); } },
{ "bindings", (a, n) => { a.Bindings = LoadChannelBindings(n); } },
};

Expand Down
4 changes: 0 additions & 4 deletions src/LEGO.AsyncAPI/LEGO.AsyncAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="LEGO.AsyncAPI.Tests" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion src/LEGO.AsyncAPI/Services/AsyncApiReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ private T ResolveReference<T>(AsyncApiReference reference)

try
{
return this.currentDocument.ResolveReference(reference) as T;
var resolvedReference = this.currentDocument.ResolveReference(reference) as T;
if (resolvedReference == null)
{
throw new AsyncApiException($"Cannot resolve reference '{reference.Reference}' to '{typeof(T).Name}'.");
}

return resolvedReference;
}
catch (AsyncApiException ex)
{
Expand Down
27 changes: 27 additions & 0 deletions test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace LEGO.AsyncAPI.Tests
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using FluentAssertions;
using LEGO.AsyncAPI.Exceptions;
using LEGO.AsyncAPI.Models;
Expand Down Expand Up @@ -428,6 +429,32 @@ public void Read_WithBasicPlusSecuritySchemeDeserializes()
Assert.AreEqual("Provide your username and password for SASL/SCRAM authentication", scheme.Value.Description);
}

[Test]
public void Read_WithWrongReference_AddsError()
{
var yaml =
"""
asyncapi: 2.3.0
info:
title: test
version: 1.0.0
channels:
workspace:
publish:
message:
$ref: '#/components/securitySchemes/saslScram'
components:
securitySchemes:
saslScram:
type: scramSha256
description: Provide your username and password for SASL/SCRAM authentication
""";
var reader = new AsyncApiStringReader();
var doc = reader.Read(yaml, out var diagnostic);
diagnostic.Errors.Should().NotBeEmpty();
doc.Channels.Values.First().Publish.Message.First().Should().BeNull();
}

[Test]
public void Read_WithBasicPlusOAuthFlowDeserializes()
{
Expand Down
21 changes: 21 additions & 0 deletions test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,36 @@
namespace LEGO.AsyncAPI.Tests.Models
{
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using LEGO.AsyncAPI.Bindings.Kafka;
using LEGO.AsyncAPI.Bindings.WebSockets;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers;
using NUnit.Framework;

public class AsyncApiChannel_Should : TestBase
{
[Test]
public void AsyncApiChannel_WithInlineParameter_DoesNotCreateReference()
{
var input =
"""
parameters:
id:
description: ids
schema:
type: string
enum:
- 08735ae0-6a1a-4578-8b4a-35aa26d15993
- 97845c62-329c-4d87-ad24-4f611b909a10
""";

var channel = new AsyncApiStringReader().ReadFragment<AsyncApiChannel>(input, AsyncApiVersion.AsyncApi2_0, out var _ );
channel.Parameters.First().Value.Reference.Should().BeNull();
}

[Test]
public void AsyncApiChannel_WithWebSocketsBinding_Serializes()
{
Expand Down

0 comments on commit b9de516

Please sign in to comment.