本文整理汇总了Java中io.swagger.jaxrs.Reader类的典型用法代码示例。如果您正苦于以下问题:Java Reader类的具体用法?Java Reader怎么用?Java Reader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Reader类属于io.swagger.jaxrs包,在下文中一共展示了Reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterScan
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
OAuth2Definition tokenScheme = new OAuth2Definition();
tokenScheme.setType("oauth2");
tokenScheme.setFlow("application");
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
tokenScheme.addScope("write:everything", "Full access");
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
swagger.setSecurityDefinitions(schemes);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
}
示例5: scanClassAnfFieldLevelAnnotations
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Test
public void scanClassAnfFieldLevelAnnotations() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithKnownInjections.class);
final List<Parameter> resourceParameters = swagger.getPaths().get("/resource/{id}").getGet().getParameters();
assertNotNull(resourceParameters);
assertEquals(4, resourceParameters.size());
assertEquals("fieldParam", getName(resourceParameters, 0));
assertEquals("skip", getName(resourceParameters, 1));
assertEquals("limit", getName(resourceParameters, 2));
assertEquals("methodParam", getName(resourceParameters, 3));
}
示例6: testFormDataBodyPart
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Test
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(5, parameters.size());
assertEquals("documentName", parameters.get(0).getName());
assertEquals("document", parameters.get(1).getName());
assertEquals("document2", parameters.get(2).getName());
assertEquals("input", parameters.get(3).getName());
assertEquals("id", parameters.get(4).getName());
}
示例7: testJacksonFeatures
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Test
public void testJacksonFeatures() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithJacksonBean.class);
final Model o = swagger.getDefinitions().get("JacksonBean");
assertEquals(Sets.newHashSet("identity", "bean", "code", "message",
"precodesuf", "premessagesuf"), o.getProperties().keySet());
}
示例8: 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;
}
}
示例9: afterScan
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
OAuth2Definition tokenScheme = new OAuth2Definition();
tokenScheme.setType("oauth2");
tokenScheme.setFlow("application");
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
tokenScheme.addScope("write:everything", "Full access");
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
swagger.setSecurityDefinitions(schemes);
//TODO: Have to add wso2-scopes to swagger definition from here
}
示例10: SwaggerModel
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Inject
public SwaggerModel(final ApplicationVersion applicationVersion,
final List<SwaggerContributor> contributors)
{
this.applicationVersion = checkNotNull(applicationVersion);
this.contributors = checkNotNull(contributors);
// filter banned types from model, such as Groovy's MetaClass
ModelConverters.getInstance().addConverter(new ModelFilter());
this.reader = new Reader(createSwagger());
}
示例11: afterScan
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
swagger.addSecurityDefinition(TOKEN_AUTH_SCHEME, new BasicAuthDefinition());
swagger.getPaths().values()
.stream()
.forEach(
path -> path.getOperations()
.stream()
.forEach(
operation -> operation.addSecurity(GraviteeApiDefinition.TOKEN_AUTH_SCHEME, null)));
}
示例12: 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;
}
示例13: beforeScan
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Override
public void beforeScan(Reader reader, Swagger swagger) {
SwaggerContext.setSwagger(swagger);
}
示例14: afterScan
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
SwaggerContext.setSwagger(null);
}
示例15: testIssue2031
import io.swagger.jaxrs.Reader; //导入依赖的package包/类
@Test
public void testIssue2031() {
final Swagger swagger = new Reader(new Swagger()).read(Resource2031.class);
assertNotNull(swagger);
}