Search in sources :

Example 11 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV2_URL_json_extensions.

@Test
public void shouldPrepareAPIFromSwaggerV2_URL_json_extensions() throws IOException {
    final SwaggerApiEntity swaggerApiEntity = prepareUrl("io/gravitee/rest/api/management/service/swagger-withExtensions-v2.json");
    validate(swaggerApiEntity);
    validateExtensions(swaggerApiEntity);
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 12 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3WithEnumExample.

@Test
public void shouldPrepareAPIFromSwaggerV3WithEnumExample() throws IOException {
    final SwaggerApiEntity api = prepareInline("io/gravitee/rest/api/management/service/mock/enum-example.yml", true, true);
    assertEquals("v1", api.getVersion());
    assertEquals("Gravitee Import Mock Example", api.getName());
    assertEquals("graviteeimportmockexample", api.getProxy().getVirtualHosts().get(0).getPath());
    final List<String> endpoints = api.getProxy().getGroups().iterator().next().getEndpoints().stream().map(Endpoint::getTarget).collect(Collectors.toList());
    assertEquals(1, endpoints.size());
    assertTrue(endpoints.contains("/"));
    validatePolicies(api, 1, 1, asList("/"));
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 13 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3WithComplexReferences.

@Test
public void shouldPrepareAPIFromSwaggerV3WithComplexReferences() throws IOException {
    final SwaggerApiEntity api = prepareInline("io/gravitee/rest/api/management/service/mock/json-api.yml", true, true);
    validatePolicies(api, 2, 5, asList("/drives"));
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 14 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3WithExamples.

@Test
public void shouldPrepareAPIFromSwaggerV3WithExamples() throws IOException {
    final SwaggerApiEntity api = prepareInline("io/gravitee/rest/api/management/service/mock/api-with-examples.yaml", true, true);
    assertEquals("2.0.0", api.getVersion());
    assertEquals("Simple API overview", api.getName());
    assertEquals("simpleapioverview", api.getProxy().getVirtualHosts().get(0).getPath());
    assertEquals("/", api.getProxy().getGroups().iterator().next().getEndpoints().iterator().next().getTarget());
    validatePolicies(api, 2, 2, asList("/", "/v2"));
    validateRules(api, "/", 2, asList(HttpMethod.GET), "List API versions");
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 15 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3WithSimpleTypedExamples.

@Test
public void shouldPrepareAPIFromSwaggerV3WithSimpleTypedExamples() throws IOException {
    final SwaggerApiEntity api = prepareInline("io/gravitee/rest/api/management/service/mock/callback-example.yaml", true, true);
    assertEquals("1.0.0", api.getVersion());
    assertEquals("Callback Example", api.getName());
    assertEquals("callbackexample", api.getProxy().getVirtualHosts().get(0).getPath());
    assertEquals("/", api.getProxy().getGroups().iterator().next().getEndpoints().iterator().next().getTarget());
    validatePolicies(api, 1, 1, asList("/streams"));
    validateRules(api, "/streams", 2, asList(HttpMethod.POST), "subscribes a client to receive out-of-band data");
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Aggregations

SwaggerApiEntity (io.gravitee.rest.api.model.api.SwaggerApiEntity)19 Test (org.junit.Test)17 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 HttpMethod (io.gravitee.common.http.HttpMethod)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 io.gravitee.definition.model (io.gravitee.definition.model)2 Flow (io.gravitee.definition.model.flow.Flow)2 Step (io.gravitee.definition.model.flow.Step)2 Policy (io.gravitee.policy.api.swagger.Policy)2 io.gravitee.rest.api.model (io.gravitee.rest.api.model)2 GroupService (io.gravitee.rest.api.service.GroupService)2 TagService (io.gravitee.rest.api.service.TagService)2 PolicyOperationVisitorManager (io.gravitee.rest.api.service.impl.swagger.policy.PolicyOperationVisitorManager)2 OAIOperationVisitor (io.gravitee.rest.api.service.impl.swagger.visitor.v3.OAIOperationVisitor)2 PolicyHelper.clearNullValues (io.gravitee.rest.api.service.validator.PolicyHelper.clearNullValues)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 Operation (io.swagger.v3.oas.models.Operation)2 PathItem (io.swagger.v3.oas.models.PathItem)2 Collections.singleton (java.util.Collections.singleton)2