Search in sources :

Example 16 with ResolverCache

use of io.swagger.v3.parser.ResolverCache in project swagger-parser by swagger-api.

the class ResolverCacheTest method testLoadInternalParameterRef.

@Test
public void testLoadInternalParameterRef(@Injectable Parameter mockedParameter) throws Exception {
    OpenAPI openAPI = new OpenAPI();
    openAPI.components(new Components().addParameters("foo", mockedParameter));
    ResolverCache cache = new ResolverCache(openAPI, auths, null);
    Parameter actualResult = cache.loadRef("#/components/parameters/foo", RefFormat.INTERNAL, Parameter.class);
    assertEquals(actualResult, mockedParameter);
    assertNull(cache.loadRef("#/components/parameters/bar", RefFormat.INTERNAL, Parameter.class));
    assertNull(cache.loadRef("#/params/foo", RefFormat.INTERNAL, Parameter.class));
}
Also used : Components(io.swagger.v3.oas.models.Components) Parameter(io.swagger.v3.oas.models.parameters.Parameter) ResolverCache(io.swagger.v3.parser.ResolverCache) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)15 ResolverCache (io.swagger.v3.parser.ResolverCache)14 Components (io.swagger.v3.oas.models.Components)10 OpenAPI (io.swagger.v3.oas.models.OpenAPI)10 Schema (io.swagger.v3.oas.models.media.Schema)7 RefFormat (io.swagger.v3.parser.models.RefFormat)5 Expectations (mockit.Expectations)5 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Parameter (io.swagger.v3.oas.models.parameters.Parameter)2 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 NullNode (com.fasterxml.jackson.databind.node.NullNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ExternalDocumentation (io.swagger.v3.oas.models.ExternalDocumentation)1 PathItem (io.swagger.v3.oas.models.PathItem)1 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)1 ByteArraySchema (io.swagger.v3.oas.models.media.ByteArraySchema)1 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)1