Uploaded image for project: 'Juneau'
  1. Juneau
  2. JUNEAU-97

Path Parameter in Parent RestResource

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 8.0.0
    • 8.1.0
    • None
    • None

    Description

      I would like to have a way to specify path param as part of the parent Resource.

      Eg. I have a parent resource teachers 

      GET /teachers  

      GET /teachers/john

      Now I want to build a child resource called students (for the teacher: john)

      GET /teachers/john/students

       

      is this something possible using parent-child resource mapping, with @RestResource parent as path /teachers/{teacherId} 

      And have a children Resource be able to pick up the teacherId. Child resource defined as

      path /students

       

      Eg. Code:

      // TeacherResource.java - Parent Resource 
      @RestResource(
              path="/teacher/{teacherId}",
              title="Teacher Resource ",
              children={
                      StudentsResource.class
              }
      )
      

      and then have a child resource

      // StudentsResource.java
      @RestResource(
              path="/students",
              title="Students",
              description="Students Related API endpoints",
      )
      
      // ....
      // with method like below, it would be great if we can pick up teacherId param from it's parent resource
      public List getStudents(@Path("teacherId") String teacherId) {
      

      Attachments

        Activity

          People

            jamesbognar James Bognar
            harish.bn Harish B N
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: