From 7d953f3a7b93bbf32075d61d1644ca0859afca26 Mon Sep 17 00:00:00 2001 From: crudbee Date: Mon, 24 Jul 2023 14:18:59 +0200 Subject: [PATCH 1/2] Add missing conversion over const --- src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs | 3 +++ 1 file changed, 3 insertions(+) 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(); } }, From f6672e5d7133f8fd413e00722e8963c42dca164a Mon Sep 17 00:00:00 2001 From: crudbee Date: Mon, 24 Jul 2023 15:27:41 +0200 Subject: [PATCH 2/2] Add in a test to cover the const keyword in schema --- .../Models/AsyncApiSchema_Should.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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);