forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-6608: Add Swagger UI to Management REST API (apache#3431)
Authored-by: Jens Deppe <[email protected]>
- Loading branch information
1 parent
2402cac
commit 232dc0f
Showing
19 changed files
with
263 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...g/apache/geode/management/internal/rest/SwaggerManagementVerificationIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.management.internal.rest; | ||
|
||
|
||
import static org.apache.geode.test.junit.rules.HttpResponseAssert.assertResponse; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import org.apache.geode.test.junit.categories.RestAPITest; | ||
import org.apache.geode.test.junit.categories.SecurityTest; | ||
import org.apache.geode.test.junit.rules.GeodeHttpClientRule; | ||
import org.apache.geode.test.junit.rules.LocatorStarterRule; | ||
import org.apache.geode.test.junit.rules.RequiresGeodeHome; | ||
|
||
@Category({SecurityTest.class, RestAPITest.class}) | ||
public class SwaggerManagementVerificationIntegrationTest { | ||
|
||
@ClassRule | ||
public static LocatorStarterRule locatorStarter = new LocatorStarterRule() | ||
.withHttpService() | ||
.withAutoStart(); | ||
|
||
@Rule | ||
public GeodeHttpClientRule client = new GeodeHttpClientRule(locatorStarter::getHttpPort); | ||
|
||
@Rule | ||
public RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome(); | ||
|
||
@Test | ||
public void isSwaggerRunning() throws Exception { | ||
// Check the UI | ||
assertResponse(client.get("/geode-management/swagger-ui.html")).hasStatusCode(200); | ||
|
||
// Check the JSON | ||
JsonNode json = | ||
assertResponse(client.get("/geode-management/v2/api-docs")).hasStatusCode(200) | ||
.getJsonObject(); | ||
assertThat(json.get("swagger").asText(), is("2.0")); | ||
|
||
JsonNode info = json.get("info"); | ||
assertThat(info.get("description").asText(), | ||
is("REST API and interface to manage Geode components.")); | ||
assertThat(info.get("title").asText(), | ||
is("Apache Geode Management REST API")); | ||
|
||
JsonNode license = info.get("license"); | ||
assertThat(license.get("name").asText(), is("Apache License, version 2.0")); | ||
assertThat(license.get("url").asText(), is("http://www.apache.org/licenses/")); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...gement/src/main/java/org/apache/geode/management/internal/rest/swagger/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional information regarding | ||
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package org.apache.geode.management.internal.rest.swagger; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
|
||
@PropertySource({"classpath:swagger-management.properties"}) | ||
@Configuration | ||
@EnableSwagger2 | ||
@SuppressWarnings("unused") | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.select() | ||
.apis(RequestHandlerSelectors.any()) | ||
.paths(PathSelectors.any()) | ||
.build() | ||
.apiInfo(apiInfo()); | ||
} | ||
|
||
/** | ||
* API Info as it appears on the Swagger-UI page | ||
*/ | ||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("Apache Geode Management REST API") | ||
.description( | ||
"REST API and interface to manage Geode components.") | ||
.version("1.0") | ||
.termsOfServiceUrl("http://www.apache.org/licenses/") | ||
.license("Apache License, version 2.0") | ||
.licenseUrl("http://www.apache.org/licenses/") | ||
.contact(new Contact("the Apache Geode Community", | ||
"http://geode.apache.org", | ||
"[email protected]")) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.