Skip to content

Commit

Permalink
[VBV-2262] [Swagger] Create new Swagger service
Browse files Browse the repository at this point in the history
+ Created a custom Swagger service.
+ Disabled SwaggerDocumentationServiceTest for now.
+ Disabled swagger2markup plugin.
+ Address checkstyle issues.
+ Add tests.
+ Change way expectedMethods are retrieved because of some $jacocoInit ghost method.
+ Rework way of comparing expected and actual ApiMethods

Change-Id: Id8b68b83bd2200acb6794f7e02b6245c32c08b27
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/45669
Closures-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
PG-Verified: jenkins <[email protected]>
Reviewed-by: Stanislav Hadjiiski <[email protected]>
CS-Verified: jenkins <[email protected]>
  • Loading branch information
AlekBoninski committed Oct 16, 2018
1 parent 87274ae commit 5c8d4e3
Show file tree
Hide file tree
Showing 13 changed files with 1,043 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,6 @@ public interface ManagementUriParts {
AuthCredentialsService.FACTORY_LINK, "default-ca-cert");
String AUTH_CREDENTIALS_CLIENT_LINK = UriUtils.buildUriPath(
AuthCredentialsService.FACTORY_LINK, "default-client-cert");

String SWAGGER_DOCUMENTATION_LINK = "/api";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ public interface SwaggerDocumentation {
public static final String INSTANCE_PATH = "/{id}";
public static final String LINE_BREAK = "<br/>";

public static interface InfoConstants {

public static final String TITLE = "Admiral API";

public static final String CONTACT_NAME = "VMware Admiral";
public static final String CONTACT_URL = "https://github.com/vmware/admiral";

public static final String LICENSE_NAME = "Apache 2 License";
public static final String LICENSE_URL = "https://github.com/vmware/admiral/blob/master/LICENSE";

public static final String DESCRIPTION =
"Admiral™ is a highly scalable and very lightweight Container Management " +
"platform for deploying and managing container\nbased applications. It is designed to have a small " +
"footprint and boot extremely quickly. Admiral™ is intended to\nprovide automated deployment and " +
"lifecycle management of containers.\n\nThis container management solution can help reduce complexity " +
"and achieve advantages including simplified and automated\napplication delivery, optimized resource " +
"utilization along with business governance and applying business policies and\noverall data center " +
"integration.";
}

public static interface DataTypes {
public static final String DATA_TYPE_STRING = "string";
public static final String DATA_TYPE_INTEGER = "integer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static class FavoriteImage extends MultiTenantDocument {

@ApiModelProperty(
value = "The name of the favorite image.",
example = "libarary/nginx",
example = "library/nginx",
required = true)
public String name;
@ApiModelProperty(
Expand Down
63 changes: 9 additions & 54 deletions host/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,54 +224,7 @@
</executions>
</plugin>

<!--Swagger-->
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger.mvn.plugin.version}</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<schemes>
<scheme>http</scheme>
<scheme>https</scheme>
</schemes>
<locations>
<location>com.vmware.admiral</location>
</locations>
<host></host>
<basePath>/</basePath>
<descriptionFile>${basedir}/swagger-resources/swaggerDescription.txt</descriptionFile>
<info>
<title>Admiral REST API</title>
<version>${project.version}</version>
<contact>
<name>VMware Admiral</name>
<url>https://github.com/vmware/admiral</url>
</contact>
<license>
<url>https://github.com/vmware/admiral/blob/master/LICENSE</url>
<name>Apache 2 license</name>
</license>
</info>
<swaggerDirectory>${swagger.spec.dir}</swaggerDirectory>
<swaggerFileName>swagger-ui</swaggerFileName>
<templatePath>${swagger.template.dir}/strapdown.html.hbs</templatePath>
<outputPath>${swagger.html.dir}/swagger-ui.html</outputPath>
<outputFormats>json,yaml</outputFormats>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<!--Markdown Documentation-->
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
Expand All @@ -284,14 +237,16 @@
</config>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>convertSwagger2markup</goal>
</goals>
</execution>
<!--Disabled because of VBV-2262-->
<!--<execution>-->
<!--<phase>install</phase>-->
<!--<goals>-->
<!--<goal>convertSwagger2markup</goal>-->
<!--</goals>-->
<!--</execution>-->
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
23 changes: 21 additions & 2 deletions host/src/main/java/com/vmware/admiral/host/ManagementHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.swagger.models.Contact;
import io.swagger.models.Info;
import io.swagger.models.License;
import io.swagger.models.Scheme;

import com.vmware.admiral.adapter.docker.service.DockerHostAdapterService;
import com.vmware.admiral.adapter.registry.service.RegistryAdapterService;
Expand All @@ -35,6 +36,7 @@
import com.vmware.admiral.auth.project.ProjectFactoryService;
import com.vmware.admiral.auth.project.ProjectService;
import com.vmware.admiral.auth.util.AuthUtil;
import com.vmware.admiral.common.SwaggerDocumentation;
import com.vmware.admiral.common.serialization.ReleaseConstants;
import com.vmware.admiral.common.util.AuthUtils;
import com.vmware.admiral.common.util.ConfigurationUtil;
Expand Down Expand Up @@ -401,8 +403,25 @@ protected void startSwaggerService() {
}

protected void startCustomSwaggerService() {
SwaggerDocumentationService newSwagger = new SwaggerDocumentationService();
this.startService(newSwagger);
SwaggerDocumentationService swaggerDocumentationService = new SwaggerDocumentationService();
Info info = new Info();

info.version(ReleaseConstants.CURRENT_API_VERSION)
.title(SwaggerDocumentation.InfoConstants.TITLE)
.description(SwaggerDocumentation.InfoConstants.DESCRIPTION)
.contact(new Contact()
.name(SwaggerDocumentation.InfoConstants.CONTACT_NAME)
.url(SwaggerDocumentation.InfoConstants.CONTACT_URL))
.license(new License()
.name(SwaggerDocumentation.InfoConstants.LICENSE_NAME)
.url(SwaggerDocumentation.InfoConstants.LICENSE_URL));

swaggerDocumentationService
.setInfo(info)
.setIncludePackages("com.vmware.admiral")
.setSchemes(Scheme.HTTP, Scheme.HTTPS);

this.startService(swaggerDocumentationService);
}

private void startExtensibilityRegistry() {
Expand Down
Loading

0 comments on commit 5c8d4e3

Please sign in to comment.