Interface IReferenceResolver

  • All Known Implementing Classes:
    LocalReferenceResolver, ReferenceResolverChain

    public interface IReferenceResolver
    Used to resolve references ($ref or operationRef) to a JSON object. Users of the apicurio-data-models library can provide zero or more custom implementations of this interface in order to provide a way to resolve reference URI formats that are not supported by default. Internal references are supported by default. When providing custom reference resolvers, those custom resolvers will be used before any default/built-in resolvers.
    Author:
    eric.wittmann@gmail.com
    • Method Detail

      • resolveRef

        ResolvedReference resolveRef​(String reference,
                                     Node from)
        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);
         
        Parameters:
        reference - 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