本文整理汇总了Java中io.swagger.jaxrs.Reader.read方法的典型用法代码示例。如果您正苦于以下问题:Java Reader.read方法的具体用法?Java Reader.read怎么用?Java Reader.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.jaxrs.Reader
的用法示例。
在下文中一共展示了Reader.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import io.swagger.jaxrs.Reader; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
swagger = new Swagger();
Info info = new Info();
info.setTitle("GreetingService");
swagger.setInfo(info);
Map<String, Object> beans = applicationContext.getBeansWithAnnotation(SpringTimeService.class);
Set<Class<?>> classes = new HashSet<Class<?>>();
for (Object bean : beans.values()) {
classes.add(bean.getClass());
}
Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(null));
swagger = reader.read(classes);
}
示例2: getSwaggerDocFromAnnotatedClasses
import io.swagger.jaxrs.Reader; //导入方法依赖的package包/类
private String getSwaggerDocFromAnnotatedClasses(ZipFile warZipFile, Swagger swaggerStubModel) throws IOException {
SwaggerAnnotationsScanner annScan = new SwaggerAnnotationsScanner(classLoader, warZipFile);
Set<Class<?>> classes = annScan.getScannedClasses();
Reader reader = new Reader(swaggerStubModel);
Set<String> stubPaths = null;
if (swaggerStubModel != null && swaggerStubModel.getPaths() != null) {
stubPaths = swaggerStubModel.getPaths().keySet();
}
Swagger swresult = reader.read(classes);
swresult = addUrlMapping(swresult, stubPaths, annScan.getUrlMapping());
String ext = FilenameUtils.getExtension(this.outputFile.getName());
if (ext.equalsIgnoreCase("json")) {
return createJSONfromPojo(swresult);
} else if (ext.equalsIgnoreCase("yaml")){
return createYAMLfromPojo(swresult);
}
throw new IllegalArgumentException("Unsupported document type: " + ext);
}
示例3: SwaggerHandler
import io.swagger.jaxrs.Reader; //导入方法依赖的package包/类
public SwaggerHandler(
final Class<? extends Application> applicationClass) {
final ApplicationPath annotation = applicationClass.getAnnotation(ApplicationPath.class);
if (annotation != null) {
baseUri = URI.create(annotation.value()).normalize();
} else {
baseUri = URI.create("/");
}
Application application;
try {
application = applicationClass.newInstance();
} catch (InstantiationException
| IllegalAccessException e) {
throw new ExceptionInInitializerError(e);
}
swagger = new ClonableSwagger();
final Reader swaggerReader = new Reader(swagger);
final Set<Class<?>> resourceClasses = application.getClasses();
if (resourceClasses.isEmpty()) {
final String packageName = applicationClass.getPackage().getName();
final Reflections reflections = new Reflections(packageName);
reflections.getTypesAnnotatedWith(Api.class).forEach(swaggerReader::read);
reflections.getTypesAnnotatedWith(SwaggerDefinition.class).forEach(swaggerReader::read);
} else {
swaggerReader.read(applicationClass);
resourceClasses.forEach(swaggerReader::read);
}
}
示例4: getSwaggerWithClasses
import io.swagger.jaxrs.Reader; //导入方法依赖的package包/类
protected Swagger getSwaggerWithClasses() {
try {
Reader reader = new Reader(null);
Swagger swagger = reader.read(getSwaggerClasses());
processSwagger(swagger);
return swagger;
}
catch (Exception ex) {
logger.error("Uncaught exception attempting to generate Swagger", ex);
return null;
}
}
示例5: scanResourcesForJaxrsAnnotations
import io.swagger.jaxrs.Reader; //导入方法依赖的package包/类
protected synchronized Swagger scanResourcesForJaxrsAnnotations(final Application app, final ServletConfig sc) {
Swagger swagger = null;
final Scanner scanner = ScannerFactory.getScanner();
LOGGER.debug("using scanner " + scanner);
if (scanner != null) {
SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
swagger = getSwagger();
Set<Class<?>> classes = null;
if (scanner instanceof JaxrsScanner) {
final JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner;
classes = jaxrsScanner.classesFromContext(app, sc);
} else {
classes = scanner.classes();
}
if (classes != null) {
final Reader reader = new Reader(swagger);
swagger = reader.read(classes);
if (scanner instanceof SwaggerConfig) {
swagger = ((SwaggerConfig) scanner).configure(swagger);
} else {
LOGGER.debug("no configurator");
}
}
}
initialized = true;
return swagger;
}