Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
ab26ef3
so many changes
VisualBean May 27, 2022
ef92287
change iany to iextension
VisualBean May 27, 2022
6bb18ff
more refactorings
VisualBean Jun 16, 2022
7bea8ea
MOAR
VisualBean Jun 20, 2022
f4d6388
moar
VisualBean Jun 21, 2022
617f614
it's a reset!
mifriis Jun 21, 2022
05e0526
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
278099a
Flattery is the finest form of piracy
mifriis Jun 21, 2022
f378ece
wait, it'a all partial classes?
mifriis Jun 21, 2022
11e49f0
API to Api
mifriis Jun 21, 2022
13bcaff
up date
Jun 21, 2022
20f38ea
FieldMap in all the things
mifriis Jun 21, 2022
aecce6b
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
df20b50
link
Jun 21, 2022
33deec0
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
9b63844
more
Jun 21, 2022
8ba2d6c
All the parsenodes!
mifriis Jun 21, 2022
434dfcc
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
96fe11c
mostly functioning exceptions
mifriis Jun 21, 2022
6ec49e4
more
Jun 21, 2022
65643e8
refs
Jun 21, 2022
bf4bcd8
more
Jun 21, 2022
7b3aa96
red squiglies begone!
mifriis Jun 21, 2022
3a0b1f6
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
5208379
more
Jun 21, 2022
276985d
ma
Jun 21, 2022
81c5430
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
942d4c5
add error
Jun 21, 2022
5b083b9
boilerplates
mifriis Jun 21, 2022
635f6b8
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
8974de7
interfaces for all your testing needs
mifriis Jun 21, 2022
c88cc72
all the reader services
mifriis Jun 21, 2022
f22d3f2
all the readers
mifriis Jun 21, 2022
7f12c4d
s
Jun 21, 2022
bf637e9
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
160de64
mooooore
VisualBean Jun 21, 2022
10b36d8
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
6d1c675
the remaining supporting classes
mifriis Jun 21, 2022
27d34f2
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
3286527
some rules for thy but not for i
mifriis Jun 21, 2022
551547e
imported types to remove the red squiglys
mifriis Jun 21, 2022
fecf155
rm
Jun 21, 2022
b59e249
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
25509ad
do the needful
mifriis Jun 21, 2022
6876d1e
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
90dfe9d
d
Jun 21, 2022
02f15cd
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
2a6c45b
Revert "rm"
Jun 21, 2022
648ab54
Auto stash before revert of "rm"
VisualBean Jun 21, 2022
5c2ef41
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
79d952c
Revert "rm"
VisualBean Jun 21, 2022
52dc9a0
server stuff
mifriis Jun 21, 2022
c1715b0
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
7dc06c4
minor fixes
VisualBean Jun 21, 2022
175ec20
more server
mifriis Jun 21, 2022
b204fd5
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
a87f1e3
minor fixes
VisualBean Jun 21, 2022
161acbf
operation deserializer
Jun 21, 2022
49b5cee
meh
mifriis Jun 21, 2022
289acd0
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
9ce6d04
holy f
VisualBean Jun 21, 2022
003bc47
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
ae390cb
string error messages
mifriis Jun 21, 2022
24a6553
fix namespaces
VisualBean Jun 21, 2022
67a20c0
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
a615d5f
tags
Jun 21, 2022
8bd3b94
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
2062e60
ref update
Jun 21, 2022
e430c29
capital
VisualBean Jun 21, 2022
bc90f0e
more capital
VisualBean Jun 21, 2022
f4a8915
changes
VisualBean Jun 21, 2022
04b977d
deserializer is happy now
mifriis Jun 21, 2022
0bc81c8
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
938ff2e
sec scheme in comp
mifriis Jun 21, 2022
bf1f435
fixes
VisualBean Jun 21, 2022
7bdb3c5
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
42c2e1f
renames
VisualBean Jun 21, 2022
1f37761
this
VisualBean Jun 21, 2022
e408bd7
sec scheme is happy
mifriis Jun 21, 2022
125a8da
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
211a655
add externaldocs
Jun 21, 2022
bcd82b5
renames
VisualBean Jun 21, 2022
405a1e5
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
fffe8c4
big a
mifriis Jun 21, 2022
9b22698
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
mifriis Jun 21, 2022
e4ff22e
add tag
Jun 21, 2022
fdad185
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
4f360d2
message
mifriis Jun 21, 2022
e071a53
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
f6c7ce8
things
Jun 21, 2022
af366cc
maybe thats message?
mifriis Jun 21, 2022
da6d00e
moar fixes
VisualBean Jun 21, 2022
2175d1f
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
5a40636
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 21, 2022
c3d5326
traits
Jun 21, 2022
2155d59
add operation
Jun 21, 2022
7c327c8
thus far
VisualBean Jun 21, 2022
29364d1
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 21, 2022
9a52ed1
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 22, 2022
4640c4c
internal static partial class AsyncApiDeserializer
Jun 22, 2022
b449e41
add parameter deserializer
Jun 22, 2022
daf8654
chanel
Jun 22, 2022
f62f18f
add messagetrait
Jun 22, 2022
38a9ea9
do something, anything with components
Jun 22, 2022
f2aa123
Remove constructor from AsyncApiInfo as it does not appear in the Ope…
Jun 22, 2022
3916deb
Get License in line with how OpenApi handles structures
Jun 22, 2022
122bfa5
add license deserializer
Jun 22, 2022
84f9c1e
add info deserializer
Jun 22, 2022
1dc92e9
update main deserializer
Jun 22, 2022
f8a0e20
Use type targeted new ()
Jun 22, 2022
325b4ab
finished walker
VisualBean Jun 22, 2022
04f03c5
fixes
VisualBean Jun 22, 2022
18d5260
fix imports
Jun 23, 2022
a9d8051
fix imports, but in a way where I dont delete a whole line by accident
Jun 23, 2022
2347a36
inline out declaration
Jun 23, 2022
a623372
remove callback
Jun 23, 2022
0bd5561
comment out bindings
Jun 23, 2022
358ca93
import things
Jun 23, 2022
de069d2
_
Jun 23, 2022
e2b3a3b
typo
Jun 23, 2022
98f3189
update example
Jun 23, 2022
315b737
add loadany
Jun 23, 2022
eec1007
weird thing i removed
mifriis Jun 23, 2022
53aceaf
add example
Jun 23, 2022
d7693c2
order schema deserializer to match documentation
Jun 23, 2022
0e0f3e3
structure change, no logical changes
Jun 23, 2022
0cd2e76
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
Jun 23, 2022
5f66a2b
fix class name
Jun 23, 2022
367f76c
more
Jun 23, 2022
beef3f2
reader non-read
Jun 23, 2022
5352215
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 23, 2022
ddb4dc6
missing walk
VisualBean Jun 23, 2022
1e28a50
fixes
VisualBean Jun 23, 2022
e565b46
remove unneeded projects
VisualBean Jun 23, 2022
5d65357
newline
Jun 24, 2022
c0b6d90
found a todo missing
Jun 24, 2022
ed24a08
cleanup AsyncApiException
Jun 24, 2022
7057828
refac
Jun 27, 2022
439a4c6
fixes and unfinished tests
VisualBean Jun 28, 2022
e060f6e
Merge remote-tracking branch 'origin/alex/refactorallofthethings' int…
VisualBean Jun 28, 2022
307a977
more fixes
VisualBean Jun 28, 2022
9165f17
fixes
VisualBean Jun 29, 2022
ac68fc6
fixed namespacing
VisualBean Jun 29, 2022
cc85f02
fix bunch of warnings
VisualBean Jun 29, 2022
0186f66
mas
VisualBean Jun 29, 2022
b259657
more fixes
VisualBean Jun 29, 2022
3a57a8d
remove open api references
VisualBean Jun 29, 2022
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
30 changes: 0 additions & 30 deletions AsyncAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.Tests", "test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI", "src\LEGO.AsyncAPI\LEGO.AsyncAPI.csproj", "{D4559946-300D-4C6F-B92B-4376414D19C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.E2E.Tests", "test\LEGO.AsyncAPI.E2E.Tests\LEGO.AsyncAPI.E2E.Tests.csproj", "{85E0F568-3B0C-4253-A03B-83578865A788}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.Readers", "src\LEGO.AsyncAPI.Readers\LEGO.AsyncAPI.Readers.csproj", "{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.Readers.YamlExample", "examples\LEGO.AsyncAPI.Readers.YamlExample\LEGO.AsyncAPI.Readers.YamlExample.csproj", "{D6314FDA-A897-4CEF-8EB1-DC46510BEB7C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LEGO.AsyncAPI.Readers.JsonExample", "examples\LEGO.AsyncAPI.Readers.JsonExample\LEGO.AsyncAPI.Readers.JsonExample.csproj", "{DACCA48F-6BA9-4552-B5A4-2D7ECAD328BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LEGO.AsyncAPI.Writers", "src\LEGO.AsyncAPI.Writers\LEGO.AsyncAPI.Writers.csproj", "{3CC2CCB8-BDF8-4C1F-AF59-851EC5B5968C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LEGO.AsyncAPI.Writers.Example", "examples\LEGO.AsyncAPI.Writers.Example\LEGO.AsyncAPI.Writers.Example.csproj", "{09C8FC87-D785-41C2-84B1-14B2F40099D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,30 +23,10 @@ Global
{D4559946-300D-4C6F-B92B-4376414D19C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4559946-300D-4C6F-B92B-4376414D19C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4559946-300D-4C6F-B92B-4376414D19C9}.Release|Any CPU.Build.0 = Release|Any CPU
{85E0F568-3B0C-4253-A03B-83578865A788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85E0F568-3B0C-4253-A03B-83578865A788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85E0F568-3B0C-4253-A03B-83578865A788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85E0F568-3B0C-4253-A03B-83578865A788}.Release|Any CPU.Build.0 = Release|Any CPU
{7D9C6FBA-4B6F-48A0-B3F5-E7357021F8F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{D6314FDA-A897-4CEF-8EB1-DC46510BEB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6314FDA-A897-4CEF-8EB1-DC46510BEB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6314FDA-A897-4CEF-8EB1-DC46510BEB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6314FDA-A897-4CEF-8EB1-DC46510BEB7C}.Release|Any CPU.Build.0 = Release|Any CPU
{DACCA48F-6BA9-4552-B5A4-2D7ECAD328BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DACCA48F-6BA9-4552-B5A4-2D7ECAD328BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DACCA48F-6BA9-4552-B5A4-2D7ECAD328BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DACCA48F-6BA9-4552-B5A4-2D7ECAD328BE}.Release|Any CPU.Build.0 = Release|Any CPU
{3CC2CCB8-BDF8-4C1F-AF59-851EC5B5968C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CC2CCB8-BDF8-4C1F-AF59-851EC5B5968C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CC2CCB8-BDF8-4C1F-AF59-851EC5B5968C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CC2CCB8-BDF8-4C1F-AF59-851EC5B5968C}.Release|Any CPU.Build.0 = Release|Any CPU
{09C8FC87-D785-41C2-84B1-14B2F40099D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09C8FC87-D785-41C2-84B1-14B2F40099D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09C8FC87-D785-41C2-84B1-14B2F40099D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09C8FC87-D785-41C2-84B1-14B2F40099D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion examples/LEGO.AsyncAPI.Readers.JsonExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static async Task Main()

var asyncApiDocument = new AsyncApiStringReader().Read(await new StreamReader(stream).ReadToEndAsync(), out var diagnostic);

if (diagnostic.HasError)
if (diagnostic.Errors.Any())
{
Console.WriteLine($"Error during spec parsing: {diagnostic.Errors.First()}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<ItemGroup>
<ProjectReference Include="..\..\src\LEGO.AsyncAPI.Readers\LEGO.AsyncAPI.Readers.csproj" />
<ProjectReference Include="..\..\src\LEGO.AsyncAPI.Writers\LEGO.AsyncAPI.Writers.csproj" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions src/LEGO.AsyncAPI.Readers/AsyncApiChannelDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Readers
{
using LEGO.AsyncAPI.Extensions;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Readers.ParseNodes;

internal static partial class AsyncApiDeserializer
{
private static readonly FixedFieldMap<AsyncApiChannel> channelFixedFields = new()
{
{ "description", (a, n) => { a.Description = n.GetScalarValue(); } },
{ "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); } },
{ "bindings", (a, n) => { ; } }, //TODO: Figure out bindings
};

private static readonly PatternFieldMap<AsyncApiChannel> channelPatternFields =
new()
{
{ s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) },
};

public static AsyncApiChannel LoadChannel(ParseNode node)
{
var mapNode = node.CheckMapNode("channel");

var pathItem = new AsyncApiChannel();

ParseMap(mapNode, pathItem, channelFixedFields, channelPatternFields);

return pathItem;
}
}
}
46 changes: 46 additions & 0 deletions src/LEGO.AsyncAPI.Readers/AsyncApiComponentsDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Readers
{
using LEGO.AsyncAPI.Extensions;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Readers.ParseNodes;

internal static partial class AsyncApiDeserializer
{
private static FixedFieldMap<AsyncApiComponents> componentsFixedFields = new()
{
{ "schemas", (a, n) => a.Schemas = n.CreateMapWithReference(ReferenceType.Schema, LoadSchema) },
{ "servers", (a, n) => a.Servers = n.CreateMapWithReference(ReferenceType.Server, LoadServer) },
{ "channels", (a, n) => a.Channels = n.CreateMapWithReference(ReferenceType.Channel, LoadChannel) },
{ "messages", (a, n) => a.Messages = n.CreateMapWithReference(ReferenceType.Message, LoadMessage) },
{ "securitySchemas", (a, n) => a.SecuritySchemes = n.CreateMapWithReference(ReferenceType.SecurityScheme, LoadSecurityScheme) },
{ "parameters", (a, n) => a.Parameters = n.CreateMapWithReference(ReferenceType.Parameter, LoadParameter) },
{ "correlationIds", (a, n) => a.CorrelationIds = n.CreateMapWithReference(ReferenceType.CorrelationId, LoadCorrelationId) },
{ "operationTraits", (a, n) => a.OperationTraits = n.CreateMapWithReference(ReferenceType.OperationTrait, LoadOperationTrait) },
{ "messageTraits", (a, n) => a.MessageTraits = n.CreateMapWithReference(ReferenceType.MessageTrait, LoadMessageTrait) },

//{"serverBindings", (a, n) => a.ServerBindings = n.CreateMapWithReference(ReferenceType.ServerBinding, LoadServerBinding)}, // TODO: Do something with bindings
//{"channelBindings", (a, n) => a.ChannelBindings = n.CreateMapWithReference(ReferenceType.ChannelBinding, LoadChannelBinding)},
//{"operationBindings", (a, n) => a.OperationBindings = n.CreateMapWithReference(ReferenceType.OperationBinding, LoadOperationBinding)},
//{"messageBindings", (a, n) => a.MessageBindings = n.CreateMapWithReference(ReferenceType.MessageBinding, LoadMessageBinding)},
};


private static PatternFieldMap<AsyncApiComponents> componentsPatternFields =
new()
{
{ s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) },
};

public static AsyncApiComponents LoadComponents(ParseNode node)
{
var mapNode = node.CheckMapNode("components");
var components = new AsyncApiComponents();

ParseMap(mapNode, components, componentsFixedFields, componentsPatternFields);

return components;
}
}
}
38 changes: 38 additions & 0 deletions src/LEGO.AsyncAPI.Readers/AsyncApiContactDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Readers
{
using System;
using LEGO.AsyncAPI.Extensions;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Readers.ParseNodes;

/// <summary>
/// Class containing logic to deserialize AsyncApi document into
/// runtime AsyncApi object model.
/// </summary>
internal static partial class AsyncApiDeserializer
{
private static FixedFieldMap<AsyncApiContact> contactFixedFields = new()
{
{ "name", (o, n) => { o.Name = n.GetScalarValue(); } },
{ "email", (o, n) => { o.Email = n.GetScalarValue(); } },
{ "url", (o, n) => { o.Url = new Uri(n.GetScalarValue(), UriKind.RelativeOrAbsolute); } },
};

private static PatternFieldMap<AsyncApiContact> contactPatternFields = new()
{
{ s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p, n)) },
};

public static AsyncApiContact LoadContact(ParseNode node)
{
var mapNode = node as MapNode;
var contact = new AsyncApiContact();

ParseMap(mapNode, contact, contactFixedFields, contactPatternFields);

return contact;
}
}
}
41 changes: 41 additions & 0 deletions src/LEGO.AsyncAPI.Readers/AsyncApiCorrelationIdDeserializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) The LEGO Group. All rights reserved.

namespace LEGO.AsyncAPI.Readers
{
using LEGO.AsyncAPI.Extensions;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Readers.ParseNodes;

/// <summary>
/// Class containing logic to deserialize AsyncAPI document into
/// runtime AsyncAPI object model.
/// </summary>
internal static partial class AsyncApiDeserializer
{
private static readonly FixedFieldMap<AsyncApiCorrelationId> correlationIdFixedFileds =
new()
{
{ "description", (a, n) => { a.Description = n.GetScalarValue(); } },
{ "location", (a, n) => { a.Location = n.GetScalarValue(); } },
};

private static readonly PatternFieldMap<AsyncApiCorrelationId> correlationIdPatternFields =
new()
{
{ s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) },
};

public static AsyncApiCorrelationId LoadCorrelationId(ParseNode node)
{
var mapNode = node.CheckMapNode("correlationId");

var correlationId = new AsyncApiCorrelationId();
foreach (var property in mapNode)
{
property.ParseField(correlationId, correlationIdFixedFileds, correlationIdPatternFields);
}

return correlationId;
}
}
}
Loading