Search in sources :

Example 1 with SBuildServer

use of jetbrains.buildServer.serverSide.SBuildServer in project teamcity-rest by JetBrains.

the class SwaggerConfigImpl method configure.

public Swagger configure(final Swagger swagger) {
    if (swagger == null)
        return null;
    Info info = swagger.getInfo();
    if (info == null) {
        info = new Info();
    }
    final SBuildServer server = myDataProvider.getServer();
    try {
        final URL url = new URL(server.getRootUrl());
        swagger.setHost(getHostAndPort(url));
    } catch (MalformedURLException e) {
        LOG.warnAndDebugDetails("Failed to configure swagger with server url", e);
    }
    info.setTitle("TeamCity REST API");
    final String version = myDataProvider.getPluginInfo().getParameterValue("api.version");
    if (!StringUtil.isEmptyOrSpaces(version)) {
        info.setVersion(version);
    } else {
        info.setVersion("" + server.getVersion().getDisplayVersionMajor() + "." + server.getVersion().getDisplayVersionMinor());
    }
    swagger.setInfo(info);
    return swagger;
}
Also used : MalformedURLException(java.net.MalformedURLException) SBuildServer(jetbrains.buildServer.serverSide.SBuildServer) Info(io.swagger.models.Info) URL(java.net.URL)

Aggregations

Info (io.swagger.models.Info)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 SBuildServer (jetbrains.buildServer.serverSide.SBuildServer)1