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 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 NoderesolveRefWithOptions(String $ref, Node from, ResolverOptions options)Resolves a reference from a relative position in the data model.
-
-
-
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
public static Node resolveRefWithOptions(String $ref, Node from, ResolverOptions options)
Resolves a reference from a relative position in the data model.- Parameters:
$ref-from-options-
-
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-
-
-