From 707da02c7e3e822532eca04d4de56b57909fe97d Mon Sep 17 00:00:00 2001 From: Madhawa Date: Thu, 12 May 2016 21:58:23 +0530 Subject: [PATCH] Adding swagger annotations to beans --- .../pom.xml | 6 +++++ .../mgt/core/dto/CertificateResponse.java | 23 +++++++++++++++++++ .../device/mgt/jaxrs/api/Certificate.java | 3 +-- .../device/mgt/jaxrs/api/Configuration.java | 10 ++++---- .../org.wso2.carbon.device.mgt.core/pom.xml | 6 +++++ .../device/mgt/core/dto/DeviceType.java | 7 ++++++ 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index dd66b2ab02..41cd547d10 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -166,6 +166,12 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common + + + io.swagger + swagger-annotations + provided + diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/dto/CertificateResponse.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/dto/CertificateResponse.java index 5ffb8270f3..9d0504e2dc 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/dto/CertificateResponse.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/dto/CertificateResponse.java @@ -18,19 +18,42 @@ package org.wso2.carbon.certificate.mgt.core.dto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.math.BigInteger; +@ApiModel(value = "CertificateResponse", description = "This class carries all information related to certificates") public class CertificateResponse { + @ApiModelProperty(name = "certificate", value = "The certificate in bytes", required = true) byte[] certificate; + + @ApiModelProperty(name = "serialNumber", value = "It is the unique ID that is used to identify a certificate", required = true) String serialNumber; + + @ApiModelProperty(name = "tenantId", value = "The ID of the tenant who adds the certificate", required = true) int tenantId; + + @ApiModelProperty(name = "commonName", value = "In mutual SSL the common name refers to the serial number of the Android device.", required = true) String commonName; + + @ApiModelProperty(name = "notAfter", value = "The expiration date of the certificate that is inherent to the certificate", required = true) long notAfter; + + @ApiModelProperty(name = "notBefore", value = "The date from when the certificate is valid", required = true) long notBefore; + + @ApiModelProperty(name = "certificateserial", value = "The serial number of the certificate", required = true) BigInteger certificateserial; + + @ApiModelProperty(name = "issuer", value = "The identity of the authority that signs the SSL certificate", required = true) String issuer; + + @ApiModelProperty(name = "subject", value = "The identity of the certificate", required = true) String subject; + + @ApiModelProperty(name = "certificateVersion", value = "The version of the certificate", required = true) int certificateVersion; public long getNotAfter() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java index 8bfcd31f66..96c865f07f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Certificate.java @@ -56,8 +56,7 @@ public interface Certificate { produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, httpMethod = "POST", value = "Adding an SSL Certificate", - notes = "Add a new SSL certificate to the client end database", - response = MediaType.class) + notes = "Add a new SSL certificate to the client end database") @ApiResponses(value = { @ApiResponse(code = 200, message = "Added successfully"), @ApiResponse(code = 500, message = "Error occurred while saving the certificate") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java index c7bc7759cf..12e21f451b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/Configuration.java @@ -46,10 +46,9 @@ public interface Configuration { produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, httpMethod = "POST", value = "Configuring general platform settings", - notes = "Configure the general platform settings using this REST API", - response = ResponsePayload.class) + notes = "Configure the general platform settings using this REST API") @ApiResponses(value = { - @ApiResponse(code = 200, message = "Tenant configuration saved successfully"), + @ApiResponse(code = 201, message = "Tenant configuration saved successfully"), @ApiResponse(code = 500, message = "Error occurred while saving the tenant configuration") }) Response saveTenantConfiguration(@ApiParam(name = "configuration", value = "The required properties to " @@ -76,10 +75,9 @@ public interface Configuration { produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, httpMethod = "PUT", value = "Updating General Platform Configurations", - notes = "Update the notification frequency using this REST API", - response = ResponsePayload.class) + notes = "Update the notification frequency using this REST API") @ApiResponses(value = { - @ApiResponse(code = 200, message = "Tenant configuration updated successfully"), + @ApiResponse(code = 201, message = "Tenant configuration updated successfully"), @ApiResponse(code = 500, message = "Error occurred while updating the tenant configuration") }) Response updateConfiguration(@ApiParam(name = "configuration", value = "The required properties to update" diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index bb73550ff6..183d211f8e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -245,6 +245,12 @@ 1.7.1 + + io.swagger + swagger-annotations + provided + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java index 52ca3ac891..eb363fff1c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/DeviceType.java @@ -18,12 +18,19 @@ package org.wso2.carbon.device.mgt.core.dto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; +@ApiModel(value = "DeviceType", description = "This class carries all information related device types") public class DeviceType implements Serializable { private static final long serialVersionUID = 7927802716452548282L; + + @ApiModelProperty(name = "id", value = "Device type id", required = true) private int id; + @ApiModelProperty(name = "name", value = "Device type name", required = true) private String name; public DeviceType() {