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;
}
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
}
}
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"));
}
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);
}
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);
}
Aggregations