title: Mark strings as non-nullable in ASP.NET Core 3.0 Swagger
body: <p>I'm using ASP.NET Core 3 and Swashbuckle with mostly default configuration and I have a DTO parameter with a string on it that I want to be non-nullable. How can I achieve this? Note, Required and nullability are separate concerns in Swagger.</p>
  <p>It's also using C#8 and the non-nullable stuff, so the compiler should be annotating the property as non-nullable already. It's understandable that Swashbuckle hasn't been updated to take that into account (and maybe can't) but I would like to be able to override the generated metadata somehow.</p>
  <pre><code>class MyDto {
      [Required]
      // I want this to show as non-nullable in the swagger documentation (and ideally also be non-nullable in the binding)
      public string TestProp { get; set; }
  }
  
  [HttpPost]
  public void Post([FromBody] MyDto requestModel) {
  }
  </code></pre>
  <p>I have tried making it Required. I also tried adding the Newtonsoft annotations, but none of these seemed to do it.</p>
  <p>Relevant bit of Swagger doc that is generated:</p>
  <pre><code>    &quot;MyDto&quot;: {
        &quot;required&quot;: [
          &quot;testProp&quot;
        ],
        &quot;type&quot;: &quot;object&quot;,
        &quot;properties&quot;: {
          &quot;testProp&quot;: {
            &quot;type&quot;: &quot;string&quot;,
            &quot;nullable&quot;: true
          }
        },
        &quot;additionalProperties&quot;: false
       }
  </code></pre>
  <p>Note that having a string parameter directly as a parameter doesn't generate the nullable attribute. E.g.</p>
  <pre><code>[HttpPost(&quot;testPost&quot;)]
  public void Post([FromBody] [Required] string testProp) {
  }
  </code></pre>
  <p>will generate</p>
  <pre><code>&quot;/api/test/testPost&quot;: {
    &quot;post&quot;: {
      &quot;tags&quot;: [
        &quot;Test&quot;
      ],
      &quot;requestBody&quot;: {
        &quot;content&quot;: {
          &quot;application/json&quot;: {
            &quot;schema&quot;: {
              &quot;type&quot;: &quot;string&quot;
            }
          },
          &quot;text/json&quot;: {
            &quot;schema&quot;: {
              &quot;type&quot;: &quot;string&quot;
            }
          },
          &quot;application/*+json&quot;: {
            &quot;schema&quot;: {
              &quot;type&quot;: &quot;string&quot;
            }
          }
        },
        &quot;required&quot;: true
      },
      &quot;responses&quot;: {
        &quot;200&quot;: {
          &quot;description&quot;: &quot;Success&quot;
        }
      }
    }
  },
  </code></pre>