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

Missing intermediate paths #252

Closed
b0bd opened this issue May 8, 2017 · 12 comments
Closed

Missing intermediate paths #252

b0bd opened this issue May 8, 2017 · 12 comments

Comments

@b0bd
Copy link

b0bd commented May 8, 2017

Using the following raml snippet with 2.0.1-SNAPSHOT I get "/Attachments" in the generated class instead of "{viewingSessionId}/Attachments": Playing with the RAML it seems I'm only getting the first part of the URL on the interface class and the final part on the method, but the intermediate parts are dropped.

raml fragment:

/ViewingSession:
  /{viewingSessionId}:
    /Attachments:
      uriParameters:
        viewingSessionId:
          type: string
      get:
        responses:
          200:
            body:
              application/json:
                type: EmptyObject

generated java fragment:

@Path("/ViewingSession")
public interface ViewingSession {
  @GET
  @Path("/Attachments")
  @Produces("application/json")
  GetViewingSessionAttachmentsByViewingSessionIdResponse getViewingSessionAttachmentsByViewingSessionId(@PathParam("viewingSessionId") String viewingSessionId);
@KevinMitchell
Copy link

We've got the same problem, and it's show-stopper for us. We are exposing the wrong paths and have no access to the URI parameter. Is this a problem with just the latest release, and downgrading to an earlier release will fix it. Or has this always been broken? Is there an ETA for a fix?

@jpbelang
Copy link
Contributor

Looking at it.

@jpbelang
Copy link
Contributor

jpbelang commented May 12, 2017

Seems I don't check the "intermediate paths" correctly.
I'm working on something, but in the meantime, could you

/ViewingSession:
  /{viewingSessionId}/Attachments:
      uriParameters:
        viewingSessionId:
          type: string
      get:
        responses:
          200:
            body:
              application/json:
                type: string

Certainly not ideal, but I currently am working on a fix.

jpbelang added a commit that referenced this issue May 12, 2017
@jpbelang
Copy link
Contributor

jpbelang commented May 12, 2017

Just pushed a fix, with a UT and added to the torture test. It's in the 2.0.1 branch.

Feedback por favor ?

@KevinMitchell
Copy link

Still not quite right. Suppose I define

/a:
  /{b}:
    uriParameters:
      b: integer
    /c:
      get:

The tool generates

@Path("/a")
public interface A {
  @GET
  @Path("/{b}/c")
  void getAC();
}

So the method getAC is missing the URI parameter.

@jpbelang
Copy link
Contributor

I'll look at it today. I thought the parser would handle stuff like this...

@KevinMitchell
Copy link

But you are generating the declaration of getAC aren't you? And presumably what you generate for that needs to include the declaration of @PathParam("b") Integer b) as arguments. The parser just provides the model, so you can access the URI/path parameters from it.

Are you also planning on allowing the methods to return an instance of Response rather than just void?

@jpbelang
Copy link
Contributor

@KevinMitchell Yes, but it does some things to help you, and not others: I'll have to go fetch PathParams from the parent resources.

As to the second question, I'm not sure I get what you are saying: we do return a response. Which case are you talking about ?

@KevinMitchell
Copy link

Yes, you are correct. It was me getting confused on this occasion. I tried to make the example as simple as possible, but it ended up being too simple, had left out the response code, and so you quite correctly didn't generate anything. So ignore that bit :-)

So it's just the path param we are missing.

Thanks,
Kevin

@jpbelang
Copy link
Contributor

Check again when you have time please.

@KevinMitchell
Copy link

That looks better. Thanks for the prompt response.

@jpbelang
Copy link
Contributor

Good. Closing. If something else comes up, ping!

@jpbelang jpbelang reopened this May 20, 2017
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

3 participants