本文整理汇总了Java中io.swagger.models.Swagger.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java Swagger.setHost方法的具体用法?Java Swagger.setHost怎么用?Java Swagger.setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.Swagger
的用法示例。
在下文中一共展示了Swagger.setHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: swaggerDocProxy
import io.swagger.models.Swagger; //导入方法依赖的package包/类
@RequestMapping(value = "/swaggerDocProxy/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Swagger swaggerDocProxy(@PathVariable(value = "id") Integer id,
@RequestParam(value = "trimSystemController", defaultValue = "true") boolean trimSystemController,
HttpServletRequest request) {
Document document = documentService.findOne(id);
if (document != null) {
Swagger swagger = new SwaggerParser()
.parse(document.getContent());
if (trimSystemController) {
swagger = Generator.convertSwagger(swagger);
}
swagger.setHost(request.getServerName() + ":" + request.getServerPort() + prefix + "/" + id);
return swagger;
}
return null;
}
示例2: process
import io.swagger.models.Swagger; //导入方法依赖的package包/类
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
SwaggerDefinition definitionAnnotation = (SwaggerDefinition) annotation;
Swagger swagger = swaggerGenerator.getSwagger();
swaggerGenerator.setBasePath(definitionAnnotation.basePath());
swagger.setHost(definitionAnnotation.host());
convertConsumes(definitionAnnotation, swagger);
convertProduces(definitionAnnotation, swagger);
convertSchemes(definitionAnnotation, swagger);
convertTags(definitionAnnotation, swagger);
convertInfo(definitionAnnotation.info(), swagger);
swagger.setExternalDocs(convertExternalDocs(definitionAnnotation.externalDocs()));
}
示例3: init
import io.swagger.models.Swagger; //导入方法依赖的package包/类
public void init() {
if (!config.isConfigOk()) {
return;
}
swagger = new Swagger();
swagger.setHost(config.getHost());
swagger.setBasePath("/");
swagger.addScheme(HTTP);
swagger.addScheme(HTTPS);
Info swaggerInfo = new Info();
swaggerInfo.setDescription(config.getDescription());
swaggerInfo.setVersion(config.getVersion());
swaggerInfo.setTitle(config.getTitle());
swaggerInfo.setTermsOfService(config.getTermsOfService());
Contact contact = new Contact();
contact.setName(config.getContactName());
contact.setEmail(config.getContactEmail());
contact.setUrl(config.getContactUrl());
swaggerInfo.setContact(contact);
License license = new License();
license.setName(config.getLicenseName());
license.setUrl(config.getLicenseUrl());
swaggerInfo.setLicense(license);
swagger.setInfo(swaggerInfo);
List<Class> classes = ClassScanner.scanClassByAnnotation(RequestMapping.class, false);
Reader.read(swagger, classes);
}
示例4: parseCommon
import io.swagger.models.Swagger; //导入方法依赖的package包/类
private static Swagger parseCommon(String requestUrl, Project project) {
Swagger swagger = new Swagger();
Contact contact = new Contact();
/*contact.setName("Convertigo Support");
contact.setEmail("[email protected]");
contact.setUrl("http://www.convertigo.com/#developers");*/
Info info = new Info();
info.setContact(contact);
info.setTitle("Convertigo REST API");
info.setDescription("Find here all deployed projects");
if (project != null) {
info.setDescription(project.getComment());
info.setVersion(project.getVersion());
}
List<Scheme> schemes = new ArrayList<Scheme>();
String host;
String basePath;
Matcher matcher = parseRequestUrl.matcher(requestUrl);
if (matcher.find()) {
schemes.add(matcher.group(1) == null ? Scheme.HTTP : Scheme.HTTPS);
host = matcher.group(2);
basePath = matcher.group(3);
} else {
String webAppPath = EnginePropertiesManager.getProperty(PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
int index = webAppPath.indexOf("://") + 3;
host = webAppPath.substring(index, webAppPath.indexOf('/', index));
basePath = webAppPath.substring(index + host.length()) + "/api";
schemes.add(Scheme.HTTP);
schemes.add(Scheme.HTTPS);
}
swagger.setInfo(info);
swagger.setSchemes(schemes);
swagger.setHost(host);
swagger.setBasePath(basePath);
swagger.setConsumes(Arrays.asList("multipart/form-data", MimeType.WwwForm.value(), MimeType.Json.value(), MimeType.Xml.value()));
swagger.setProduces(Arrays.asList(MimeType.Json.value(), MimeType.Xml.value()));
return swagger;
}