本文整理汇总了Java中io.swagger.models.Swagger.setBasePath方法的典型用法代码示例。如果您正苦于以下问题:Java Swagger.setBasePath方法的具体用法?Java Swagger.setBasePath怎么用?Java Swagger.setBasePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.Swagger
的用法示例。
在下文中一共展示了Swagger.setBasePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.swagger.models.Swagger; //导入方法依赖的package包/类
@Test
public void test() {
BeanUtils.setContext(Mockito.mock(ApplicationContext.class));
MicroserviceMeta mm = new MicroserviceMeta("app:ms");
List<SchemaMeta> smList = new ArrayList<>();
SwaggerGenerator generator = new SwaggerGenerator(context, TestRestEngineSchemaListenerSchemaImpl.class);
Swagger swagger = generator.generate();
swagger.setBasePath("");
SchemaMeta sm1 = new SchemaMeta(swagger, mm, "sid1");
smList.add(sm1);
RestEngineSchemaListener listener = new RestEngineSchemaListener();
SchemaMeta[] smArr = smList.toArray(new SchemaMeta[smList.size()]);
listener.onSchemaLoaded(smArr);
// 重复调用,不应该出异常
listener.onSchemaLoaded(smArr);
ServicePathManager spm = ServicePathManager.getServicePathManager(mm);
Assert.assertEquals(mm, spm.getMicroserviceMeta());
Assert.assertSame(sm1,
spm.consumerLocateOperation("/add/", "POST").getOperation().getOperationMeta().getSchemaMeta());
}
示例2: setup
import io.swagger.models.Swagger; //导入方法依赖的package包/类
@Before
public void setup() {
BeanUtils.setContext(applicationContext);
MicroserviceMeta mm = new MicroserviceMeta("app:ms");
Swagger swagger = UnitTestSwaggerUtils.generateSwagger(TestServicePathManagerSchemaImpl.class).getSwagger();
Map<String, Path> paths = swagger.getPaths();
swagger.setBasePath("");
Path path = paths.remove("/static1");
paths.put("/root/rest/static1", path);
path = paths.remove("/dynamic1");
paths.put("/dynamic1/{id}", path);
path = paths.remove("/dynamic2");
paths.put("/dynamic2/{id}", path);
SchemaMeta schemaMeta = new SchemaMeta(swagger, mm, "sid");
spm = new ServicePathManager(mm);
spm.addSchema(schemaMeta);
spm.sortPath();
}
示例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: process
import io.swagger.models.Swagger; //导入方法依赖的package包/类
@Override
protected Swagger process(Application app, ServletContext servletContext, ServletConfig sc, HttpHeaders headers, UriInfo uriInfo)
{
String path = CurrentInstitution.get().getUrlAsUrl().getPath();
Swagger swags = super.process(app, servletContext, sc, headers, uriInfo);
swags.setBasePath(path+"api");
return swags;
}
示例5: setBashPath
import io.swagger.models.Swagger; //导入方法依赖的package包/类
private void setBashPath(Swagger swagger) {
if (StringUtils.isEmpty(swagger.getBasePath())){
swagger.setBasePath(StringUtils.isEmpty(servletContext.getContextPath()) ? "/" : servletContext.getContextPath());
}
}
示例6: 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;
}