Improve method MapSchemaToObject to support array and object (#670)

This commit is contained in:
Daniel L. Romero
2021-10-28 01:21:30 -05:00
committed by GitHub
parent 0e06cf6346
commit ae2a05e86b

View File

@@ -114,11 +114,6 @@ namespace WireMock.Net.OpenApiParser.Mappers
return null;
}
if (schema.AllOf.Count > 0)
{
return MapSchemaAllOfToObject(schema);
}
switch (schema.GetSchemaType())
{
case SchemaType.Array:
@@ -149,6 +144,11 @@ namespace WireMock.Net.OpenApiParser.Mappers
}
}
if (schema.AllOf.Count > 0)
{
jArray.Add(MapSchemaAllOfToObject(schema));
}
return jArray;
case SchemaType.Boolean:
@@ -161,10 +161,18 @@ namespace WireMock.Net.OpenApiParser.Mappers
var propertyAsJObject = new JObject();
foreach (var schemaProperty in schema.Properties)
{
string propertyName = schemaProperty.Key;
var openApiSchema = schemaProperty.Value;
propertyAsJObject.Add(MapPropertyAsJObject(schemaProperty.Value, schemaProperty.Key));
}
if (schema.AllOf.Count > 0)
{
foreach (var property in schema.AllOf)
{
foreach (var item in property.Properties)
{
propertyAsJObject.Add(MapPropertyAsJObject(item.Value, item.Key));
}
}
}
return name != null ? new JProperty(name, propertyAsJObject) : (JToken)propertyAsJObject;