use of org.wso2.carbon.apimgt.api.APIDefinitionValidationResponse in project carbon-apimgt by wso2.
the class OAS3ParserTest method testValidateOpenAPIDefinitionWithBlankTitle.
@Test
public void testValidateOpenAPIDefinitionWithBlankTitle() throws Exception {
String relativePath = "definitions" + File.separator + "oas3" + File.separator + "oas3_blank_title.yaml";
String openApi = IOUtils.toString(getClass().getClassLoader().getResourceAsStream(relativePath), "UTF-8");
APIDefinitionValidationResponse response = oas3Parser.validateAPIDefinition(openApi, false);
Assert.assertTrue(response.isValid());
Assert.assertTrue(response.getParser().getClass().equals(oas3Parser.getClass()));
}
use of org.wso2.carbon.apimgt.api.APIDefinitionValidationResponse in project carbon-apimgt by wso2.
the class OASTestBase method testGenerateAPIDefinition.
public void testGenerateAPIDefinition(APIDefinition parser) throws Exception {
APIIdentifier identifier = new APIIdentifier("admin", "simple", "1.0.0");
API api = new API(identifier);
api.setScopes(new HashSet<>(Arrays.asList(sampleScope, extensionScope)));
api.setUriTemplates(new HashSet<>(Arrays.asList(petGet)));
String definition = parser.generateAPIDefinition(new SwaggerData(api));
APIDefinitionValidationResponse response = parser.validateAPIDefinition(definition, false);
Assert.assertTrue(response.isValid());
Assert.assertTrue(response.getParser().getClass().equals(parser.getClass()));
Set<URITemplate> uriTemplates = parser.getURITemplates(definition);
Assert.assertEquals(1, uriTemplates.size());
Assert.assertTrue(uriTemplates.contains(petGet));
Set<Scope> scopes = parser.getScopes(definition);
Assert.assertEquals(2, scopes.size());
Assert.assertTrue(scopes.contains(sampleScope));
Assert.assertTrue(scopes.contains(extensionScope));
}
use of org.wso2.carbon.apimgt.api.APIDefinitionValidationResponse in project carbon-apimgt by wso2.
the class OASTestBase method testGenerateAPIDefinitionWithExtension.
public String testGenerateAPIDefinitionWithExtension(APIDefinition parser, String content) throws Exception {
JSONObject jsonObject = new JSONObject(content);
String equalNoOfResourcesWithExtension = jsonObject.getJSONObject("equalNoOfResourcesWithExtension").toString();
Scope newScope = new Scope();
newScope.setName("newScope");
newScope.setKey("newScope");
newScope.setRoles("admin");
newScope.setDescription("newScopeDescription");
URITemplate updatedItemGet = new URITemplate();
updatedItemGet.setUriTemplate("/items");
updatedItemGet.setAuthType("Application & Application User");
updatedItemGet.setAuthTypes("Application & Application User");
updatedItemGet.setHTTPVerb("GET");
updatedItemGet.setHttpVerbs("GET");
updatedItemGet.setThrottlingTier("Unlimited");
updatedItemGet.setThrottlingTiers("Unlimited");
updatedItemGet.setScope(newScope);
updatedItemGet.setScopes(newScope);
APIIdentifier identifier = new APIIdentifier("admin", "simple", "1.0.0");
API api = new API(identifier);
api.setScopes(new HashSet<>(Arrays.asList(sampleScope, extensionScope, newScope)));
api.setUriTemplates(new HashSet<>(Arrays.asList(petPost, updatedItemGet)));
String definition = parser.generateAPIDefinition(new SwaggerData(api), equalNoOfResourcesWithExtension);
APIDefinitionValidationResponse response = parser.validateAPIDefinition(definition, false);
Assert.assertTrue(response.isValid());
return definition;
}
Aggregations