Merge pull request #374 from madhawap/master

changes to swagger SecurityDefinitionConfigurator and annotations
revert-70aa11f8
Kamidu Sachith Punchihewa 8 years ago committed by GitHub
commit 7d7977cbdc

@ -26,13 +26,14 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given " + @ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given"
"criteria as a collection") + " criteria as a collection")
public class ActivityList extends BasePaginatedResult { public class ActivityList extends BasePaginatedResult {
private List<Activity> activities; private List<Activity> activities;
@ApiModelProperty(value = "List of devices returned") @ApiModelProperty(value = "Returns the list of activities that match the offset and limit parameter values"
+ " that were specified.")
@JsonProperty("activities") @JsonProperty("activities")
public List<Activity> getList() { public List<Activity> getList() {
return activities; return activities;
@ -46,7 +47,6 @@ public class ActivityList extends BasePaginatedResult {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("{\n"); sb.append("{\n");
sb.append(" count: ").append(getCount()).append(",\n"); sb.append(" count: ").append(getCount()).append(",\n");
sb.append(" devices: [").append(activities).append("\n"); sb.append(" devices: [").append(activities).append("\n");
sb.append("]}\n"); sb.append("]}\n");

@ -23,15 +23,13 @@ import io.swagger.annotations.ApiModelProperty;
public class BasePaginatedResult { public class BasePaginatedResult {
private int count;
private String next;
private String previous;
/** /**
* Number of Resources returned. * Number of Resources returned.
*/ */
@ApiModelProperty(value = "Number of resources returned.") @ApiModelProperty(value = "Number of total resources.", example = "2")
@JsonProperty("count") @JsonProperty("count")
private int count;
public int getCount() { public int getCount() {
return count; return count;
} }

@ -29,7 +29,8 @@ public class RoleList extends BasePaginatedResult {
private List<String> roles; private List<String> roles;
@ApiModelProperty(value = "List of roles returned") @ApiModelProperty(value = "Returns the list of roles that match the offset and limit parameter values "
+ "that were specified.")
@JsonProperty("roles") @JsonProperty("roles")
public List<String> getList() { public List<String> getList() {
return roles; return roles;

@ -29,12 +29,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@SwaggerDefinition( @SwaggerDefinition(
basePath = "/api-device-mgt-v1.0", basePath = "/api/device-mgt/v1.0",
host = "localhost:9443" host = "localhost:9443"
) )
public class SecurityDefinitionConfigurator implements ReaderListener { public class SecurityDefinitionConfigurator implements ReaderListener {
public static final String TOKEN_AUTH_SCHEME = "tokenAuthScheme"; public static final String TOKEN_AUTH_SCHEME = "swagger_auth";
@Override @Override
public void beforeScan(Reader reader, Swagger swagger) { public void beforeScan(Reader reader, Swagger swagger) {
@ -45,9 +45,10 @@ public class SecurityDefinitionConfigurator implements ReaderListener {
public void afterScan(Reader reader, Swagger swagger) { public void afterScan(Reader reader, Swagger swagger) {
OAuth2Definition tokenScheme = new OAuth2Definition(); OAuth2Definition tokenScheme = new OAuth2Definition();
tokenScheme.setType("oauth2"); tokenScheme.setType("oauth2");
tokenScheme.setFlow("password"); tokenScheme.setFlow("application");
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth/token"); tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth/authorize"); tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
tokenScheme.addScope("write:everything", "Full access");
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>(); Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme); schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);

@ -28,12 +28,20 @@ import java.io.Serializable;
"uniquely.") "uniquely.")
public class DeviceIdentifier implements Serializable{ public class DeviceIdentifier implements Serializable{
@ApiModelProperty(
name = "id",
value = "Identity of the device.",
required = true,
example = "123456")
@JsonProperty(value = "id", required = true) @JsonProperty(value = "id", required = true)
@ApiModelProperty(name = "id", value = "Identity of the device.", required = true)
private String id; private String id;
@ApiModelProperty(
name = "type",
value = "Type of the device.",
required = true,
example = "android")
@JsonProperty(value = "type", required = true) @JsonProperty(value = "type", required = true)
@ApiModelProperty(name = "type", value = "Type of the device.", required = true)
private String type; private String type;
public DeviceIdentifier() {} public DeviceIdentifier() {}

@ -25,8 +25,8 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
@ApiModel(value = "Activity", description = "Each activity instance has a unique identifier that can be " + @ApiModel(value = "Activity", description = "An activity instance carries a unique identifier that can be " +
"used to identify an operation instance.") "used to identify a particular operation instance uniquely")
public class Activity { public class Activity {
public enum Type { public enum Type {
@ -35,36 +35,40 @@ public class Activity {
@ApiModelProperty( @ApiModelProperty(
name = "activityId", name = "activityId",
value = "The unique activity identifier", value = "Activity identifier",
required = true) required = true,
example = "ACTIVITY_1")
@JsonProperty("activityId") @JsonProperty("activityId")
private String activityId; private String activityId;
@ApiModelProperty( @ApiModelProperty(
name = "code", name = "code",
value = "The activity code", value = "Activity code",
required = true) required = true,
example = "DEVICE_RING")
@JsonProperty("code") @JsonProperty("code")
private String code; private String code;
@ApiModelProperty( @ApiModelProperty(
name = "type", name = "type",
value = "The type of the activity, such as CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY.", value = "Activity type",
required = true, required = true,
allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY") allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY",
example = "COMMAND")
@JsonProperty("type") @JsonProperty("type")
private Type type; private Type type;
@ApiModelProperty( @ApiModelProperty(
name = "createdTimeStamp", name = "createdTimeStamp",
value = "The recorded timestamp of when the activity took place.", value = "Timestamp recorded when the activity took place",
required = true) required = true,
example = "Thu Oct 06 11:18:47 IST 2016")
@JsonProperty("createdTimestamp") @JsonProperty("createdTimestamp")
private String createdTimeStamp; private String createdTimeStamp;
@ApiModelProperty( @ApiModelProperty(
name = "activityStatuses", name = "activityStatuses",
value = "The collection of statuses for a given activity.", value = "Collection of statuses corresponding to the activity",
required = true) required = true)
@JsonProperty("activityStatuses") @JsonProperty("activityStatuses")
private List<ActivityStatus> activityStatus; private List<ActivityStatus> activityStatus;

@ -43,7 +43,8 @@ public class ActivityStatus {
@ApiModelProperty( @ApiModelProperty(
name = "status", name = "status",
value = "Status of the activity performed.", value = "Status of the activity performed.",
required = true) required = true,
example = "PENDING")
@JsonProperty("status") @JsonProperty("status")
private Status status; private Status status;
@ -57,7 +58,8 @@ public class ActivityStatus {
@ApiModelProperty( @ApiModelProperty(
name = "updatedTimestamp ", name = "updatedTimestamp ",
value = "Last updated time of the activity.", value = "Last updated time of the activity.",
required = true) required = true,
example = "Thu Oct 06 11:18:47 IST 2016")
@JsonProperty("updatedTimestamp") @JsonProperty("updatedTimestamp")
private String updatedTimestamp; private String updatedTimestamp;

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.common.operation.mgt; package org.wso2.carbon.device.mgt.common.operation.mgt;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -26,10 +27,20 @@ import io.swagger.annotations.ApiModelProperty;
+ " responses") + " responses")
public class OperationResponse { public class OperationResponse {
@ApiModelProperty(name = "response", value = "Operation response returned from the device", required = true) @ApiModelProperty(
name = "response",
value = "Operation response returned from the device",
required = true,
example = "SUCCESSFUL")
@JsonProperty("response")
private String response; private String response;
@ApiModelProperty(name = "receivedTimeStamp", value = "Time that the operation response received",
required = true) @ApiModelProperty(
name = "receivedTimeStamp",
value = "Time that the operation response received",
required = true,
example = "Thu Oct 06 11:18:47 IST 2016")
@JsonProperty("receivedTimeStamp")
private String receivedTimeStamp; private String receivedTimeStamp;
public String getResponse() { public String getResponse() {

Loading…
Cancel
Save