Search in sources :

Example 6 with OpenApiReader

use of io.swagger.v3.oas.integration.api.OpenApiReader in project swagger-core by swagger-api.

the class JaxrsOpenApiContext method buildReader.

@Override
protected OpenApiReader buildReader(OpenAPIConfiguration openApiConfiguration) throws Exception {
    OpenApiReader reader;
    if (StringUtils.isNotBlank(openApiConfiguration.getReaderClass())) {
        Class cls = getClass().getClassLoader().loadClass(openApiConfiguration.getReaderClass());
        reader = (OpenApiReader) cls.newInstance();
    } else {
        reader = new Reader();
    }
    if (reader instanceof Reader) {
        ((Reader) reader).setApplication(app);
    }
    reader.setConfiguration(openApiConfiguration);
    return reader;
}
Also used : Reader(io.swagger.v3.jaxrs2.Reader) OpenApiReader(io.swagger.v3.oas.integration.api.OpenApiReader) OpenApiReader(io.swagger.v3.oas.integration.api.OpenApiReader)

Example 7 with OpenApiReader

use of io.swagger.v3.oas.integration.api.OpenApiReader in project swagger-core by swagger-api.

the class JaxrsApplicationAndAnnotationScannerTest method shouldScanClassesFromPackages.

@Test(description = "scan a simple resource from packages")
public void shouldScanClassesFromPackages() throws Exception {
    SwaggerConfiguration config = new SwaggerConfiguration().resourcePackages(Stream.of("com.my.project.resources", "org.my.project.resources").collect(Collectors.toSet())).openAPI(new OpenAPI().info(new Info().description("TEST INFO DESC")));
    OpenApiContext ctx = new GenericOpenApiContext<>().openApiConfiguration(config).openApiReader(new Reader(config)).openApiScanner(scanner.application(null).openApiConfiguration(config)).init();
    OpenAPI openApi = ctx.read();
    assertNotNull(openApi);
    assertEquals(openApi.getPaths().keySet(), Arrays.asList("/packageA", "/packageB"));
}
Also used : Reader(io.swagger.v3.jaxrs2.Reader) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) Info(io.swagger.v3.oas.models.info.Info) OpenAPI(io.swagger.v3.oas.models.OpenAPI) SwaggerConfiguration(io.swagger.v3.oas.integration.SwaggerConfiguration) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) OpenApiContext(io.swagger.v3.oas.integration.api.OpenApiContext) Test(org.testng.annotations.Test)

Aggregations

Reader (io.swagger.v3.jaxrs2.Reader)5 OpenAPI (io.swagger.v3.oas.models.OpenAPI)5 GenericOpenApiContext (io.swagger.v3.oas.integration.GenericOpenApiContext)4 SwaggerConfiguration (io.swagger.v3.oas.integration.SwaggerConfiguration)4 OpenApiContext (io.swagger.v3.oas.integration.api.OpenApiContext)4 Info (io.swagger.v3.oas.models.info.Info)4 Test (org.testng.annotations.Test)4 OpenApiReader (io.swagger.v3.oas.integration.api.OpenApiReader)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ModelConverter (io.swagger.v3.core.converter.ModelConverter)1 ModelResolver (io.swagger.v3.core.jackson.ModelResolver)1 OpenAPIConfiguration (io.swagger.v3.oas.integration.api.OpenAPIConfiguration)1 IOException (java.io.IOException)1 Application (javax.ws.rs.core.Application)1