jersey
  1. jersey
  2. JERSEY-638

Extend WADL to support JSON response representation

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.17
    • Component/s: core
    • Labels:
      None

      Description

      http://java.net/projects/jersey/lists/users/archive/2010-12/message/189

      The extended WADL of Jersey has a nice feature for XML documentation, where you can say:
      @response.representation.200.example

      {@link Examples#MY_SAMPLE_OBJECT}

      The WADL generator will actually marshal the MY_SAMPLE_OBJECT to XML for the documentation. That way the documentation reflects the REAL way that object would be represented. Awesome!

      Unfortunately, all of my services produce JSON. In JSON, the example is even more important because there is no equivalent of a schema for JSON. Is there anything similar available for JSON? Has anyone written anything custom that I could look at as an example?

        Activity

        Hide
        anilgmaipady added a comment -

        This patch will fix this bug. Example:

        • @response.representation.200.mediaType application/json
        • @response.representation.200.example {@link Examples#SAMPLE_ITEM}

          Will generate JSON of Examples#SAMPLE_ITEM

          * @response.representation.200.mediaType application/xml
          * @response.representation.200.example {@link Examples#SAMPLE_ITEM}

        Will generate XML of Examples#SAMPLE_ITEM

        Show
        anilgmaipady added a comment - This patch will fix this bug. Example: @response.representation.200.mediaType application/json @response.representation.200.example {@link Examples#SAMPLE_ITEM} Will generate JSON of Examples#SAMPLE_ITEM * @response.representation.200.mediaType application/xml * @response.representation.200.example {@link Examples#SAMPLE_ITEM} Will generate XML of Examples#SAMPLE_ITEM
        Hide
        berngp added a comment -

        Are there any updates to support a WADL serialized to JSON?

        Looking forward for this!
        Cheers
        Bernardo.

        Show
        berngp added a comment - Are there any updates to support a WADL serialized to JSON? Looking forward for this! Cheers Bernardo.
        Hide
        gdavison added a comment -

        You can now request a JSON version of the WADL with the mime type "application/vnd.sun.wadl+json", if you want JSON-Schema to be generated you need to look at the jersey-wadl-json-schema contrib module which will generate them for you. (See http://kingsfleet.blogspot.co.uk/2012/11/json-schema-generation-in-jersey.html)

        Show
        gdavison added a comment - You can now request a JSON version of the WADL with the mime type "application/vnd.sun.wadl+json", if you want JSON-Schema to be generated you need to look at the jersey-wadl-json-schema contrib module which will generate them for you. (See http://kingsfleet.blogspot.co.uk/2012/11/json-schema-generation-in-jersey.html )
        Hide
        sbolton added a comment - - edited

        This issue does not seem to be fixed. Generating the wadl with json schema does not solve this specific problem they are two separate things. It is the media type of the "example" that is wrong here and not creating the wadl as json or providing a json schema description of the object.

        The format of the example is already rendered as xml in the resourcedoc.xml file before the wadl is generated, if the response type is json, then the example should be json.

        • @response.representation.200.qname Root
        • @response.representation.200.mediaType application/json
        • @response.representation.200.example {@link Root#DOC_EXAMPLE}

        This is what I see when requesting the json schema version of the wadl. I have the describedby tags and I can request the schema for root. Note the example that is also included here that is still xml. We are using xslt to process the wadl and we do currently need the json-schema version, just the correct text representation of the example.

         <ns2:response status="200">
         <ns2:representation xmlns:json="http://wadl.dev.java.net/2009/02/json-schema" element="Root" mediaType="application/json" json:describedby="application.wadl/root">
         <ns2:doc>
         <ns4:p xmlns:ns4="http://www.w3.org/1999/xhtml">
        <ns4:h6>Example</ns4:h6>
         <ns4:pre>
        <ns4:code><?xml version="1.0" encoding="UTF-8" standalone="yes"?> <root/> </ns4:code>
         </ns4:pre>
         </ns4:p>
         </ns2:doc>
         </ns2:representation>
         </ns2:response>
        
        Show
        sbolton added a comment - - edited This issue does not seem to be fixed. Generating the wadl with json schema does not solve this specific problem they are two separate things. It is the media type of the "example" that is wrong here and not creating the wadl as json or providing a json schema description of the object. The format of the example is already rendered as xml in the resourcedoc.xml file before the wadl is generated, if the response type is json, then the example should be json. @response.representation.200.qname Root @response.representation.200.mediaType application/json @response.representation.200.example {@link Root#DOC_EXAMPLE} This is what I see when requesting the json schema version of the wadl. I have the describedby tags and I can request the schema for root. Note the example that is also included here that is still xml. We are using xslt to process the wadl and we do currently need the json-schema version, just the correct text representation of the example. <ns2:response status= "200" > <ns2:representation xmlns:json = "http://wadl.dev.java.net/2009/02/json-schema" element= "Root" mediaType= "application/json" json:describedby= "application.wadl/root" > <ns2:doc> <ns4:p xmlns:ns4 = "http://www.w3.org/1999/xhtml" > <ns4:h6> Example </ns4:h6> <ns4:pre> <ns4:code> <?xml version= "1.0" encoding= "UTF-8" standalone= "yes" ?> <root/> </ns4:code> </ns4:pre> </ns4:p> </ns2:doc> </ns2:representation> </ns2:response>

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            Martin Matula
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: