Search in sources :

Example 31 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.

the class ApiConfigLoader method loadInternalConfiguration.

/**
 * Only used for internal-mechanism Apis.  Loads default values for class-wide configuration.
 * Most validation is skipped/ignored as these Apis are not configurable and often follow
 * different rules anyway.
 */
public ApiConfig loadInternalConfiguration(ServiceContext serviceContext, Class<?> endpointClass) throws ApiConfigException {
    ApiConfig config = configFactory.create(serviceContext, typeLoader, endpointClass);
    config.setName(INTERNAL_API_NAME);
    annotationSource.loadEndpointMethods(serviceContext, endpointClass, config.getApiClassConfig().getMethods());
    return config;
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig)

Example 32 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.

the class ApiAnnotationIntrospectorTest method testGetSerializerTypeWithIncompatibleSourceType.

@Test
public void testGetSerializerTypeWithIncompatibleSourceType() throws Exception {
    try {
        ApiConfig config = new ApiConfig.Factory().create(ServiceContext.create(), new TypeLoader(), TestEndpoint.class);
        ApiAnnotationIntrospector.getSchemaType(TypeToken.of(BadSerializerBean.class), config);
        fail("no exception thrown when a bad serializer was specified");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : TypeLoader(com.google.api.server.spi.TypeLoader) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 33 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.

the class JsonConfigWriterTest method apiCollation.

@Test
public void apiCollation() throws Exception {
    ApiConfig config2 = configFactory.copy(apiConfig);
    ApiConfig config3 = configFactory.copy(apiConfig);
    ApiConfig config4 = configFactory.copy(apiConfig);
    ApiConfig config5 = configFactory.copy(apiConfig);
    ApiConfig config6 = configFactory.copy(apiConfig);
    config4.setVersion("v2");
    config5.setVersion("v2");
    config6.setName("differentApi");
    Map<ApiKey, String> jsonConfigs = writer.writeConfig(ImmutableList.of(apiConfig, config2, config3, config4, config5, config6));
    assertEquals(3, jsonConfigs.size());
    assertThat(jsonConfigs.keySet()).containsExactly(new ApiKey("myapi", "v1", "https://myapp.appspot.com/_ah/api"), new ApiKey("myapi", "v2", "https://myapp.appspot.com/_ah/api"), new ApiKey("differentApi", "v1", "https://myapp.appspot.com/_ah/api"));
}
Also used : ApiKey(com.google.api.server.spi.config.model.ApiKey) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 34 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.

the class SwaggerGeneratorTest method testWriteSwagger_ApiKeys.

@Test
public void testWriteSwagger_ApiKeys() throws Exception {
    ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), ApiKeysEndpoint.class);
    Swagger swagger = generator.writeSwagger(ImmutableList.of(config), true, context);
    Swagger expected = readExpectedAsSwagger("api_keys.swagger");
    compareSwagger(expected, swagger);
}
Also used : Swagger(io.swagger.models.Swagger) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 35 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.

the class SwaggerGeneratorTest method testWriteSwagger_FooEndpoint_internal.

@Test
public void testWriteSwagger_FooEndpoint_internal() throws Exception {
    ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), FooEndpoint.class);
    Swagger swagger = generator.writeSwagger(ImmutableList.of(config), true, context);
    Swagger expected = readExpectedAsSwagger("foo_endpoint_internal.swagger");
    compareSwagger(expected, swagger);
}
Also used : Swagger(io.swagger.models.Swagger) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Aggregations

ApiConfig (com.google.api.server.spi.config.model.ApiConfig)91 Test (org.junit.Test)72 Api (com.google.api.server.spi.config.Api)29 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)26 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)20 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)18 ApiKey (com.google.api.server.spi.config.model.ApiKey)9 Swagger (io.swagger.models.Swagger)8 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)7 TypeLoader (com.google.api.server.spi.TypeLoader)5 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)4 ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)4 ServiceContext (com.google.api.server.spi.ServiceContext)3 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ApiClass (com.google.api.server.spi.config.ApiClass)2 ApiFrontendLimits (com.google.api.server.spi.config.ApiFrontendLimits)2 ApiReference (com.google.api.server.spi.config.ApiReference)2 Named (com.google.api.server.spi.config.Named)2 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)2