Package io.apicurio.datamodels.refs
Class ResolvedReference
- java.lang.Object
-
- io.apicurio.datamodels.refs.ResolvedReference
-
public class ResolvedReference extends Object
Represents a resolved reference that can contain three different types of content:- NODE: An
Noderepresenting an OpenAPI or AsyncAPI document/component - JSON: A
JsonNoderepresenting 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
- NODE: An
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResolvedReference.ResolvedReferenceTypeEnumeration of the types of content that can be contained in aResolvedReference.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNodeasJson()Gets the content as a JsonNode.NodeasNode()Gets the content as a Node.StringasText()Gets the content as text.static ResolvedReferencefromJson(com.fasterxml.jackson.databind.JsonNode jsonNode)Creates a ResolvedReference containing a JsonNode with application/json media type.static ResolvedReferencefromJson(com.fasterxml.jackson.databind.JsonNode jsonNode, String mediaType)Creates a ResolvedReference containing a JsonNode with a specific media type.static ResolvedReferencefromNode(Node node)Creates a ResolvedReference containing a Node.static ResolvedReferencefromText(String text, String mediaType)Creates a ResolvedReference containing text content with a specific media type.StringgetMediaType()Gets the media type of the content, if available.ResolvedReference.ResolvedReferenceTypegetReferenceType()Gets the type of content in this reference.booleanisJson()Checks if this reference contains a JsonNode.booleanisNode()Checks if this reference contains a Node.booleanisText()Checks if this reference contains text.
-
-
-
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 contentmediaType- 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 contentmediaType- the media type of the content (e.g., "application/vnd.google.protobuf;version=3")- Returns:
- a ResolvedReference of type TEXT
-
getReferenceType
public ResolvedReference.ResolvedReferenceType getReferenceType()
Gets the type of content in this reference.- Returns:
- the reference type
-
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
-
-