title: How to add custom headers in NSwag document using C# .NET CORE?
body: <p>I am in need of adding custom headers, but cannot figure it out.  I am trying to utilize the new services.AddOpenApiDocument() instead of the services.AddSwaggerDocument().  I want to add these custom headers on my whole API not just a single method or controller.  I attempted to add an operation processor, but when I load up the swagger UI I receive the following error " Could not render this component, see the console."</p>
  
  <p>Here is my snippet within my <code>ConfigureServices()</code>:</p>
  
  <pre><code>    services.AddOpenApiDocument(document =&gt;
      {
          ...
          // this works fine
          document.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer"));
          document.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", new SwaggerSecurityScheme
              {
                  Type = SwaggerSecuritySchemeType.ApiKey,
                  Name = "Authorization",
                  In = SwaggerSecurityApiKeyLocation.Header
              })
          );
  
          // this is the header i want to show up for all endpoints that is breaking
          document.OperationProcessors.Add(new SampleHeaderOperationProcessor());
      });
  </code></pre>
  
  <p>Here is my operation processor:</p>
  
  <pre><code>public class SampleHeaderOperationProcessor : IOperationProcessor
  {
      public Task&lt;bool&gt; ProcessAsync(OperationProcessorContext context)
      {
          context.OperationDescription.Operation.Parameters.Add(
              new SwaggerParameter {
                  Name = "Sample",
                  Kind = SwaggerParameterKind.Header,
                  Type = NJsonSchema.JsonObjectType.String,
                  IsRequired = false,
                  Description = "This is a test header",
                  Default = "{{\"field1\": \"value1\", \"field2\": \"value2\"}}"
              });
  
          return Task.FromResult(true);
      }
  }
  </code></pre>
  
  <p>The only thing I have pertaining to this within my Configure():</p>
  
  <pre><code>    app.UseSwagger();
      app.UseSwaggerUi3();                              
  </code></pre>
  
  <p>Here is my error and the console log:
  <a href="https://i.stack.imgur.com/EjKlV.png" rel="nofollow noreferrer">My error and console log</a></p>
  
  <p>If it helps I'm using <code>ASP .NET CORE 2.2</code> and <code>NSwag.AspNetCore v12.1.0</code></p>