本文整理汇总了Java中io.swagger.models.Info类的典型用法代码示例。如果您正苦于以下问题:Java Info类的具体用法?Java Info怎么用?Java Info使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Info类属于io.swagger.models包,在下文中一共展示了Info类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineConnectorName
import io.swagger.models.Info; //导入依赖的package包/类
@Override
protected final String determineConnectorName(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) {
final Swagger swagger = parseSpecification(connectorSettings, false).getModel();
final Info info = swagger.getInfo();
if (info == null) {
return super.determineConnectorName(connectorTemplate, connectorSettings);
}
final String title = info.getTitle();
if (title == null) {
return super.determineConnectorName(connectorTemplate, connectorSettings);
}
return title;
}
示例2: testMicroserviceMetaManager
import io.swagger.models.Info; //导入依赖的package包/类
@Test
public void testMicroserviceMetaManager() throws Exception {
MicroserviceMetaManager microserviceMetaManager = new MicroserviceMetaManager();
microserviceMetaManager.getOrCreateMicroserviceMeta("app:testname");
Assert.assertEquals("microservice meta manager", microserviceMetaManager.getName());
Assert.assertEquals("Not allow register repeat data, name=%s, key=%s",
microserviceMetaManager.getRegisterErrorFmt());
Assert.assertEquals(0, microserviceMetaManager.getAllSchemaMeta("app:testname").size());
Swagger oSwagger = new Swagger();
Info oInfo = new Info();
oInfo.setVendorExtension("x-java-interface", "java.lang.String");
oSwagger.setInfo(oInfo);
Assert.assertEquals("java.lang.String", (ClassUtils.getJavaInterface(oSwagger)).getName());
oInfo.setVendorExtension("x-java-class", "java.lang.String");
}
示例3: init
import io.swagger.models.Info; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
Info info = new Info()
.title("Swagger Server")
.description("RESTful API specification for the ElasTest Instrumentation Manager (EIM)")
.termsOfService("TBD")
.contact(new Contact()
.email("[email protected]"))
.license(new License()
.name("Apache 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0.html"));
ServletContext context = config.getServletContext();
Swagger swagger = new Swagger().info(info);
String propertiesFile = "/WEB-INF/bootstrap.properties";
Properties.load(config.getServletContext().getResourceAsStream(propertiesFile), propertiesFile);
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
示例4: determineConnectorDescription
import io.swagger.models.Info; //导入依赖的package包/类
@Override
protected final String determineConnectorDescription(final ConnectorTemplate connectorTemplate,
final ConnectorSettings connectorSettings) {
final Swagger swagger = parseSpecification(connectorSettings, false).getModel();
final Info info = swagger.getInfo();
if (info == null) {
return super.determineConnectorDescription(connectorTemplate, connectorSettings);
}
final String description = info.getDescription();
if (description == null) {
return super.determineConnectorDescription(connectorTemplate, connectorSettings);
}
return description;
}
示例5: afterPropertiesSet
import io.swagger.models.Info; //导入依赖的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);
}
示例6: registerSwaggerJsonResource
import io.swagger.models.Info; //导入依赖的package包/类
static void registerSwaggerJsonResource(ResourceConfig rc) {
new SwaggerContextService()
.withSwaggerConfig(new SwaggerConfig() {
public Swagger configure(Swagger swagger) {
Info info = new Info();
info.setTitle("App Runner");
info.setDescription("The REST API for App Runner which is used for registering apps, deploying apps, viewing logs etc.");
info.setVersion("1.0");
swagger.setInfo(info);
swagger.setBasePath("/api/v1");
return swagger;
}
public String getFilterClass() {
return null;
}
})
.withScanner(new Scanner() {
private boolean prettyPrint;
public Set<Class<?>> classes() {
return rc.getInstances().stream().map(Object::getClass).collect(Collectors.toSet());
}
public boolean getPrettyPrint() {
return prettyPrint;
}
public void setPrettyPrint(boolean b) {
prettyPrint = b;
}
})
.initConfig()
.initScanner();
rc.packages(ApiListingResource.class.getPackage().getName());
}
示例7: createServiceInfoFromOpenApi
import io.swagger.models.Info; //导入依赖的package包/类
/**
* Adds additional information to {@link Service} object.
*
* @throws OpenApiConversionException
*/
private void createServiceInfoFromOpenApi(
Service.Builder serviceBuilder, List<OpenApiFile> openApiFiles)
throws OpenApiConversionException {
for (OpenApiFile openApiFile : openApiFiles) {
//TODO(user): need better way to resolve conflicts here
if (openApiFile.swagger().getInfo() != null) {
Info info = openApiFile.swagger().getInfo();
if (info.getTitle() != null) {
serviceBuilder.setTitle(info.getTitle());
}
if (info.getDescription() != null) {
serviceBuilder.getDocumentationBuilder().setSummary(info.getDescription());
}
}
}
}
示例8: writeSwagger
import io.swagger.models.Info; //导入依赖的package包/类
private Swagger writeSwagger(Iterable<ApiConfig> configs, SwaggerContext context,
GenerationContext genCtx)
throws ApiConfigException {
ImmutableListMultimap<ApiKey, ? extends ApiConfig> configsByKey = FluentIterable.from(configs)
.index(CONFIG_TO_ROOTLESS_KEY);
Swagger swagger = new Swagger()
.produces("application/json")
.consumes("application/json")
.scheme(context.scheme)
.host(context.hostname)
.basePath(context.basePath)
.info(new Info()
.title(context.hostname)
.version(context.docVersion));
for (ApiKey apiKey : configsByKey.keySet()) {
writeApi(apiKey, configsByKey.get(apiKey), swagger, genCtx);
}
writeQuotaDefinitions(swagger, genCtx);
return swagger;
}
示例9: apply
import io.swagger.models.Info; //导入依赖的package包/类
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
Info info = params.info;
License license = info.getLicense();
String termOfService = info.getTermsOfService();
if ((license != null && (isNotBlank(license.getName()) || isNotBlank(license.getUrl()))) || isNotBlank(termOfService)) {
markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(LICENSE_INFORMATION));
MarkupDocBuilder paragraph = copyMarkupDocBuilder(markupDocBuilder);
if (license != null) {
if (isNotBlank(license.getName())) {
paragraph.italicText(labels.getLabel(LICENSE)).textLine(COLON + license.getName());
}
if (isNotBlank(license.getUrl())) {
paragraph.italicText(labels.getLabel(LICENSE_URL)).textLine(COLON + license.getUrl());
}
}
paragraph.italicText(labels.getLabel(TERMS_OF_SERVICE)).textLine(COLON + termOfService);
markupDocBuilder.paragraph(paragraph.toString(), true);
}
return markupDocBuilder;
}
示例10: testLicenseInfoComponent
import io.swagger.models.Info; //导入依赖的package包/类
@Test
public void testLicenseInfoComponent() throws URISyntaxException {
Info info = new Info()
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"))
.termsOfService("Bla bla bla");
Swagger2MarkupConverter.Context context = createContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
markupDocBuilder = new LicenseInfoComponent(context).apply(markupDocBuilder, LicenseInfoComponent.parameters(info, OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);
Path expectedFile = getExpectedFile(COMPONENT_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
示例11: SwaggerBuilder
import io.swagger.models.Info; //导入依赖的package包/类
/**
* @param dictionary The entity dictionary
* @param info Basic service information that cannot be generated
*/
public SwaggerBuilder(EntityDictionary dictionary, Info info) {
this.dictionary = dictionary;
globalResponses = new HashMap<>();
globalParams = new HashSet<>();
allClasses = new HashSet<>();
filterOperators = Sets.newHashSet(
Operator.IN,
Operator.NOT,
Operator.INFIX,
Operator.PREFIX,
Operator.POSTFIX,
Operator.GE,
Operator.GT,
Operator.LE,
Operator.LT,
Operator.ISNULL,
Operator.NOTNULL
);
swagger = new Swagger();
swagger.info(info);
}
示例12: createData
import io.swagger.models.Info; //导入依赖的package包/类
private String createData() throws Exception {
final Swagger expected = new Swagger();
expected.host(HOST);
when(request.getHeader("Host")).thenReturn(HOST);
expected.info(new Info().title(CONTEXT_PATH.substring(1)).description("API Documentation").version("1.0"));
createData(DummyService.class, "/api", expected, endpointsByPathMap, GET);
createData(DummyService.class, "/api", expected, endpointsByPathMap, POST);
createData(AnnotatedDummyService.class, "/apiAnnotated", expected, endpointsByPathMap,
"an annotated test service", ANY, "millis", "millis since epoch");
final ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper.writeValueAsString(expected);
}
示例13: setJavaInterface
import io.swagger.models.Info; //导入依赖的package包/类
protected void setJavaInterface(Info info, Class<?> cls) {
if (cls.isInterface()) {
info.setVendorExtension(SwaggerConst.EXT_JAVA_INTF, cls.getName());
return;
}
// Class<?>[] interfaces = cls.getInterfaces();
// if (interfaces.length == 1) {
// info.setVendorExtension(SwaggerConst.EXT_JAVA_INTF, interfaces[0].getName());
// return;
// }
String intfName = ensureGetPackageName() + "." + cls.getSimpleName() + "Intf";
info.setVendorExtension(SwaggerConst.EXT_JAVA_INTF, intfName);
}
示例14: init
import io.swagger.models.Info; //导入依赖的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);
}
示例15: getSwagger
import io.swagger.models.Info; //导入依赖的package包/类
public ClonableSwagger getSwagger(final String basePath,
final UriInfo uriInfo) {
ClonableSwagger swagger = swaggerMap.get(basePath);
if (swagger == null) {
final int i = swaggerPaths.get(basePath);
swagger = new ClonableSwagger();
final String title = env.getProperty(String.format("swagger[%d].info.title", i));
final String version = env.getProperty(String.format("swagger[%d].info.version", i));
swagger.setBasePath('/' + basePath);
final Info info = new Info();
info.setTitle(title);
info.setVersion(version);
swagger.setInfo(info);
final Map<String, Path> pathsMap = new TreeMap<>();
final Map<String, Model> definitionsMap = new TreeMap<>();
final Map<String, SecuritySchemeDefinition> securityDefinitionsMap = new TreeMap<>();
processUris(pathsMap, definitionsMap, securityDefinitionsMap, i);
swagger.setPaths(pathsMap);
swagger.setDefinitions(definitionsMap);
swagger.setSecurityDefinitions(securityDefinitionsMap);
swaggerMap.putIfAbsent(basePath, swagger);
}
return swagger.withUriInfo(uriInfo);
}