use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class FormDataBodyPartTest method testFormDataBodyPart.
@Test(description = "FormDataBodyPart should be ignored when generating the Swagger document")
public void testFormDataBodyPart() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithFormData.class);
final List<Parameter> parameters = swagger.getPath("/test/document/{documentName}.json").getPost().getParameters();
assertEquals(parameters.size(), 3);
assertEquals(parameters.get(0).getName(), "documentName");
assertEquals(parameters.get(1).getName(), "input");
assertEquals(parameters.get(2).getName(), "id");
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ScannerTest method scanAnotherResource.
@Test(description = "scan another resource")
public void scanAnotherResource() {
final Swagger swagger = getSwagger(ResourceWithComplexBodyInputType.class);
final Operation post = swagger.getPaths().get("/myapi/testPostWithBody").getPost();
assertNotNull(post);
assertNotNull(swagger.getDefinitions());
assertNotNull(swagger.getDefinitions().get("ClassWithString"));
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ScannerTest method scanBeanParamResource.
@Test(description = "scan a bean param resource")
public void scanBeanParamResource() {
final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
final List<Parameter> params = getParameters(swagger, "/bean/{id}");
final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
assertEquals(headerParam1.getDefaultValue(), 1);
assertEquals(headerParam1.getName(), "test order annotation 1");
final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
assertEquals(headerParam2.getDefaultValue(), 2);
assertEquals(headerParam2.getName(), "test order annotation 2");
final QueryParameter priority1 = (QueryParameter) params.get(2);
assertNull(priority1.getDefaultValue());
assertEquals(priority1.getName(), "test priority 1");
final QueryParameter priority2 = (QueryParameter) params.get(3);
assertEquals(priority2.getDefaultValue(), 4);
assertEquals(priority2.getName(), "test priority 2");
final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
assertEquals(bodyParam1.getDefaultValue(), "bodyParam");
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ScannerTest method scanResourceWithExtensions.
@Test(description = "scan resource with extensions")
public void scanResourceWithExtensions() throws JsonProcessingException {
final Swagger swagger = getSwagger(ResourceWithExtensions.class);
assertNotNull(swagger);
Map<String, Object> infoExtensions = swagger.getInfo().getVendorExtensions();
assertEquals("private", infoExtensions.get("x-accessLevel"));
Map<String, Object> operationExtensions = swagger.getPath("/rest/test").getGet().getVendorExtensions();
assertEquals("/hello-world/v1/", operationExtensions.get("x-externalPath"));
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ReaderTest method scanEmptyPathAnnotation.
@Test(description = "scan empty path annotation")
public void scanEmptyPathAnnotation() {
Swagger swagger = getSwagger(ResourceWithEmptyPath.class);
assertNotNull(getGet(swagger, "/"));
}
Aggregations