Version 4

    Built in YAML provider

     

    Since Beta 6, resteasy comes with built in support for YAML using the Jyaml library. To enable YAML support, you need to drop in the jyaml-1.3.jar in RestEASY's classpath.

     

    Classpath

     

    Jyaml jar file can either be downloaded from sourceforge: https://sourceforge.net/project/showfiles.php?group_id=153924

     

    Or if you use maven, the jyaml jar is available through the main repositories and included using this dependency:

     

          <dependency>
            <groupId>org.jyaml</groupId>
            <artifactId>jyaml</artifactId>
            <version>1.3</version>
          </dependency>      
    

     

    When starting resteasy look out in the logs for a line stating that the YamlProvider has been added - this indicates that resteasy has found the Jyaml jar:

     

    2877 Main INFO org.jboss.resteasy.plugins.providers.RegisterBuiltin - Adding YamlProvider

     

    Mime Types

     

    The Yaml provider recognises three mime types:

     

    • text/x-yaml

    • text/yaml

    • application/x-yaml

     

    Example

     

    This is an example of how to use Yaml in a resource method.

     

    
    import javax.ws.rs.ConsumeMime;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.ProduceMime;
    
    @Path("/yaml")
    public class YamlResource
    {
       
       @GET
       @ProduceMime("text/x-yaml")
       public MyObject getMyObject() {
          return createMyObject();
       }
    ...
    }