Package io.apicurio.datamodels.refs
Class ReferenceUtil
- java.lang.Object
-
- io.apicurio.datamodels.refs.ReferenceUtil
-
public class ReferenceUtil extends Object
- Author:
- eric.wittmann@gmail.com
-
-
Constructor Summary
Constructors Constructor Description ReferenceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleancanResolveRef(String $ref, Node from)Returns true only if the given reference can be resolved relative to the given document.static booleanhasValue(Object value)Check if the property value exists (is not undefined and is not null).static com.fasterxml.jackson.databind.node.ObjectNoderesolveFragmentFromJS(com.fasterxml.jackson.databind.node.ObjectNode contextNode, String fragment)Resolves the given $ref fragment (e.g.static NoderesolveNodeRef(Node node)Resolves a node reference.static NoderesolveNodeRefWithOptions(Node node, ResolverOptions options)Resolves a node reference.static NoderesolveRef(String $ref, Node from)Resolves a reference from a relative position in the data model.static ResolvedReferenceresolveRefAsReference(String $ref, Node from)Resolves a reference and returns it as a ResolvedReference.static ResolvedReferenceresolveRefAsReferenceWithOptions(String $ref, Node from, ResolverOptions options)Resolves a reference from a relative position in the data model, returning a ResolvedReference.static NoderesolveRefWithOptions(String $ref, Node from, ResolverOptions options)Deprecated.UseresolveRefAsReferenceWithOptions(String, Node, ResolverOptions)for full access to all content types
-
-
-
Method Detail
-
resolveNodeRef
public static Node resolveNodeRef(Node node)
Resolves a node reference. If there is no "$ref" property on the node, then the node itself is returned. If there is a "$ref" property, then it is resolved (if possible) to another node.- Parameters:
node-
-
resolveNodeRefWithOptions
public static Node resolveNodeRefWithOptions(Node node, ResolverOptions options)
Resolves a node reference. If there is no "$ref" property on the node, then the node itself is returned. If there is a "$ref" property, then it is resolved (if possible) to another node.- Parameters:
node-options-
-
resolveRef
public static Node resolveRef(String $ref, Node from)
Resolves a reference from a relative position in the data model. Returns null if the $ref is null or cannot be resolved. Attemps to recursively resolve nodes.- Parameters:
$ref-from-
-
resolveRefWithOptions
@Deprecated public static Node resolveRefWithOptions(String $ref, Node from, ResolverOptions options)
Deprecated.UseresolveRefAsReferenceWithOptions(String, Node, ResolverOptions)for full access to all content typesResolves a reference from a relative position in the data model. Backward-compatible method that returns a Node. If the resolved reference is not a Node (e.g., JSON or Text), this method returns null.- Parameters:
$ref- the reference to resolvefrom- the node from which to resolveoptions- resolver options
-
resolveRefAsReferenceWithOptions
public static ResolvedReference resolveRefAsReferenceWithOptions(String $ref, Node from, ResolverOptions options)
Resolves a reference from a relative position in the data model, returning a ResolvedReference. This method supports all content types: Node, JSON, and Text.- Parameters:
$ref- the reference to resolvefrom- the node from which to resolveoptions- resolver options- Returns:
- a ResolvedReference containing the resolved content, or null if not found
-
resolveRefAsReference
public static ResolvedReference resolveRefAsReference(String $ref, Node from)
Resolves a reference and returns it as a ResolvedReference. This is the recommended method for new code.- Parameters:
$ref- the reference to resolvefrom- the node from which to resolve- Returns:
- a ResolvedReference, or null if not found
-
canResolveRef
public static boolean canResolveRef(String $ref, Node from)
Returns true only if the given reference can be resolved relative to the given document. Examples of $ref values include: #/definitions/ExampleDefinition #/parameters/fooId #/responses/NotFoundResponse- Parameters:
$ref-from-
-
hasValue
public static boolean hasValue(Object value)
Check if the property value exists (is not undefined and is not null).- Parameters:
value-
-
resolveFragmentFromJS
public static com.fasterxml.jackson.databind.node.ObjectNode resolveFragmentFromJS(com.fasterxml.jackson.databind.node.ObjectNode contextNode, String fragment)Resolves the given $ref fragment (e.g. /components/schemas/MySchema) against the given JS Object context. This operates against raw javascript, not against a data model.- Parameters:
contextNode-fragment-
-
-