mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #374 from madhawap/master
changes to swagger SecurityDefinitionConfigurator and annotations
This commit is contained in:
commit
7d7977cbdc
@ -26,13 +26,14 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given " +
|
||||
"criteria as a collection")
|
||||
@ApiModel(value = "List of activities", description = "This contains a set of activities that matches a given"
|
||||
+ " criteria as a collection")
|
||||
public class ActivityList extends BasePaginatedResult {
|
||||
|
||||
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")
|
||||
public List<Activity> getList() {
|
||||
return activities;
|
||||
@ -46,7 +47,6 @@ public class ActivityList extends BasePaginatedResult {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{\n");
|
||||
|
||||
sb.append(" count: ").append(getCount()).append(",\n");
|
||||
sb.append(" devices: [").append(activities).append("\n");
|
||||
sb.append("]}\n");
|
||||
|
||||
@ -23,15 +23,13 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class BasePaginatedResult {
|
||||
|
||||
private int count;
|
||||
private String next;
|
||||
private String previous;
|
||||
|
||||
/**
|
||||
* Number of Resources returned.
|
||||
*/
|
||||
@ApiModelProperty(value = "Number of resources returned.")
|
||||
@ApiModelProperty(value = "Number of total resources.", example = "2")
|
||||
@JsonProperty("count")
|
||||
private int count;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -29,7 +29,8 @@ public class RoleList extends BasePaginatedResult {
|
||||
|
||||
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")
|
||||
public List<String> getList() {
|
||||
return roles;
|
||||
|
||||
@ -29,12 +29,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SwaggerDefinition(
|
||||
basePath = "/api-device-mgt-v1.0",
|
||||
basePath = "/api/device-mgt/v1.0",
|
||||
host = "localhost:9443"
|
||||
)
|
||||
public class SecurityDefinitionConfigurator implements ReaderListener {
|
||||
|
||||
public static final String TOKEN_AUTH_SCHEME = "tokenAuthScheme";
|
||||
public static final String TOKEN_AUTH_SCHEME = "swagger_auth";
|
||||
|
||||
@Override
|
||||
public void beforeScan(Reader reader, Swagger swagger) {
|
||||
@ -45,9 +45,10 @@ public class SecurityDefinitionConfigurator implements ReaderListener {
|
||||
public void afterScan(Reader reader, Swagger swagger) {
|
||||
OAuth2Definition tokenScheme = new OAuth2Definition();
|
||||
tokenScheme.setType("oauth2");
|
||||
tokenScheme.setFlow("password");
|
||||
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth/token");
|
||||
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth/authorize");
|
||||
tokenScheme.setFlow("application");
|
||||
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
|
||||
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
|
||||
tokenScheme.addScope("write:everything", "Full access");
|
||||
|
||||
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
|
||||
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
|
||||
|
||||
@ -28,12 +28,20 @@ import java.io.Serializable;
|
||||
"uniquely.")
|
||||
public class DeviceIdentifier implements Serializable{
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "id",
|
||||
value = "Identity of the device.",
|
||||
required = true,
|
||||
example = "123456")
|
||||
@JsonProperty(value = "id", required = true)
|
||||
@ApiModelProperty(name = "id", value = "Identity of the device.", required = true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "type",
|
||||
value = "Type of the device.",
|
||||
required = true,
|
||||
example = "android")
|
||||
@JsonProperty(value = "type", required = true)
|
||||
@ApiModelProperty(name = "type", value = "Type of the device.", required = true)
|
||||
private String type;
|
||||
|
||||
public DeviceIdentifier() {}
|
||||
|
||||
@ -25,8 +25,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "Activity", description = "Each activity instance has a unique identifier that can be " +
|
||||
"used to identify an operation instance.")
|
||||
@ApiModel(value = "Activity", description = "An activity instance carries a unique identifier that can be " +
|
||||
"used to identify a particular operation instance uniquely")
|
||||
public class Activity {
|
||||
|
||||
public enum Type {
|
||||
@ -35,36 +35,40 @@ public class Activity {
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "activityId",
|
||||
value = "The unique activity identifier",
|
||||
required = true)
|
||||
value = "Activity identifier",
|
||||
required = true,
|
||||
example = "ACTIVITY_1")
|
||||
@JsonProperty("activityId")
|
||||
private String activityId;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "code",
|
||||
value = "The activity code",
|
||||
required = true)
|
||||
value = "Activity code",
|
||||
required = true,
|
||||
example = "DEVICE_RING")
|
||||
@JsonProperty("code")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "type",
|
||||
value = "The type of the activity, such as CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY.",
|
||||
value = "Activity type",
|
||||
required = true,
|
||||
allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY")
|
||||
allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY",
|
||||
example = "COMMAND")
|
||||
@JsonProperty("type")
|
||||
private Type type;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "createdTimeStamp",
|
||||
value = "The recorded timestamp of when the activity took place.",
|
||||
required = true)
|
||||
value = "Timestamp recorded when the activity took place",
|
||||
required = true,
|
||||
example = "Thu Oct 06 11:18:47 IST 2016")
|
||||
@JsonProperty("createdTimestamp")
|
||||
private String createdTimeStamp;
|
||||
|
||||
@ApiModelProperty(
|
||||
name = "activityStatuses",
|
||||
value = "The collection of statuses for a given activity.",
|
||||
value = "Collection of statuses corresponding to the activity",
|
||||
required = true)
|
||||
@JsonProperty("activityStatuses")
|
||||
private List<ActivityStatus> activityStatus;
|
||||
|
||||
@ -43,7 +43,8 @@ public class ActivityStatus {
|
||||
@ApiModelProperty(
|
||||
name = "status",
|
||||
value = "Status of the activity performed.",
|
||||
required = true)
|
||||
required = true,
|
||||
example = "PENDING")
|
||||
@JsonProperty("status")
|
||||
private Status status;
|
||||
|
||||
@ -57,7 +58,8 @@ public class ActivityStatus {
|
||||
@ApiModelProperty(
|
||||
name = "updatedTimestamp ",
|
||||
value = "Last updated time of the activity.",
|
||||
required = true)
|
||||
required = true,
|
||||
example = "Thu Oct 06 11:18:47 IST 2016")
|
||||
@JsonProperty("updatedTimestamp")
|
||||
private String updatedTimestamp;
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.common.operation.mgt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ -26,10 +27,20 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
+ " responses")
|
||||
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;
|
||||
@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;
|
||||
|
||||
public String getResponse() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user