Search code examples
restcxfwadlcxfrsraml

Expose RAML contract instead WADL in CXF


I am new in REST world, an in most of CXF examples that I saw there is an configuration to expose WADL in REST services when published.

Something like

Available RESTful services:
Endpoint address: http://localhost:8080/ouat-servicesImpl/api
WADL : http://localhost:8080/ouat-servicesImpl/api?_wadl

Then, when clicked

<application>
  <grammars/>
  <resources base="http://localhost:8080/ouat-servicesImpl/api">
    <resource path="/topics">
      <method name="POST">
        <request>
          <representation mediaType="application/json"/>
        </request>
        <response>
          <representation mediaType="application/json"/>
        </response>
      </method>
    </resource>
  </resources>
</application>

I was learning RAML and its benefits in contract creation. Is there any way to expose RAML contract in this CXF "home" service page? Or am I mixing the concepts/ purpose of RAML and WADL? Actually I think both are ways to expose services contract, however in my opinion RAML is more complete


Solution

  • Assuming you package your CXF service as a WAR, here is how you can achieve your goal, based on a real project I'm working on:

    Bonus point for: