cancel
Showing results for 
Search instead for 
Did you mean: 

Swagger required OpenApiParameter for header

Highlighted
Visitor

Swagger required OpenApiParameter for header

Hi,

Im using Swaasbuckle v5 for .net core v3.

When I made my OpenApiParameter required to true its not allowing me to submit the request and alwasy fires required validation even if I enter data.

 

operation.Parameters.Add(new OpenApiParameter
{
    Name = "apiAccessKey",
    In = ParameterLocation.Header,
    Required = true,
    Schema = new OpenApiSchema
    {
        Type = nameof(String)
    }
});

//Below line is from startup when adding swagger options
c.OperationFilter<AddRequiredHeaderParameter>();

{0760B350-772D-48BB-8288-D85BACA9ED59&#125;.png.jpg

 

Thanks.

1 REPLY 1
Highlighted
Moderator

Re: Swagger required OpenApiParameter for header

Try replacing

Type = nameof(String)

with

Type = "string"

Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors
Top Kudoed Posts