mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-26 11:21:51 +01:00
@@ -1,5 +1,6 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Models;
|
||||
@@ -16,7 +17,7 @@ internal static class OpenApiSchemaExtensions
|
||||
{
|
||||
value = false;
|
||||
|
||||
if (schema.Extensions.TryGetValue("x-nullable", out IOpenApiExtension e) && e is OpenApiBoolean openApiBoolean)
|
||||
if (schema.Extensions.TryGetValue("x-nullable", out var e) && e is OpenApiBoolean openApiBoolean)
|
||||
{
|
||||
value = openApiBoolean.Value;
|
||||
return true;
|
||||
@@ -27,32 +28,30 @@ internal static class OpenApiSchemaExtensions
|
||||
|
||||
public static SchemaType GetSchemaType(this OpenApiSchema? schema)
|
||||
{
|
||||
switch (schema?.Type)
|
||||
if (schema == null)
|
||||
{
|
||||
case "object":
|
||||
return SchemaType.Object;
|
||||
|
||||
case "array":
|
||||
return SchemaType.Array;
|
||||
|
||||
case "integer":
|
||||
return SchemaType.Integer;
|
||||
|
||||
case "number":
|
||||
return SchemaType.Number;
|
||||
|
||||
case "boolean":
|
||||
return SchemaType.Boolean;
|
||||
|
||||
case "string":
|
||||
return SchemaType.String;
|
||||
|
||||
case "file":
|
||||
return SchemaType.File;
|
||||
|
||||
default:
|
||||
return SchemaType.Unknown;
|
||||
return SchemaType.Unknown;
|
||||
}
|
||||
|
||||
if (schema.Type == null)
|
||||
{
|
||||
if (schema.AllOf.Any() || schema.AnyOf.Any())
|
||||
{
|
||||
return SchemaType.Object;
|
||||
}
|
||||
}
|
||||
|
||||
return schema.Type switch
|
||||
{
|
||||
"object" => SchemaType.Object,
|
||||
"array" => SchemaType.Array,
|
||||
"integer" => SchemaType.Integer,
|
||||
"number" => SchemaType.Number,
|
||||
"boolean" => SchemaType.Boolean,
|
||||
"string" => SchemaType.String,
|
||||
"file" => SchemaType.File,
|
||||
_ => SchemaType.Unknown
|
||||
};
|
||||
}
|
||||
|
||||
public static SchemaFormat GetSchemaFormat(this OpenApiSchema? schema)
|
||||
|
||||
@@ -193,7 +193,8 @@ internal class OpenApiPathsMapper
|
||||
}
|
||||
else
|
||||
{
|
||||
jArray.Add(MapSchemaToObject(schema.Items, name));
|
||||
var arrayItem = MapSchemaToObject(schema.Items, name: null); // Set name to null to force JObject instead of JProperty
|
||||
jArray.Add(arrayItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,12 +220,9 @@ internal class OpenApiPathsMapper
|
||||
|
||||
if (schema.AllOf.Count > 0)
|
||||
{
|
||||
foreach (var property in schema.AllOf)
|
||||
foreach (var group in schema.AllOf.SelectMany(p => p.Properties).GroupBy(x => x.Key))
|
||||
{
|
||||
foreach (var item in property.Properties)
|
||||
{
|
||||
propertyAsJObject.Add(MapPropertyAsJObject(item.Value, item.Key));
|
||||
}
|
||||
propertyAsJObject.Add(MapPropertyAsJObject(group.First().Value, group.Key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,27 +39,35 @@ public class WireMockOpenApiParserSettings
|
||||
public IWireMockOpenApiParserExampleValues? ExampleValues { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is a Header match case insensitive? (default is true).
|
||||
/// Is a Header match case-insensitive?
|
||||
///
|
||||
/// Default is <c>true</c>.
|
||||
/// </summary>
|
||||
public bool HeaderPatternIgnoreCase { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Is a Query Parameter match case insensitive? (default is true).
|
||||
/// Is a Query Parameter match case-insensitive?
|
||||
///
|
||||
/// Default is <c>true</c>.
|
||||
/// </summary>
|
||||
public bool QueryParameterPatternIgnoreCase { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Is a Request Body match case insensitive? (default is true).
|
||||
/// Is a Request Body match case-insensitive?
|
||||
///
|
||||
/// Default is <c>true</c>.
|
||||
/// </summary>
|
||||
public bool RequestBodyIgnoreCase { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Is a ExampleValue match case insensitive? (default is true).
|
||||
/// Is a ExampleValue match case-insensitive?
|
||||
///
|
||||
/// Default is <c>true</c>.
|
||||
/// </summary>
|
||||
public bool IgnoreCaseExampleValues { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Are examples generated dynamically? (default is false).
|
||||
/// Are examples generated dynamically?
|
||||
/// </summary>
|
||||
public bool DynamicExamples { get; set; } = false;
|
||||
public bool DynamicExamples { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user