Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Set Access-Control-Allow-Origin in Raml API #420

Open
elhamroshan opened this issue Jan 21, 2020 · 2 comments
Open

Set Access-Control-Allow-Origin in Raml API #420

elhamroshan opened this issue Jan 21, 2020 · 2 comments

Comments

@elhamroshan
Copy link

I'm trying to set Access-Control-Allow-Origin in my Raml API. Found in the web that I can do that by adding headers to my responses like:

    responses:
      200:
        headers:
          Access-Control-Allow-Origin:
            example: |
              *
          Access-Control-Allow-Methods:
            example: |
              GET, POST
          Access-Control-Allow-Headers:
            example: |
              Content-Type

I've done this but it fails compiling the code with the following error:

 method respond200WithApplicationJson in class GetApiV1ProjectsResponse cannot be applied to given types;
[ERROR]   required: ApiV1Projects.GetApiV1ProjectsResponse.HeadersFor200
[ERROR]   found: java.lang.String
[ERROR]   reason: actual and formal argument lists differ in length

Current java code when returning the response:

return GetApiV1ProjectsResponse.respond200WithApplicationJson(projectsToJson(restResponse));

Should I add any changes to my response implementation? What is missing here?

Thanks in advance!

@jpbelang
Copy link
Contributor

jpbelang commented Feb 9, 2020

I've been busy elsewhere, sorry for the delay. I'll check this tomorrow morning. Promise.

@jpbelang
Copy link
Contributor

There is an example in the project of using headers: raml-to-jaxrs/examples/maven-examples/raml-defined-example/src/main/java/server/humanity/HumanityImpl.java

But if you could give me a mode complete example maybe I could see what is wrong ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants