Class LocalReferenceResolver

  • All Implemented Interfaces:
    IReferenceResolver

    public class LocalReferenceResolver
    extends Object
    implements IReferenceResolver
    A class to help with resolving references. Handles recursion with loop detection.
    Author:
    eric.wittmann@gmail.com
    • Constructor Detail

      • LocalReferenceResolver

        public LocalReferenceResolver()
    • Method Detail

      • resolveRef

        public ResolvedReference resolveRef​(String $ref,
                                            Node from)
        Description copied from interface: IReferenceResolver
        Resolves a reference to a ResolvedReference.

        The resolver can return three different types of content:

        Example for a Protocol Buffers .proto file reference:

         String protoContent = "syntax = \"proto3\";\n\nmessage UserEvent {\n  string userId = 1;\n}\n";
         return ResolvedReference.fromText(protoContent, "application/vnd.google.protobuf;version=3");
         

        Example for a JSON Schema reference:

         JsonNode jsonSchema = // ... parse JSON ...
         return ResolvedReference.fromJson(jsonSchema, "application/schema+json");
         

        Example for an OpenAPI component reference:

         Node node = // ... parse and convert to Node ...
         return ResolvedReference.fromNode(node);
         
        Specified by:
        resolveRef in interface IReferenceResolver
        Parameters:
        $ref - the reference URI to resolve (e.g., "http://example.com/schema.proto")
        from - the node containing the reference
        Returns:
        a ResolvedReference containing the resolved content, or null if the resolver cannot resolve the reference