mattfrear/Swashbuckle.AspNetCore.Filters

SwaggerRequestExample Attribute is applied to other action

DenisSteff opened this issue · 0 comments

I create a simple api project using "dotnet new webapi"

I add 2 methods in the controller, the post action have an example using the attribute SwaggerRequestExample


  [HttpPost("")]
        [SwaggerRequestExample(typeof(WeatherForecast), typeof(WeatherForecastExample))]
        public  IActionResult Post([FromBody] WeatherForecast weatherForecast)
        {
            return Ok();
        }


        [HttpPut("{id}")]
        public IActionResult Update([FromRoute] int id, [FromBody] WeatherForecast weatherForecast)
        {
            return Ok();
        }

In startup i add this


services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new OpenApiInfo { Title = "SwaggerDoc", Version = "v1" });
            c.ExampleFilters();
        });

        services.AddSwaggerExamplesFromAssemblies(Assembly.GetEntryAssembly());

When i run my project i have the example on the Post method but also on th PUT which is not decorate whith the SwaggerRequestExample attribute.

Capture