title: Enabling CORS with openapi-generator
body: <p>So I'm using <a href="https://openapi-generator.tech/" rel="nofollow noreferrer">openapi-generator</a> to generate a flask server to serve my api. </p>
  
  <p>I am having no trouble generating the server running it and viewing endpoints in my browser. However I get a CORS error when I make a GET request from my React Web App.</p>
  
  <p>I've tried a few things to enable CORS. </p>
  
  <p>I tried adding the header to my endpoint in my .yaml.</p>
  
  <pre><code>/pipelines:
      get:
        summary: 'Returns a list of pipelines.'
        operationId: get_pipelines
        responses:
          '200':
            description: 'A JSON array of pipelines'
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/Pipeline'
            headers:
              Access-Control-Allow-Origin: '*'
          default:
            description: Unexpected error
            content:
              'application/json':
                schema:
                  $ref: '#/components/schemas/ErrorMessage'
  </code></pre>
  
  <p>When I try adding the header via the .yaml and try to regenerate the server module, I get this error:</p>
  
  <pre><code>-attribute paths.'/pipelines'(get).responses.200.Access-Control-Allow-Origin is not of type `object
  </code></pre>
  
  <p>I also tried installing and importing flask_cors in the <strong>main</strong>.py of the server module.</p>
  
  <pre><code>#!/usr/bin/env python3
  
  import connexion
  
  from openapi_server import encoder
  from flask_cors import CORS
  
  def main():
      app = connexion.App(__name__, specification_dir='./openapi/')
      CORS(app.app)
      app.app.json_encoder = encoder.JSONEncoder
      app.add_api('openapi.yaml',
                  arguments={'title': 'ICDR API'},
                  pythonic_params=True)
      app.run(port=5050)
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>And I tried both those together. These fixes I found in the swagger-codegen <a href="https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml" rel="nofollow noreferrer">petstore.yaml</a> example and in the <a href="https://connexion.readthedocs.io/en/latest/cookbook.html#cors-support" rel="nofollow noreferrer">connexion docs</a>. </p>
  
  <p>However as I stated I'm using openapi-generator so its a little different than either of those other tools, but I'm having a lot of trouble finding any information on how to set this up correctly. Has anyone worked with openapi-generator before who can help me out?</p>