Search in sources :

Example 1 with ApiConfigInconsistency

use of com.google.api.server.spi.config.ApiConfigInconsistency 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);
    }
}
Also used : ApiConfigInconsistency(com.google.api.server.spi.config.ApiConfigInconsistency) ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) ApiConfig(com.google.api.server.spi.config.model.ApiConfig)

Aggregations

ApiConfigInconsistency (com.google.api.server.spi.config.ApiConfigInconsistency)1 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)1 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)1