use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class SimpleReaderTest method scanSimpleResourceWithoutAnnotations.
@Test(description = "scan a simple resource without annotations")
public void scanSimpleResourceWithoutAnnotations() {
DefaultReaderConfig config = new DefaultReaderConfig();
config.setScanAllResources(true);
Swagger swagger = new Reader(new Swagger(), config).read(SimpleResourceWithoutAnnotations.class);
assertEquals(swagger.getPaths().size(), 2);
Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertEquals(get.getParameters().size(), 2);
PathParameter param1 = (PathParameter) get.getParameters().get(0);
assertEquals(param1.getIn(), "path");
assertEquals(param1.getName(), "id");
assertTrue(param1.getRequired());
assertNull(param1.getDescription());
assertEquals(param1.getDefaultValue(), "5");
Parameter param2 = get.getParameters().get(1);
assertEquals(param2.getIn(), "query");
assertEquals(param2.getName(), "limit");
assertFalse(param2.getRequired());
assertNull(param2.getDescription());
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class SubResourceReaderTest method readAnotherResourceWithSubresources.
@Test(description = "scan another resource with subresources")
public void readAnotherResourceWithSubresources() {
final Swagger swagger = getSwagger(TestResource.class);
final Operation get = getGet(swagger, "/test/more/otherStatus");
assertEquals(get.getOperationId(), "otherStatus");
final Parameter qp = get.getParameters().get(0);
assertEquals(qp.getIn(), "query");
assertEquals(qp.getName(), "qp");
assertTrue(get.getProduces().containsAll(Arrays.asList("application/json", "application/xml")));
assertEquals(swagger.getPaths().keySet().size(), 2);
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ReaderTest method scanParametersFromBaseResource.
@Test(description = "it should scan parameters from base resource class")
public void scanParametersFromBaseResource() {
Swagger swagger = getSwagger(BookResource.class);
assertNotNull(swagger);
List<Parameter> parameters = getGet(swagger, "/{id}/v1/books/{name}").getParameters();
assertEquals(parameters.size(), 4);
Parameter description = parameters.get(0);
assertTrue(description instanceof PathParameter);
assertEquals(description.getName(), "description");
assertEquals(description.getDescription(), "Overridden description");
Parameter id = parameters.get(1);
assertTrue(id instanceof PathParameter);
assertEquals(id.getName(), "id");
assertEquals(id.getDescription(), "The Identifier of entity");
Parameter test = parameters.get(2);
assertTrue(test instanceof QueryParameter);
assertEquals(test.getName(), "test");
assertEquals(test.getDescription(), "Test Query Param");
Parameter name = parameters.get(3);
assertTrue(name instanceof PathParameter);
assertEquals(name.getName(), "name");
assertEquals(name.getDescription(), "The books name");
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class RegexPathParamTest method scanSimpleResource.
@Test(description = "scan a simple resource")
public void scanSimpleResource() {
Swagger swagger = new Reader(new Swagger()).read(RegexPathParamResource.class);
Operation get = swagger.getPaths().get("/{report_type}").getGet();
Parameter param = get.getParameters().get(0);
assertEquals(param.getName(), "report_type");
assertEquals(param.getPattern(), "[aA-zZ]+");
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithReadOnlyAndEmptyValueParams.
@Test(description = "scan a resource with read-only and empty value parameters")
public void scanClassWithReadOnlyAndEmptyValueParams() {
Swagger swagger = getSwagger(Issue1979Resource.class);
Parameter readOnlyParam = swagger.getPath("/fun/readOnly").getGet().getParameters().get(0);
assertTrue(readOnlyParam.isReadOnly());
Parameter allowEmptyParam = swagger.getPath("/fun/allowEmpty").getGet().getParameters().get(0);
assertTrue(allowEmptyParam.getAllowEmptyValue());
}
Aggregations