diff options
Diffstat (limited to 'a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java')
-rw-r--r-- | a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java index 86ae2734..e6b938a0 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationController.java @@ -23,10 +23,12 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import io.swagger.v3.oas.annotations.Operation; +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 io.swagger.v3.oas.annotations.tags.Tag; import java.io.IOException; import java.util.Optional; @@ -34,7 +36,6 @@ import java.util.Optional; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfigParser; import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ConfigurationFile; import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse; -import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ErrorResponse.ErrorInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,10 +48,13 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController("ConfigurationControllerV2") -@Api(tags = {Consts.V2_CONFIG_API_NAME}) +@Tag(name = ConfigurationController.API_NAME) public class ConfigurationController { private static final Logger logger = LoggerFactory.getLogger(ConfigurationController.class); + public static final String API_NAME = "Management of configuration"; + public static final String API_DESCRIPTION = ""; + @Autowired ConfigurationFile configurationFile; @@ -58,13 +62,18 @@ public class ConfigurationController { .create(); // @PutMapping(path = Consts.V2_API_ROOT + "/configuration", consumes = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Replace the current configuration file with the given configuration", // - notes = "Note that the file is ignored if the Consul is used.") + @Operation(summary = "Replace the current configuration file with the given configuration", // + description = "Note that the file is ignored if the Consul is used.") @ApiResponses(value = { // - @ApiResponse(code = 200, message = "Configuration updated", response = VoidResponse.class), // - @ApiResponse(code = 400, message = "Invalid configuration provided", response = ErrorInfo.class), // - @ApiResponse(code = 500, message = "Something went wrong when replacing the configuration. Try again.", - response = ErrorResponse.ErrorInfo.class) // + @ApiResponse(responseCode = "200", // + description = "Configuration updated", // + content = @Content(schema = @Schema(implementation = VoidResponse.class))), // + @ApiResponse(responseCode = "400", // + description = "Invalid configuration provided", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), // + @ApiResponse(responseCode = "500", // + description = "Something went wrong when replacing the configuration. Try again.", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // }) public ResponseEntity<Object> putConfiguration(@RequestBody Object configuration) { try { @@ -86,13 +95,17 @@ public class ConfigurationController { } @GetMapping(path = Consts.V2_API_ROOT + "/configuration", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Returns the contents of the configuration file", // - notes = "Note that the file contents is not relevant if the Consul is used.") // + @Operation(summary = "Returns the contents of the configuration file", // + description = "Note that the file contents is not relevant if the Consul is used.") // @ApiResponses(value = { // - @ApiResponse(code = 200, message = "Configuration", response = Object.class), // - @ApiResponse(code = 404, message = "File is not found or readable", - response = ErrorResponse.ErrorInfo.class)} // - ) + @ApiResponse(responseCode = "200", // + description = "Configuration", // + content = @Content(schema = @Schema(implementation = Object.class))), // + @ApiResponse(responseCode = "404", // + description = "File is not found or readable", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) + + }) public ResponseEntity<Object> getConfiguration() { try { Optional<JsonObject> rootObject = configurationFile.readFile(); |