Show Table of Contents
15.15. YAML Provider
RESTEasy comes with built in support for YAML using the
SnakeYAML library. To enable YAML support, you must insert the following dependencies into the project pom file of your application:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-yaml-provider</artifactId>
<version>${version.org.jboss.resteasy}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${version.org.yaml.snakeyaml}</version>
</dependency>
YAML provider recognizes three mime types:
- text/x-yaml
- text/yaml
- application/x-yaml
The following example demonstrates how to use YAML in a resource method:
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/yaml")
public class YamlResource
{
@GET
@Produces("text/x-yaml")
public MyObject getMyObject() {
return createMyObject();
}
...
}

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.