use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ReaderFixFor1959Test method readAndCompare.
private void readAndCompare(Set<Class<?>> testClasses, Set<String> expectedOperationIds) {
Swagger swagger = new Swagger();
new Reader(swagger).read(testClasses);
Set<String> actualOperationIds = new HashSet<String>();
for (Path path : swagger.getPaths().values()) {
for (Operation operation : path.getOperations()) {
actualOperationIds.add(operation.getOperationId());
}
}
Assert.assertEquals(actualOperationIds, expectedOperationIds);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findPostOperationWithObjectsCollection.
@Test(description = "find a Post operation with collection of objects")
public void findPostOperationWithObjectsCollection() {
Path petPath = getPath("collectionOfObjects");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof RefProperty);
RefProperty rm = (RefProperty) inputSchema;
assertEquals(rm.getSimpleRef(), PET);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsList.
@Test(description = "find a Post operation with list of strings")
public void findAPostOperationWithStringsList() {
Path petPath = getPath("listOfStrings");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof StringProperty);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ReaderTest method scanDeclaredExceptions.
@Test(description = "scan resource with annotated exception")
public void scanDeclaredExceptions() {
Swagger swagger = getSwagger(ResourceWithCustomException.class);
assertNotNull(swagger);
Operation operation = getGet(swagger, "/{id}");
assertEquals(operation.getResponses().size(), 3);
assertTrue(operation.getResponses().containsKey("200"));
assertTrue(operation.getResponses().containsKey("400"));
assertTrue(operation.getResponses().containsKey("404"));
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class SimpleReaderTest method verifyTopLevelAuthorization.
@Test(description = "verify top-level auth #1041")
public void verifyTopLevelAuthorization() {
Swagger swagger = getSwagger(Resource1041.class);
Operation path1 = getGet(swagger, "/external/info/path1");
List<Map<String, List<String>>> security1 = path1.getSecurity();
assertEquals(security1.size(), 1);
assertNotNull(security1.get(0).get("my_auth"));
Operation path2 = getGet(swagger, "/external/info/path2");
List<Map<String, List<String>>> security2 = path2.getSecurity();
assertEquals(security2.size(), 1);
assertNotNull(security2.get(0).get("your_auth"));
}
Aggregations