OpenAPI NonBodyParameter replacement?
See original GitHub issueI upgraded to Swashbuckle v5, and was trying to update a project that uses the Microsoft.AspNetCore.Mvc.Versioning. It uses an operation filter like such:
public void Apply(Operation operation, OperationFilterContext context)
{
var apiDescription = context.ApiDescription;
operation.Deprecated = apiDescription.IsDeprecated();
if (operation.Parameters == null)
{
return;
}
// REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/412
// REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/413
foreach (var parameter in operation.Parameters.OfType<NonBodyParameter>())
{
var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name);
if (parameter.Description == null)
{
parameter.Description = description.ModelMetadata?.Description;
}
if (parameter.Default == null)
{
parameter.Default = description.DefaultValue;
}
parameter.Required |= description.IsRequired;
}
}
With SwaggerDocument no longer used in v5, I couldn’t find a NonBodyParameter equivalent in OpenAPI model.
Can anyone tell me the appropriate class to use for that in OpenAPI?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Is there <NonBodyParameter> equivalent
I updated Swashbuckle v5 and operation.Parameters() is not valid anymore.Is there any replacement? { var apiDescription = context.ApiDescription ...
Read more >Add Custom Parameters In Swagger Using ASP.NET Core ...
This article showed you a sample of how to add custom request parameters in Swagger using ASP.NET Core 3.1 and Swashbuckle.AspNetCore 5.0.0.
Read more >[Solved]-Web Api How to add a Header parameter for all API ...
Add(new NonBodyParameter { Name = "X-User-Token", In = "header", ... 5) I have to change some : using System.Collections.Generic; using Microsoft.OpenApi.
Read more >Source code for drf_yasg.openapi - drf-yasg
Source code for drf_yasg.openapi ... raise_from is EXTREMELY slow, replaced with plain raise raise AttributeError("object of class " + type(self).
Read more >[ASP.Net Core] Swagger - Show non-declared API ...
Sometimes we don't declare the API's parameter(s) on API controller's Action, but we still want them to be shown on Swagger (OpenAPI ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So not cool that you decided to break everything
How did you change your code with RequestBody?