|
| 1 | +// Copyright (c) The LEGO Group. All rights reserved. |
| 2 | + |
| 3 | +namespace LEGO.AsyncAPI.Readers |
| 4 | +{ |
| 5 | + using LEGO.AsyncAPI.Extensions; |
| 6 | + using LEGO.AsyncAPI.Models; |
| 7 | + using LEGO.AsyncAPI.Readers.ParseNodes; |
| 8 | + |
| 9 | + internal static partial class AsyncApiDeserializer |
| 10 | + { |
| 11 | + private static FixedFieldMap<AsyncApiComponents> componentsFixedFields = new() |
| 12 | + { |
| 13 | + { "schemas", (a, n) => a.Schemas = n.CreateMapWithReference(ReferenceType.Schema, LoadSchema) }, |
| 14 | + { "servers", (a, n) => a.Servers = n.CreateMapWithReference(ReferenceType.Server, LoadServer) }, |
| 15 | + { "channels", (a, n) => a.Channels = n.CreateMapWithReference(ReferenceType.Channel, LoadChannel) }, |
| 16 | + { "messages", (a, n) => a.Messages = n.CreateMapWithReference(ReferenceType.Message, LoadMessage) }, |
| 17 | + { "securitySchemas", (a, n) => a.SecuritySchemes = n.CreateMapWithReference(ReferenceType.SecurityScheme, LoadSecurityScheme) }, |
| 18 | + { "parameters", (a, n) => a.Parameters = n.CreateMapWithReference(ReferenceType.Parameter, LoadParameter) }, |
| 19 | + { "correlationIds", (a, n) => a.CorrelationIds = n.CreateMapWithReference(ReferenceType.CorrelationId, LoadCorrelationId) }, |
| 20 | + { "operationTraits", (a, n) => a.OperationTraits = n.CreateMapWithReference(ReferenceType.OperationTrait, LoadOperationTrait) }, |
| 21 | + { "messageTraits", (a, n) => a.MessageTraits = n.CreateMapWithReference(ReferenceType.MessageTrait, LoadMessageTrait) }, |
| 22 | + |
| 23 | + //{"serverBindings", (a, n) => a.ServerBindings = n.CreateMapWithReference(ReferenceType.ServerBinding, LoadServerBinding)}, // TODO: Do something with bindings |
| 24 | + //{"channelBindings", (a, n) => a.ChannelBindings = n.CreateMapWithReference(ReferenceType.ChannelBinding, LoadChannelBinding)}, |
| 25 | + //{"operationBindings", (a, n) => a.OperationBindings = n.CreateMapWithReference(ReferenceType.OperationBinding, LoadOperationBinding)}, |
| 26 | + //{"messageBindings", (a, n) => a.MessageBindings = n.CreateMapWithReference(ReferenceType.MessageBinding, LoadMessageBinding)}, |
| 27 | + }; |
| 28 | + |
| 29 | + |
| 30 | + private static PatternFieldMap<AsyncApiComponents> componentsPatternFields = |
| 31 | + new() |
| 32 | + { |
| 33 | + { s => s.StartsWith("x-"), (a, p, n) => a.AddExtension(p, LoadExtension(p, n)) }, |
| 34 | + }; |
| 35 | + |
| 36 | + public static AsyncApiComponents LoadComponents(ParseNode node) |
| 37 | + { |
| 38 | + var mapNode = node.CheckMapNode("components"); |
| 39 | + var components = new AsyncApiComponents(); |
| 40 | + |
| 41 | + ParseMap(mapNode, components, componentsFixedFields, componentsPatternFields); |
| 42 | + |
| 43 | + return components; |
| 44 | + } |
| 45 | + } |
| 46 | +} |
0 commit comments