Class MediaTypes

java.lang.Object
com.toedter.spring.hateoas.jsonapi.MediaTypes

public class MediaTypes extends Object
Provides constants for the JSON:API media type.

This utility class defines the official JSON:API media type application/vnd.api+json as specified in the JSON:API specification. These constants can be used for content negotiation, request/response type declarations, and Spring MVC mapping annotations.

Example usage:


 @GetMapping(produces = MediaTypes.JSON_API_VALUE)
 public EntityModel<Movie> getMovie() {
   // ...
 }

 @RequestMapping(consumes = MediaTypes.JSON_API_VALUE)
 public void createMovie(@RequestBody Movie movie) {
   // ...
 }
 
See Also:
  • Field Details

    • JSON_API_VALUE

      public static final String JSON_API_VALUE
      String representation of the JSON:API media type: "application/vnd.api+json".

      Use this constant with annotations like @RequestMapping, @GetMapping, etc.

      See Also:
    • JSON_API

      public static final org.springframework.http.MediaType JSON_API
      MediaType constant for JSON:API: application/vnd.api+json.

      Use this constant for programmatic media type handling and content negotiation with Spring's MediaType API.