Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there <NonBodyParameter> equivalent

I updated Swashbuckle v5 and operation.Parameters() is not valid anymore.Is there any replacement?

        {
            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<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;
            }
        }

Error CS0307 The property 'OpenApiOperation.Parameters' cannot be used with type arguments

like image 651
Yoana Gancheva Avatar asked Nov 11 '19 12:11

Yoana Gancheva


1 Answers

From Swashbuckle.AspNetCore GitHub site

In OpenAPI v3, body parameters are split out into a separate property called RequestBody. So, I think you may be able to remove OfType filter entirely as all values in the collection are "non-body"

I think you should be able to use OpenApiParameter.

like image 101
Harry Biscuit Avatar answered Oct 15 '22 19:10

Harry Biscuit