Skip to content

Commit

Permalink
Filter required properti in headers, query params, request body (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
leolplex committed Nov 27, 2021
1 parent 9db6e80 commit 13c002f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private MappingModel MapOperationToMappingModel(string path, string httpMethod,
MapSchemaToObject(responseSchema);

var requestBodyModel = new BodyModel();
if (operation.RequestBody != null && operation.RequestBody.Content != null)
if (operation.RequestBody != null && operation.RequestBody.Content != null && operation.RequestBody.Required)
{
var request = operation.RequestBody.Content;
TryGetContent(request, out OpenApiMediaType requestContent, out string requestContentType);
Expand Down Expand Up @@ -323,6 +323,7 @@ private JToken MapOpenApiAnyToJToken(IOpenApiAny any)
private IList<ParamModel> MapQueryParameters(IEnumerable<OpenApiParameter> queryParameters)
{
var list = queryParameters
.Where(req => req.Required)
.Select(qp => new ParamModel
{
Name = qp.Name,
Expand All @@ -339,6 +340,7 @@ private IList<ParamModel> MapQueryParameters(IEnumerable<OpenApiParameter> query
private IList<HeaderModel> MapRequestHeaders(IEnumerable<OpenApiParameter> headers)
{
var list = headers
.Where(req => req.Required)
.Select(qp => new HeaderModel
{
Name = qp.Name,
Expand Down

0 comments on commit 13c002f

Please sign in to comment.