Search in sources :

Example 36 with ApiConfig

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);
}
Also used : Swagger(io.swagger.models.Swagger) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 37 with ApiConfig

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);
}
Also used : Swagger(io.swagger.models.Swagger) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 38 with ApiConfig

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);
}
Also used : Swagger(io.swagger.models.Swagger) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 39 with ApiConfig

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

Example 40 with ApiConfig

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);
}
Also used : 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