I am trying to add an optional parameter to my API endpoint. The default value of this parameter is "true". I am getting an error saying cannot convert bool to OpenAPIAny. What other value could I put besides that?
operation.Parameters.Add(new OpenApiParameter()
{
Name = "Name",
In = ParameterLocation.Query,
Description = "Description",
Required = false,
Schema = new OpenApiSchema
{
Type = "boolean",
Default = true
}
}
CodePudding user response:
The Default
property is a type of IOpenApiAny so you will need to convert the boolean to that. Try using this line:
Default = new Microsoft.OpenApi.Any.OpenApiBoolean(true)