Class OpenApiSerializer


  • public class OpenApiSerializer
    extends Object
    Class used to serialize an OpenAPI
    Author:
    eric.wittmann@gmail.com
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fasterxml.jackson.databind.ObjectWriter createObjectWriter​(com.fasterxml.jackson.databind.ObjectMapper objectMapper, Format format)
      Creates an ObjectWriter for the given format with the appropriate settings.
      static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Format format)
      Serializes the given OpenAPI object into either JSON or YAML and returns it as a string.
      static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi, com.fasterxml.jackson.databind.ObjectWriter writer)
      Serializes the given OpenAPI object using the provided ObjectWriter and returns it as a string.
      static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi, Format format)
      Serializes the given OpenAPI object into either JSON or YAML and returns it as a string.
    • Method Detail

      • createObjectWriter

        public static com.fasterxml.jackson.databind.ObjectWriter createObjectWriter​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                                                                     Format format)
        Creates an ObjectWriter for the given format with the appropriate settings.
        Parameters:
        objectMapper - the ObjectMapper to use
        format - the serialization format
        Returns:
        the ObjectWriter with the appropriate settings
      • serialize

        public static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi,
                                       Format format)
                                throws IOException
        Serializes the given OpenAPI object into either JSON or YAML and returns it as a string.
        Parameters:
        openApi - the OpenAPI object
        format - the serialization format
        Returns:
        OpenAPI object as a String
        Throws:
        IOException - Errors in processing the JSON
      • serialize

        public static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi,
                                       com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                       Format format)
                                throws IOException
        Serializes the given OpenAPI object into either JSON or YAML and returns it as a string.
        Parameters:
        openApi - the OpenAPI object
        objectMapper - the ObjectMapper to use
        format - the serialization format
        Returns:
        OpenAPI object as a String
        Throws:
        IOException - Errors in processing the JSON
      • serialize

        public static String serialize​(org.eclipse.microprofile.openapi.models.OpenAPI openApi,
                                       com.fasterxml.jackson.databind.ObjectWriter writer)
                                throws IOException
        Serializes the given OpenAPI object using the provided ObjectWriter and returns it as a string.
        Parameters:
        openApi - the OpenAPI object
        writer - the ObjectWriter to use
        Returns:
        OpenAPI object as a String
        Throws:
        IOException - Errors in processing the model