OpenAPITools / OpenAPITools/openapi-generator

[QUESTION] How can I add CrossOrigin annotation to the controller generated by OpenAPI Generator?

Open
#18,373 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

How can I tell openapi generator to add this annotation to the controller definition:

@CrossOrigin(
    methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE},
    exposedHeaders = {
      "Access-Control-Allow-Origin",
      "Access-Control-Allow-Credentials"
    })

see: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced sample file, samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/PetApiController.java, and inspect the OpenAPI Generator Spring Boot templates and configuration options that produce it. Determine whether the requested annotation can be configured; done means identifying a supported configuration or clearly scoping the generator change required.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.