Skip to content

Commit

Permalink
Fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keahpeters committed Apr 29, 2024
1 parent 3a21817 commit 40cb61f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static class ApiParameterDescriptionExtensions
private static readonly HashSet<string> IllegalHeaderParameters = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
HeaderNames.Accept,
HeaderNames.ContentType,
HeaderNames.Authorization
HeaderNames.Authorization,
HeaderNames.ContentType
};

public static bool IsRequiredParameter(this ApiParameterDescription apiParameter)
Expand Down Expand Up @@ -122,7 +122,7 @@ internal static bool IsFromForm(this ApiParameterDescription apiParameter)

internal static bool IsIllegalHeaderParameter(this ApiParameterDescription apiParameter)
{
// Certian header parameters are not allowed and should be described using the corresponding OpenAPI keywords
// Certain header parameters are not allowed and should be described using the corresponding OpenAPI keywords
// https://swagger.io/docs/specification/describing-parameters/#header-parameters
return apiParameter.Source == BindingSource.Header && IllegalHeaderParameters.Contains(apiParameter.Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ public void GetSwagger_IgnoresParameters_IfActionParameterIsIllegalHeaderParamet
Name = fromHeaderAttribute?.Name ?? illegalParameter.Name,
Source = BindingSource.Header,
ModelMetadata = ModelMetadataFactory.CreateForParameter(illegalParameter)
},
new ApiParameterDescription
{
Name = "param",
Source = BindingSource.Header
}
}
)
Expand Down Expand Up @@ -563,6 +568,10 @@ public void GetSwagger_GenerateParametersSchemas_IfActionParameterIsIllegalHeade
new OpenApiParameter
{
Name = illegalParameterName,
},
new OpenApiParameter
{
Name = "param",
}
}
}
Expand All @@ -588,10 +597,16 @@ public void GetSwagger_GenerateParametersSchemas_IfActionParameterIsIllegalHeade
Name = illegalParameterName,
Source = BindingSource.Header,
ModelMetadata = ModelMetadataFactory.CreateForParameter(illegalParameter)
},
new ApiParameterDescription
{
Name = "param",
Source = BindingSource.Header,
ModelMetadata = ModelMetadataFactory.CreateForType(typeof(string))
}
}),
}
);
); ;

var document = subject.GetSwagger("v1");

Expand Down

0 comments on commit 40cb61f

Please sign in to comment.