Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8720

Support custom data formats on individual REST DSL routes

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.15.1
    • Fix Version/s: None
    • Component/s: rest
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      It would be nice if I could select a custom data format for an individual REST DSL route to marshal objects differently.

      For example: Say I have a REST service that returns company data including the company's employees. But when I get an individual employee, I want to include the URI of the company in the response. So I defined a "json-standalone" data format that uses a different Jackson view.

      rest("/companies/{companyId}")
        .get()
      
      rest("/employees/{employeeId}")
        .get()
        .dataFormat("json-standalone")
      
      @Bean(name = "json-standalone")
      @Scope("prototype")
      public JacksonDataFormat dataFormat() {
          return new JacksonDataFormat(objectMapper, HashMap.class, JsonViews.Standalone.class);
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              stijn.van.bael Stijn Van Bael
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: