summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-acelement/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-12-01 15:24:57 +0000
committerliamfallon <liam.fallon@est.tech>2022-12-06 12:53:44 +0000
commitcf5af3fd2e67b0aef402114a0f3ae263fdfc7efe (patch)
tree844e1f34ffe75187e1a76ebbfe724874f2dba188 /participant/participant-impl/participant-impl-acelement/src/main/java
parent7af90cd8fdabdd1c3ae79d3551980016d6b24f7e (diff)
Replace SpringFox with SpringDoc in CLAMP
This commit: - Remove springfox from CLAMP - updates the commissioning, AC Element, and K8S particiapnt to use the generated interface rather than the hard coded one - removes swagger annotations from handwritten code - implements SpringDoc for the <base_path>/v3/api-docs on endpoints Issue-ID: POLICY-4404 Change-Id: I49f48bc7828cb49dab854ef9ed16a9aa377983e1 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-acelement/src/main/java')
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringDocBean.java (renamed from participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringFoxConfig.java)28
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java2
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java67
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java96
4 files changed, 31 insertions, 162 deletions
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringFoxConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringDocBean.java
index 4e88e364a..11696093a 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringFoxConfig.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/SpringDocBean.java
@@ -20,27 +20,29 @@
package org.onap.policy.clamp.acm.element.config;
-import org.onap.policy.clamp.acm.element.main.rest.AcElementController;
+import io.swagger.v3.oas.models.ExternalDocumentation;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
@Configuration
-public class SpringFoxConfig {
+public class SpringDocBean {
/**
- * Docket Spring Fox Config.
+ * Bean to configure Springdoc.
*
- * @return Docket
+ * @return the OpenAPI specification
*/
@Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).select()
- .apis(RequestHandlerSelectors.basePackage(AcElementController.class.getPackageName()))
- .paths(PathSelectors.any()).build();
+ public OpenAPI acmElementParticipantOpenApi() {
+ return new OpenAPI()
+ .info(new Info().title("ACM Element Test Participant")
+ .description("CLAMP Automation Composition Management Element Test Participant API")
+ .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
+ .externalDocs(new ExternalDocumentation()
+ .description("CLAMP Automation Composition Management Documentation")
+ .url("https://docs.onap.org/projects/onap-policy-parent/en/latest/clamp/clamp.html"));
}
}
-
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
index 21394401c..d42b0d196 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/parameters/ElementTopicParameters.java
@@ -22,10 +22,12 @@ package org.onap.policy.clamp.acm.element.main.parameters;
import java.util.List;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import org.onap.policy.clamp.models.acm.messages.rest.element.DmaapConfig;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
@Data
+@EqualsAndHashCode(callSuper = false)
public class ElementTopicParameters extends TopicParameters {
/**
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java
deleted file mode 100644
index 369342b11..000000000
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AbstractRestController.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * Licensed 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.acm.element.main.rest;
-
-import javax.ws.rs.core.MediaType;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * Common superclass to provide REST endpoints for the AC element.
- */
-// @formatter:off
-@RequestMapping(
- value = "/onap/policy/clamp/acelement/v2",
- produces = {
- MediaType.APPLICATION_JSON,
- AbstractRestController.APPLICATION_YAML
- }
-)
-// @formatter:on
-public abstract class AbstractRestController {
- public static final String APPLICATION_YAML = "application/yaml";
-
- public static final String API_VERSION_NAME = "api-version";
-
- public static final String VERSION_MINOR_NAME = "X-MinorVersion";
- public static final String VERSION_MINOR_DESCRIPTION =
- "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client";
-
- public static final String VERSION_PATCH_NAME = "X-PatchVersion";
- public static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request";
-
- public static final String VERSION_LATEST_NAME = "X-LatestVersion";
- public static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
-
- public static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
- public static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
-
- public static final String OK_CODE = "200";
- public static final String CREATED_CODE = "201";
- public static final String NO_CONTENT_CODE = "204";
- public static final String AUTHENTICATION_ERROR_CODE = "401";
- public static final String BAD_REQUEST_ERROR_CODE = "400";
-
- public static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
- public static final String BAD_REQUEST_ERROR_MESSAGE = "Bad request";
- public static final String SERVER_OK_MESSAGE = "Success";
-} \ No newline at end of file
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
index afe864edc..021567a7b 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementController.java
@@ -20,117 +20,49 @@
package org.onap.policy.clamp.acm.element.main.rest;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.headers.Header;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import java.util.UUID;
import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.acm.element.main.rest.genapi.AcElementControllerApi;
import org.onap.policy.clamp.acm.element.service.ConfigService;
import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
-public class AcElementController extends AbstractRestController {
+public class AcElementController implements AcElementControllerApi {
private final ConfigService configService;
/**
- * REST endpoint to get the existing element config.
+ * REST end point to get the existing element configuration.
*
- * @return the element config params
+ * @return the element configuration parameters
*/
- // @formatter:off
- @GetMapping(path = "/config", produces = MediaType.APPLICATION_JSON_VALUE)
- @Operation(summary = "Return the element config",
- tags = { "Clamp Automation Composition AC Element Impl API" })
- @ApiResponses(
- value = {
- @ApiResponse(responseCode = OK_CODE, description = SERVER_OK_MESSAGE,
- content = @Content(schema = @Schema(implementation = ElementConfig.class)),
- headers = {
- @Header(name = API_VERSION_NAME),
- @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
- @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
- }),
- @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<ElementConfig> getElementConfig() {
+ @Override
+ public ResponseEntity<ElementConfig> getElementConfig(UUID onapRequestId) {
return new ResponseEntity<>(configService.getElementConfig(), HttpStatus.OK);
}
/**
- * REST endpoint to activate the element.
+ * REST end point to activate the element.
*
- * @param params element parameters for this ac element
+ * @param params element parameters for this AC element
*/
- // @formatter:off
- @PostMapping(path = "/activate", consumes = MediaType.APPLICATION_JSON_VALUE,
- produces = MediaType.APPLICATION_JSON_VALUE)
- @Operation(summary = "Activates the element config",
- tags = { "Clamp Automation Composition AC Element Impl API" }
- )
- @ApiResponses(
- value = {
- @ApiResponse(responseCode = CREATED_CODE, description = SERVER_OK_MESSAGE,
- headers = {
- @Header(name = API_VERSION_NAME),
- @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
- @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
- }),
- @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(responseCode = BAD_REQUEST_ERROR_CODE, description = BAD_REQUEST_ERROR_MESSAGE)
- }
- )
- // formatter:on
- public ResponseEntity<Object> activateElement(@RequestBody ElementConfig params) {
+ @Override
+ public ResponseEntity<String> activateElement(UUID onapRequestId, ElementConfig params) {
configService.activateElement(params);
return new ResponseEntity<>(HttpStatus.CREATED);
}
/**
- * REST endpoint to delete the element config.
+ * REST end point to delete the element configuration.
*
* @return Status of operation
*/
- // @formatter:off
- @DeleteMapping(path = "/deactivate")
- @Operation(summary = "Delete the element config",
- tags = { "Clamp Automation Composition AC Element Impl API" }
- )
- @ApiResponses(
- value = {
- @ApiResponse(responseCode = NO_CONTENT_CODE, description = SERVER_OK_MESSAGE,
- headers = {
- @Header(name = API_VERSION_NAME),
- @Header(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION),
- @Header(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION),
- @Header(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION)
- }),
- @ApiResponse(responseCode = AUTHENTICATION_ERROR_CODE, description = AUTHENTICATION_ERROR_MESSAGE)
- }
- )
- // @formatter:on
- public ResponseEntity<Void> deleteConfig() {
+ @Override
+ public ResponseEntity<Void> deleteConfig(UUID onapRequestId) {
configService.deleteConfig();
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}