Search in sources :

Example 1 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class CheckReadableApiTest method createContext.

private static ReaderContext createContext(Class<?> cls, boolean readHidden) {
    final ReaderContext context = createContext(cls);
    context.setReadHidden(readHidden);
    return context;
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext)

Example 2 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class ConsumesProducesTest method applyConsumesProducesTest1.

@Test(dataProvider = "resourceWithAnnotations")
public void applyConsumesProducesTest1(String methodName, List<String> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    final Method method = findMethod(context, methodName);
    extension.applyConsumes(context, operation, method);
    extension.applyProduces(context, operation, method);
    Assert.assertEquals(operation.getConsumes(), expected);
    Assert.assertEquals(operation.getProduces(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 3 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class HttpMethodGetterTest method getHttpMethodTest.

@Test(dataProvider = "resources")
public void getHttpMethodTest(String methodName, String expected) throws NoSuchMethodException {
    final ReaderContext context = createDefaultContext();
    Assert.assertEquals(extension.getHttpMethod(context, findMethod(context, methodName)), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Test(org.testng.annotations.Test)

Example 4 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class ImplicitParametersTest method applyImplicitParametersTest.

@Test(dataProvider = "resourceWithAnnotations")
public void applyImplicitParametersTest(String methodName, int expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyImplicitParameters(context, operation, findMethod(context, methodName));
    Assert.assertEquals(operation.getParameters().size(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 5 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class PathGetterTest method getPathWithoutApiTest.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void getPathWithoutApiTest(String methodName, String expected) throws NoSuchMethodException {
    final ReaderContext context = createDefaultContextWithoutApi();
    context.setParentPath("/tests");
    Assert.assertEquals(extension.getPath(context, findMethod(context, methodName)), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Test(org.testng.annotations.Test)

Aggregations

ReaderContext (io.swagger.servlet.ReaderContext)16 Test (org.testng.annotations.Test)15 Operation (io.swagger.models.Operation)12 Response (io.swagger.models.Response)2 Method (java.lang.reflect.Method)2 BodyParameter (io.swagger.models.parameters.BodyParameter)1 Parameter (io.swagger.models.parameters.Parameter)1 PathParameter (io.swagger.models.parameters.PathParameter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1