Java Code Examples for io.swagger.models.Info#setVersion()

The following examples show how to use io.swagger.models.Info#setVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiDocConfig.java    From ambari-logsearch with Apache License 2.0 8 votes vote down vote up
@Bean
public BeanConfig swaggerConfig() {
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setSchemes(new String[]{"http", "https"});
  beanConfig.setBasePath(BASE_PATH);
  beanConfig.setTitle(TITLE);
  beanConfig.setDescription(DESCRIPTION);
  beanConfig.setLicense(LICENSE);
  beanConfig.setLicenseUrl(LICENSE_URL);
  beanConfig.setScan(true);
  beanConfig.setVersion(VERSION);
  beanConfig.setResourcePackage(ServiceLogsResource.class.getPackage().getName());

  License license = new License();
  license.setName(LICENSE);
  license.setUrl(LICENSE_URL);

  Info info = new Info();
  info.setDescription(DESCRIPTION);
  info.setTitle(TITLE);
  info.setVersion(VERSION);
  info.setLicense(license);
  beanConfig.setInfo(info);
  return beanConfig;
}
 
Example 2
Source File: SwaggerUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method will create the info section of the swagger document.
 *
 * @param dataServiceName name of the data-service.
 * @param transports      enabled transports.
 * @param serverConfig    Server config object.
 * @param swaggerDoc      Swagger document object.
 * @throws AxisFault Exception occured while getting the host address from transports.
 */
private static void addSwaggerInfoSection(String dataServiceName, List<String> transports,
                                          MIServerConfig serverConfig, Swagger swaggerDoc) throws AxisFault {

    swaggerDoc.basePath("/" + SwaggerProcessorConstants.SERVICES_PREFIX + "/" + dataServiceName);

    if (transports.contains("https")) {
        swaggerDoc.addScheme(Scheme.HTTPS);
        swaggerDoc.addScheme(Scheme.HTTP);
        swaggerDoc.setHost(serverConfig.getHost("https"));
    } else {
        swaggerDoc.addScheme(Scheme.HTTP);
        swaggerDoc.setHost(serverConfig.getHost("http"));
    }

    Info info = new Info();
    info.title(dataServiceName);
    info.setVersion("1.0");
    info.description("API Definition of dataservice : " + dataServiceName);
    swaggerDoc.setInfo(info);

    swaggerDoc.addConsumes("application/json");
    swaggerDoc.addConsumes("application/xml");

    swaggerDoc.addProduces("application/json");
    swaggerDoc.addProduces("application/xml");
}
 
Example 3
Source File: OpenAPIV2GeneratorTest.java    From spring-openapi with MIT License 5 votes vote down vote up
private Info createTestInfo() {
	Info info = new Info();
	info.setTitle("Test API");
	info.setDescription("Test description");
	info.setVersion("1.0.0");
	return info;
}
 
Example 4
Source File: UpdateManager.java    From cellery-distribution with Apache License 2.0 5 votes vote down vote up
/**
 * Creates Swagger Info
 *
 * @param api API sent by controller
 * @return Swagger Info
 */
private static Info createSwaggerInfo(API api) {
    Info info = new Info();
    info.setVersion(cellConfig.getVersion());
    info.setTitle(generateAPIName(api));
    return info;
}
 
Example 5
Source File: SwaggerService.java    From heimdall with Apache License 2.0 5 votes vote down vote up
private Info getInfoByApi(Api api) {
    Info info = new Info();
    info.setTitle(api.getName());
    info.setDescription(api.getDescription());
    info.setVersion(api.getVersion());

    return info;
}
 
Example 6
Source File: JbootSwaggerManager.java    From jboot with Apache License 2.0 5 votes vote down vote up
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);

}
 
Example 7
Source File: RestServer.java    From Cheddar with Apache License 2.0 5 votes vote down vote up
private void enableAutoGenerationOfSwaggerSpecification() {
    // The main scanner class used to scan the classes for swagger + jax-rs annoatations
    final BeanConfig beanConfig = new BeanConfig();
    beanConfig.setResourcePackage("com.clicktravel.services,com.clicktravel.services.*");
    beanConfig.setSchemes(new String[] { "https" });
    beanConfig.setBasePath("/");
    final Info info = new Info();
    info.setVersion("2.0.0");
    beanConfig.setInfo(info);
    beanConfig.setTitle("Swagger Specification");
    beanConfig.setVersion("0.0.0");
    beanConfig.setScan(true);
}
 
Example 8
Source File: OAS2Parser.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * This method generates API definition to the given api
 *
 * @param swaggerData api
 * @return API definition in string format
 * @throws APIManagementException
 */
@Override
public String generateAPIDefinition(SwaggerData swaggerData) throws APIManagementException {
    Swagger swagger = new Swagger();

    //Create info object
    Info info = new Info();
    info.setTitle(swaggerData.getTitle());
    if (swaggerData.getDescription() != null) {
        info.setDescription(swaggerData.getDescription());
    }

    Contact contact = new Contact();
    //Create contact object and map business owner info
    if (swaggerData.getContactName() != null) {
        contact.setName(swaggerData.getContactName());
    }
    if (swaggerData.getContactEmail() != null) {
        contact.setEmail(swaggerData.getContactEmail());
    }
    if (swaggerData.getContactName() != null || swaggerData.getContactEmail() != null) {
        //put contact object to info object
        info.setContact(contact);
    }

    info.setVersion(swaggerData.getVersion());
    swagger.setInfo(info);
    updateSwaggerSecurityDefinition(swagger, swaggerData, "https://test.com");
    updateLegacyScopesFromSwagger(swagger, swaggerData);
    for (SwaggerData.Resource resource : swaggerData.getResources()) {
        addOrUpdatePathToSwagger(swagger, resource);
    }

    return getSwaggerJsonString(swagger);
}
 
Example 9
Source File: GenerateService.java    From sofa-rpc with Apache License 2.0 4 votes vote down vote up
public Info getInfo() {
    Info info = new Info();
    info.setVersion("");
    info.setTitle("Swagger API");
    return info;
}
 
Example 10
Source File: RestAPIResourceConfig.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public RestAPIResourceConfig() {
  register(new AbstractBinder() {
    @Override
    protected void configure() {
      bindFactory(PipelineStoreInjector.class).to(PipelineStoreTask.class);
      bindFactory(AclStoreInjector.class).to(AclStoreTask.class);
      bindFactory(StageLibraryInjector.class).to(StageLibraryTask.class);
      bindFactory(PrincipalInjector.class).to(Principal.class);
      bindFactory(URIInjector.class).to(URI.class);
      bindFactory(ConfigurationInjector.class).to(Configuration.class);
      bindFactory(RuntimeInfoInjector.class).to(RuntimeInfo.class);
      bindFactory(BuildInfoInjector.class).to(BuildInfo.class);
      bindFactory(StatsCollectorInjector.class).to(StatsCollector.class);
      bindFactory(StandAndClusterManagerInjector.class).to(Manager.class);
      bindFactory(SupportBundleInjector.class).to(SupportBundleManager.class);
      bindFactory(EventHandlerTaskInjector.class).to(EventHandlerTask.class);
      bindFactory(BlobStoreTaskInjector.class).to(BlobStoreTask.class);
      bindFactory(CredentialStoreTaskInjector.class).to(CredentialStoresTask.class);

      bindFactory(UserGroupManagerInjector.class).to(UserGroupManager.class);
      bindFactory(UsersManagerInjector.class).to(UsersManager.class);
      bindFactory(ActivationInjector.class).to(Activation.class);
    }
  });
  register(new PaginationInfoInjectorBinder());

  register(RolesAnnotationFilter.class);
  register(CsrfProtectionFilter.class);
  register(MultiPartFeature.class);

  //Hooking up Swagger-Core
  register(ApiListingResource.class);
  register(SwaggerSerializers.class);

  register(RestResponseFilter.class);

  //Configure and Initialize Swagger
  BeanConfig beanConfig = new BeanConfig();
  beanConfig.setVersion("1.0.0");
  beanConfig.setBasePath("/rest");
  beanConfig.setResourcePackage(RestAPI.class.getPackage().getName());
  beanConfig.setScan(true);
  beanConfig.setTitle("Data Collector RESTful API");

  Info info = new Info();
  info.setTitle("Data Collector RESTful API");
  info.setDescription("An Enterprise-Grade Approach to Managing Big Data in Motion");
  info.setVersion("1.0.0");
  beanConfig.setInfo(info);
}