Class ResolvedReference


  • public class ResolvedReference
    extends Object
    Represents a resolved reference that can contain three different types of content:
    • NODE: An Node representing an OpenAPI or AsyncAPI document/component
    • JSON: A JsonNode representing JSON/YAML content that isn't OpenAPI/AsyncAPI
    • TEXT: A String representing non-JSON content such as Protocol Buffers (.proto), GraphQL, Avro text schemas, etc.

    This class is used as the return type for IReferenceResolver.resolveRef(String, Node) to support dereferencing external schemas in formats other than OpenAPI/AsyncAPI, particularly for AsyncAPI 3.0 Multi-Format Schema Objects.

    Author:
    ewittman
    • Method Detail

      • fromNode

        public static ResolvedReference fromNode​(Node node)
        Creates a ResolvedReference containing a Node.
        Parameters:
        node - the Node content
        Returns:
        a ResolvedReference of type NODE
      • fromJson

        public static ResolvedReference fromJson​(com.fasterxml.jackson.databind.JsonNode jsonNode)
        Creates a ResolvedReference containing a JsonNode with application/json media type.
        Parameters:
        jsonNode - the JsonNode content
        Returns:
        a ResolvedReference of type JSON
      • fromJson

        public static ResolvedReference fromJson​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                                 String mediaType)
        Creates a ResolvedReference containing a JsonNode with a specific media type.
        Parameters:
        jsonNode - the JsonNode content
        mediaType - the media type of the content (e.g., "application/vnd.apache.avro+json;version=1.12.0")
        Returns:
        a ResolvedReference of type JSON
      • fromText

        public static ResolvedReference fromText​(String text,
                                                 String mediaType)
        Creates a ResolvedReference containing text content with a specific media type.
        Parameters:
        text - the text content
        mediaType - the media type of the content (e.g., "application/vnd.google.protobuf;version=3")
        Returns:
        a ResolvedReference of type TEXT
      • getMediaType

        public String getMediaType()
        Gets the media type of the content, if available.
        Returns:
        the media type, or null if not available
      • isNode

        public boolean isNode()
        Checks if this reference contains a Node.
        Returns:
        true if the content is a Node
      • isJson

        public boolean isJson()
        Checks if this reference contains a JsonNode.
        Returns:
        true if the content is a JsonNode
      • isText

        public boolean isText()
        Checks if this reference contains text.
        Returns:
        true if the content is text
      • asNode

        public Node asNode()
        Gets the content as a Node.
        Returns:
        the Node content
        Throws:
        ClassCastException - if the content is not a Node
      • asJson

        public com.fasterxml.jackson.databind.JsonNode asJson()
        Gets the content as a JsonNode.
        Returns:
        the JsonNode content
        Throws:
        ClassCastException - if the content is not a JsonNode
      • asText

        public String asText()
        Gets the content as text.
        Returns:
        the text content
        Throws:
        ClassCastException - if the content is not text