Opposite of DisableAutoDtoInBodyParam

We prefer not to have query parameters in our POST requests. Is there a way to get Swagger to remove inputs for query parameters and just show the body parameter? We do want to retain the inputs for path parameters. Thanks… -Paul

Instead of this:

We prefer this:

You can remove parameter from the list by annotating it with ApiMember[ParameterType="model"] attribute. You can also specify that the body parameter must be always generated for this particular request even if DisableAutoDtoInBodyParam setting is set to true when you create new OpenApiFeature(). To always generate body you need to add [Api(BodyParam = GenerateBodyParameter.Always] attribute to request DTO.

By default the setting DisableAutoDtoInBodyParam is set to false and body parameter is generated for POST requests.

    [Api(Description = "User Login", BodyParameter = GenerateBodyParameter.Always, IsRequired = true)]
    [Route("/login", "POST", Summary = "Logins user")]
    public class CreateHelloReq : IReturn<LoginResult>
        [ApiMember(IsRequired=true, ParameterType = "model")]
        public string Username { get; set; }

        [ApiMember(IsRequired=true, ParameterType = "model")]
        public string Password { get; set; }

Perfect, thank you. It does pollute my request DTO with a bunch of parameter attributes, any consideration making a global version of it at the class level? -Paul

You can use OperationFilter to remove all parameters which do not have ParameterType="body" for specific operation. Something like that

Plugins.Add(new OpenApiFeature { 
    OperationFilter = (verb, op) =>
        if (op.OperationId.StartsWith("ReceiveTextMessage_")
            op.Parameters.RemoveAll(p => p.In != "body");

We’ll also look what can be changed to reduce these number of declarations and simplify using requests with body only.