use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class SwaggerGeneratorTest method testWriteSwagger_FooEndpointWithDescription.
@Test
public void testWriteSwagger_FooEndpointWithDescription() throws Exception {
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), FooDescriptionEndpoint.class);
Swagger swagger = generator.writeSwagger(ImmutableList.of(config), false, context);
Swagger expected = readExpectedAsSwagger("foo_with_description_endpoint.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_ThirdPartyAuthEndpoint.
@Test
public void testWriteSwagger_ThirdPartyAuthEndpoint() throws Exception {
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), ThirdPartyAuthEndpoint.class);
Swagger swagger = generator.writeSwagger(ImmutableList.of(config), true, context);
Swagger expected = readExpectedAsSwagger("third_party_auth.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_GoogleAuthEndpoint.
@Test
public void testWriteSwagger_GoogleAuthEndpoint() throws Exception {
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), GoogleAuthEndpoint.class);
Swagger swagger = generator.writeSwagger(ImmutableList.of(config), true, context);
Swagger expected = readExpectedAsSwagger("google_auth.swagger");
compareSwagger(expected, swagger);
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigValidator method validate.
/**
* Validates all configurations for a single API. Makes sure the API-level configuration matches
* for all classes and that the contained configuration is valid and can be turned into a *.api
* file. Only checks for swarm-specific validity. Apiary FE may still dislike a config for its
* own reasons.
*
* @throws ApiConfigInvalidException on any invalid API-wide configuration.
* @throws ApiClassConfigInvalidException on any invalid API class configuration.
* @throws ApiMethodConfigInvalidException on any invalid API method configuration.
* @throws ApiParameterConfigInvalidException on any invalid API parameter configuration.
*/
public void validate(Iterable<? extends ApiConfig> apiConfigs) throws ApiConfigInvalidException, ApiClassConfigInvalidException, ApiMethodConfigInvalidException, ApiParameterConfigInvalidException {
if (Iterables.isEmpty(apiConfigs)) {
return;
}
Map<String, ApiMethodConfig> restfulSignatures = Maps.newHashMap();
Iterator<? extends ApiConfig> i = apiConfigs.iterator();
ApiConfig first = i.next();
validate(first, restfulSignatures);
while (i.hasNext()) {
ApiConfig config = i.next();
Iterable<ApiConfigInconsistency<Object>> inconsistencies = config.getConfigurationInconsistencies(first);
if (!Iterables.isEmpty(inconsistencies)) {
throw new InconsistentApiConfigurationException(config, first, inconsistencies);
}
validate(config, restfulSignatures);
}
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testNamespaceValidation_emptyPackage.
@Test
public void testNamespaceValidation_emptyPackage() throws Exception {
ApiConfig validNamespaceEmptyPackage = configFactory.copy(config);
validNamespaceEmptyPackage.getNamespaceConfig().setOwnerDomain("domain");
validNamespaceEmptyPackage.getNamespaceConfig().setOwnerName("name");
validator.validate(validNamespaceEmptyPackage);
}
Aggregations