title: How to set default values for a query param with array type in .Net.Core with Swashbuckle by code
body: <p>I am currently working with .NET Core 3.1 and Swashbuckle library. I have made several endpoints with requests decorated with attributes and proper swagger descriptions (I want to continue doing it this way).</p>
  <p>Now I have a problem with the query parameter whose type is Array.
  It is no problem to show this property with items to add.
  <a href="https://i.stack.imgur.com/fIZFM.png" rel="nofollow noreferrer">enter image description here</a>
  I wish to fulfill them with default 12 values. It could be 12 x 0.
  Something like:</p>
  <pre><code>[DefaultValue(new int[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })]
  </code></pre>
  <p>Also, I set [MaxLength(12)], but it also does not work.</p>
  <p>I see for now even validation for numbers does not work.</p>
  <p>For now, it looks like this:</p>
  <pre><code>    /// &lt;summary&gt;
      /// MyArray with 12x0 values.
      /// &lt;/summary&gt;
      [DefaultValue(new int[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })]
      [MaxLength(12)]
      [Range(0, 1)]
      public int[] MyArray { get; set; }
  </code></pre>
  <p>What do I want to achieve?</p>
  <ul>
  <li>default values for 12 items with 0.</li>
  <li>no less and no more than 12 items.</li>
  <li>validation is in range 0,1</li>
  </ul>
  <p>Thank you in advance!</p>
  <p>Edit:
  I have also tried custom AttributeFilter, but it changes nothing on swagger UI...</p>
  <pre><code> public class QueryArrayParameterFilter : IParameterFilter
  {
      public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
      {
          if (!parameter.In.HasValue || parameter.In.Value != ParameterLocation.Query)
              return;
  
          if (parameter.Schema?.Type == &quot;array&quot; &amp;&amp; parameter.Name.Equals(&quot;MyArray&quot;))
          {
              var value = null as IOpenApiExtension;
              parameter.Extensions.TryGetValue(&quot;explode&quot;, out value);
  
              if (value == null)
              {
                  parameter.Extensions.Add(&quot;explode&quot;, new OpenApiBoolean(false));
              }
  
              parameter.Schema = new OpenApiSchema
              {
                  Type = &quot;array&quot;,
                  Items = new OpenApiSchema()
                  {
                      MaxItems = 2,
                      Type = &quot;integer&quot;,
                      Format = &quot;int64&quot;,
                      Example = new OpenApiArray() 
                      {
                      new OpenApiInteger(0),
                      new OpenApiInteger(0)
                      },
                      Default = new OpenApiArray()
                      {
                      new OpenApiInteger(0),
                      new OpenApiInteger(0)
                      }
                  },
                  MaxItems = 3
              };
          }
      }
  }
  </code></pre>