diff --git a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs index 5f3fb609..582016eb 100644 --- a/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs +++ b/src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs @@ -101,6 +101,9 @@ public class JsonSchemaDeserializer { "enum", (a, n) => { a.Enum = n.CreateListOfAny(); } }, + { + "const", (a, n) => { a.Const = n.CreateAny(); } + }, { "examples", (a, n) => { a.Examples = n.CreateListOfAny(); } }, diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs index bb190ad3..4b99a465 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs @@ -104,6 +104,10 @@ public class AsyncApiSchema_Should }, }, }, + ["property9"] = new AsyncApiSchema + { + Const = new AsyncApiString("aSpecialConstant"), + }, }, Nullable = true, ExternalDocs = new AsyncApiExternalDocumentation @@ -418,6 +422,9 @@ public void SerializeAsJson_WithAdvancedSchemaObject_V2Works() } } } + }, + ""property9"": { + ""const"": ""aSpecialConstant"" } }, ""nullable"": true, @@ -478,6 +485,9 @@ public void Deserialize_WithAdditionalProperties_Works() } } } + }, + ""property9"": { + ""const"": ""aSpecialConstant"" } }, ""nullable"": true, @@ -596,7 +606,7 @@ public void Serialize_WithInliningOptions_ShouldInlineAccordingly(bool shouldInl { "testD", new AsyncApiSchema { Reference = new AsyncApiReference { Type = ReferenceType.Schema, Id = "testD" } } }, }, }) - .WithComponent("testB", new AsyncApiSchema() { Description = "test", Type = SchemaType.Boolean }) + .WithComponent("testB", new AsyncApiSchema() { Description = "test", Type = SchemaType.Boolean }) .Build(); var outputString = new StringWriter(CultureInfo.InvariantCulture);