Skip to content

Commit

Permalink
fix: parse const keyword in a schema object (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
crudbee authored Jul 30, 2023
1 parent 3c28796 commit 22b329c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/LEGO.AsyncAPI.Readers/V2/AsyncApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
},
Expand Down
12 changes: 11 additions & 1 deletion test/LEGO.AsyncAPI.Tests/Models/AsyncApiSchema_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public class AsyncApiSchema_Should
},
},
},
["property9"] = new AsyncApiSchema
{
Const = new AsyncApiString("aSpecialConstant"),
},
},
Nullable = true,
ExternalDocs = new AsyncApiExternalDocumentation
Expand Down Expand Up @@ -418,6 +422,9 @@ public void SerializeAsJson_WithAdvancedSchemaObject_V2Works()
}
}
}
},
""property9"": {
""const"": ""aSpecialConstant""
}
},
""nullable"": true,
Expand Down Expand Up @@ -478,6 +485,9 @@ public void Deserialize_WithAdditionalProperties_Works()
}
}
}
},
""property9"": {
""const"": ""aSpecialConstant""
}
},
""nullable"": true,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 22b329c

Please sign in to comment.