io.swagger.models.Swagger.setInfo()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中io.swagger.models.Swagger.setInfo()方法的一些代码示例,展示了Swagger.setInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.setInfo()方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:setInfo

Swagger.setInfo介绍

暂无

代码示例

代码示例来源:origin: apache/servicecomb-java-chassis

private void correctInfo() {
 Info info = swagger.getInfo();
 if (info == null) {
  info = new Info();
  swagger.setInfo(info);
 }
 if (StringUtils.isEmpty(info.getTitle())) {
  info.setTitle("swagger definition for " + cls.getName());
 }
 if (StringUtils.isEmpty(info.getVersion())) {
  info.setVersion("1.0.0");
 }
 setJavaInterface(info, cls);
}

代码示例来源:origin: vmware/admiral

/**
 * Specify the {@link Info} object to be used by Swagger. This object
 * contains general information about the API such as the title, license, etc.
 *
 * @param info The {@link Info} object used by Swagger
 * @return This instance of {@link SwaggerDocumentationAssembler}
 */
public SwaggerDocumentationAssembler setInfo(Info info) {
  this.swagger.setInfo(info);
  return this;
}

代码示例来源:origin: io.swagger/swagger-models

public Swagger info(Info info) {
  this.setInfo(info);
  return this;
}

代码示例来源:origin: kongchen/swagger-maven-plugin

public AbstractDocumentSource(Log log, ApiSource apiSource) throws MojoFailureException {
  LOG = log;
  this.outputPath = apiSource.getOutputPath();
  this.templatePath = apiSource.getTemplatePath();
  this.swaggerPath = apiSource.getSwaggerDirectory();
  this.modelSubstitute = apiSource.getModelSubstitute();
  this.jsonExampleValues = apiSource.isJsonExampleValues();
  swagger = new Swagger();
  if (apiSource.getSchemes() != null) {
    for (String scheme : apiSource.getSchemes()) {
      swagger.scheme(Scheme.forValue(scheme));
    }
  }
  // read description from file
  if (apiSource.getDescriptionFile() != null) {
    try {
      InputStream is = new FileInputStream(apiSource.getDescriptionFile());
      apiSource.getInfo().setDescription(IOUtils.toString(is));
      is.close();
    } catch (IOException e) {
      throw new MojoFailureException(e.getMessage(), e);
    }
  }
  swagger.setHost(apiSource.getHost());
  swagger.setInfo(apiSource.getInfo());
  swagger.setBasePath(apiSource.getBasePath());
  swagger.setExternalDocs(apiSource.getExternalDocs());
  this.apiSource = apiSource;
}

代码示例来源:origin: apache/servicecomb-java-chassis

private void convertInfo(io.swagger.annotations.Info infoAnnotation, Swagger swagger) {
 if (infoAnnotation == null) {
  return;
 }
 Info info = new Info();
 info.setTitle(infoAnnotation.title());
 info.setVersion(infoAnnotation.version());
 info.setDescription(infoAnnotation.description());
 info.setTermsOfService(infoAnnotation.termsOfService());
 info.setContact(convertContact(infoAnnotation.contact()));
 info.setLicense(convertLicense(infoAnnotation.license()));
 info.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(infoAnnotation.extensions()));
 swagger.setInfo(info);
}

代码示例来源:origin: springside/springtime

@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);
}

代码示例来源:origin: nutzam/nutzboot

public void init(ServletConfig config) throws ServletException {
  Ioc ioc = appContext.getIoc();
  Swagger swagger = ioc.get(Swagger.class);
  swagger.setInfo(ioc.get(Info.class, "swaggerInfo"));
  HashSet<Class<?>> classes = new HashSet<>();
  String pkgName = conf.get("swagger.resource.package", appContext.getPackage());
  for (Class<?> klass : Scans.me().scanPackage(pkgName)) {
    classes.add(klass);
  }
  Reader.read(swagger, classes);
  config.getServletContext().setAttribute("swagger", swagger);
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

private void correctInfo() {
 Info info = swagger.getInfo();
 if (info == null) {
  info = new Info();
  swagger.setInfo(info);
 }
 if (StringUtils.isEmpty(info.getTitle())) {
  info.setTitle("swagger definition for " + cls.getName());
 }
 if (StringUtils.isEmpty(info.getVersion())) {
  info.setVersion("1.0.0");
 }
 setJavaInterface(info, cls);
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private void prepareSwagger() {
  List<String> json = Collections.singletonList(Operation.MEDIA_TYPE_APPLICATION_JSON);
  this.swagger.setConsumes(json);
  this.swagger.setProduces(json);
  if (this.service.getHost().getSecureListener() != null) {
    this.swagger.setSchemes(Collections.singletonList(Scheme.HTTPS));
    URI uri = this.service.getHost().getSecureUri();
    this.swagger.setHost(uri.getHost() + ":" + uri.getPort());
  } else {
    this.swagger.setSchemes(Collections.singletonList(Scheme.HTTP));
    URI uri = this.service.getHost().getPublicUri();
    this.swagger.setHost(uri.getHost() + ":" + uri.getPort());
  }
  this.swagger.setSchemes(new ArrayList<>());
  this.swagger.setInfo(this.info);
  this.swagger.setBasePath(UriUtils.URI_PATH_CHAR);
}

代码示例来源:origin: org.ballerinalang/ballerina-to-swagger

this.createOrganizationModel(attributes.get("organization"), info);
swagger.setInfo(info);

代码示例来源:origin: Sayi/swagger-dubbo

@Override
public Swagger configure(Swagger swagger) {
  ApplicationConfig application = ReferenceManager.getInstance().getApplication();
  if (null != application) {
    Info info = swagger.getInfo();
    if (info == null) {
      info = new Info();
      swagger.setInfo(info);
    }
    info.setTitle(application.getName());
    
    version = StringUtils.isNotBlank(version) ? version : application.getVersion();
    if (StringUtils.isNotBlank(groupId) 
        && StringUtils.isNotBlank(artifactId)
        && StringUtils.isNotBlank(version)){
      info.setDescription(MessageFormat.format(mavenDependency, groupId, artifactId, version));
    }
    info.setVersion(StringUtils.isNotBlank(version) ? version : "");
    
    Contact contact = new Contact();
    info.setContact(contact);
    contact.setName(application.getOwner());
  }
  setBashPath(swagger);
  return swagger;
}

代码示例来源:origin: wso2/carbon-apimgt

swagger.setInfo(info);
Map<String, Path> stringPathMap = new HashMap();
for (UriTemplate uriTemplate : api.getUriTemplates().values()) {

代码示例来源:origin: io.swagger/swagger-jaxrs

reader.getSwagger().setInfo(info);

代码示例来源:origin: apache/cxf

private void configureSwagger() {
    swagger = new Swagger();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    Info info = new Info();
    Contact swaggerContact = new Contact();
    License swaggerLicense = new License();
    swaggerLicense.name(this.license)
      .url(this.licenseUrl);
    swaggerContact.name(this.contact);
    info.version(this.version)
      .description(this.description)
      .contact(swaggerContact)
      .license(swaggerLicense)
      .title(this.title);
    swagger.setInfo(info);
    if (this.schemes != null) {
      for (String scheme : this.schemes) {
        swagger.scheme(Scheme.forValue(scheme));
      }
    }
    swagger.setHost(this.host);
    swagger.setBasePath(this.basePath);
  }
}

代码示例来源:origin: org.kie.server/kie-server-services-swagger

@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {    	
  this.context = registry;
  
  JaxrsScanner jaxrsScanner = new DefaultJaxrsScanner();
  jaxrsScanner.setPrettyPrint(true);
  /*
   * Set our JAX-RS Scanner with SCANNER_ID_DEFAULT.
   * We need to do this before creating the BeanConfig, as this prevents the BeanConfig to register itself as the default scanner.
   * The first one wins.
   */
  SwaggerScannerLocator.getInstance().putScanner((SwaggerContextService.SCANNER_ID_DEFAULT), jaxrsScanner);
  BeanConfig beanConfig = new BeanConfig();
  
  String contextRoot = KieServerEnvironment.getContextRoot();
  if (contextRoot != null) {
    beanConfig.setBasePath(contextRoot + "/services/rest");
  }
  
  //Set the Info on the Swagger object, not on the BeanConfig ... otherwise the Info on Swagger (which will be 'null') will override the Info we set on the BeanConfig.
  beanConfig.getSwagger().setInfo(getInfo());
  beanConfig.setScan(true);
  
  initialized = true;
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

private void convertInfo(io.swagger.annotations.Info infoAnnotation, Swagger swagger) {
 if (infoAnnotation == null) {
  return;
 }
 Info info = new Info();
 info.setTitle(infoAnnotation.title());
 info.setVersion(infoAnnotation.version());
 info.setDescription(infoAnnotation.description());
 info.setTermsOfService(infoAnnotation.termsOfService());
 info.setContact(convertContact(infoAnnotation.contact()));
 info.setLicense(convertLicense(infoAnnotation.license()));
 info.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(infoAnnotation.extensions()));
 swagger.setInfo(info);
}

代码示例来源:origin: com.github.phillip-kruger/apiee-core

private Swagger createSwagger(final Set<Class<?>> classes,final URL url){
  Swagger swagger = new Reader(new Swagger()).read(classes);
  
  Info info = getSwaggerInfo(swagger);
  if(info!=null)swagger.setInfo(info);
  
  Map<String, SecuritySchemeDefinition> securityDefinitions = getSecurityDefinitions(swagger);
  if(securityDefinitions!=null)swagger.setSecurityDefinitions(securityDefinitions);
  
  String consumes = whiteLabel.getProperty(CONSUMES, null);
  if(anyIsSet(consumes))swagger.setConsumes(toList(swagger.getConsumes(),consumes));
  
  String produces = whiteLabel.getProperty(PRODUCES, null);
  if(anyIsSet(produces))swagger.setProduces(toList(swagger.getProduces(),produces));
  
  String basePath = whiteLabel.getProperty(BASE_PATH, getBasePath(swagger.getBasePath(), url));
  if(anyIsSet(basePath))swagger.setBasePath(basePath);
  
  String schemes = whiteLabel.getProperty(SCHEMES, url.getProtocol().toUpperCase());
  if(anyIsSet(schemes))swagger.setSchemes(toSchemeList(swagger.getSchemes(),schemes));
      
  String host = whiteLabel.getProperty(HOST, url.getHost() + DOUBLE_POINT + url.getPort());
  if(anyIsSet(host))swagger.setHost(host);
  
  String tags = whiteLabel.getProperty(TAGS, null);
  if(anyIsSet(tags))swagger.setTags(toTagList(swagger.getTags(),tags));
  
  return swagger;
}

代码示例来源:origin: org.wso2.msf4j/msf4j-swagger

private void updateInfoFromConfig() {
  if (getSwagger().getInfo() == null) {
    setInfo(new Info());
  }
  if (StringUtils.isNotBlank(getDescription())) {
    getSwagger().getInfo().setDescription(getDescription());
  }
  if (StringUtils.isNotBlank(getTitle())) {
    getSwagger().getInfo().setTitle(getTitle());
  }
  if (StringUtils.isNotBlank(getVersion())) {
    getSwagger().getInfo().setVersion(getVersion());
  }
  if (StringUtils.isNotBlank(getTermsOfServiceUrl())) {
    getSwagger().getInfo().setTermsOfService(getTermsOfServiceUrl());
  }
  if (getContact() != null) {
    getSwagger().getInfo().setContact((new Contact()).name(getContact()));
  }
  if (getLicense() != null && getLicenseUrl() != null) {
    getSwagger().getInfo().setLicense((new License()).name(getLicense()).url(getLicenseUrl()));
  }
  if (getSchemes() != null) {
    for (String scheme : getSchemes()) {
      reader.getSwagger().scheme(Scheme.forValue(scheme));
    }
  }
  reader.getSwagger().setInfo(getInfo());
}

代码示例来源:origin: wso2/msf4j

private void updateInfoFromConfig() {
  if (getSwagger().getInfo() == null) {
    setInfo(new Info());
  }
  if (StringUtils.isNotBlank(getDescription())) {
    getSwagger().getInfo().setDescription(getDescription());
  }
  if (StringUtils.isNotBlank(getTitle())) {
    getSwagger().getInfo().setTitle(getTitle());
  }
  if (StringUtils.isNotBlank(getVersion())) {
    getSwagger().getInfo().setVersion(getVersion());
  }
  if (StringUtils.isNotBlank(getTermsOfServiceUrl())) {
    getSwagger().getInfo().setTermsOfService(getTermsOfServiceUrl());
  }
  if (getContact() != null) {
    getSwagger().getInfo().setContact((new Contact()).name(getContact()));
  }
  if (getLicense() != null && getLicenseUrl() != null) {
    getSwagger().getInfo().setLicense((new License()).name(getLicense()).url(getLicenseUrl()));
  }
  if (getSchemes() != null) {
    for (String scheme : getSchemes()) {
      reader.getSwagger().scheme(Scheme.forValue(scheme));
    }
  }
  reader.getSwagger().setInfo(getInfo());
}

代码示例来源:origin: yangfuhai/jboot

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);
}

相关文章

微信公众号

最新文章

更多