mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 01:41:26 +02:00
Make results of application codec and swagger doc desc consistent
Application codec returns permissions, requiredApps and features in string format. However, based on swagger doc, the codec is supposed to return array. This commit fixes the type inconsistent issue raised in application rest api. Change-Id: If47338b287518a981c98ff89ca543802579c7610
This commit is contained in:
parent
32347e0351
commit
c67ca3cf7a
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.codec.impl;
|
package org.onosproject.codec.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
import org.onosproject.app.ApplicationService;
|
import org.onosproject.app.ApplicationService;
|
||||||
@ -33,7 +34,16 @@ public final class ApplicationCodec extends JsonCodec<Application> {
|
|||||||
public ObjectNode encode(Application app, CodecContext context) {
|
public ObjectNode encode(Application app, CodecContext context) {
|
||||||
checkNotNull(app, "Application cannot be null");
|
checkNotNull(app, "Application cannot be null");
|
||||||
ApplicationService service = context.getService(ApplicationService.class);
|
ApplicationService service = context.getService(ApplicationService.class);
|
||||||
return context.mapper().createObjectNode()
|
|
||||||
|
ArrayNode permissions = context.mapper().createArrayNode();
|
||||||
|
ArrayNode features = context.mapper().createArrayNode();
|
||||||
|
ArrayNode requiredApps = context.mapper().createArrayNode();
|
||||||
|
|
||||||
|
app.permissions().forEach(p -> permissions.add(p.toString()));
|
||||||
|
app.features().forEach(f -> features.add(f));
|
||||||
|
app.requiredApps().forEach(a -> requiredApps.add(a));
|
||||||
|
|
||||||
|
ObjectNode result = context.mapper().createObjectNode()
|
||||||
.put("name", app.id().name())
|
.put("name", app.id().name())
|
||||||
.put("id", app.id().id())
|
.put("id", app.id().id())
|
||||||
.put("version", app.version().toString())
|
.put("version", app.version().toString())
|
||||||
@ -42,11 +52,14 @@ public final class ApplicationCodec extends JsonCodec<Application> {
|
|||||||
.put("readme", StringEscapeUtils.escapeJson(app.readme()))
|
.put("readme", StringEscapeUtils.escapeJson(app.readme()))
|
||||||
.put("origin", app.origin())
|
.put("origin", app.origin())
|
||||||
.put("url", app.url())
|
.put("url", app.url())
|
||||||
.put("permissions", app.permissions().toString()) // FIXME: change to an array
|
|
||||||
.put("featuresRepo", app.featuresRepo().isPresent() ?
|
.put("featuresRepo", app.featuresRepo().isPresent() ?
|
||||||
app.featuresRepo().get().toString() : "")
|
app.featuresRepo().get().toString() : "")
|
||||||
.put("features", app.features().toString()) // FIXME: change to an array
|
|
||||||
.put("requiredApps", app.requiredApps().toString()) // FIXME: change to an array
|
|
||||||
.put("state", service.getState(app.id()).toString());
|
.put("state", service.getState(app.id()).toString());
|
||||||
|
|
||||||
|
result.set("features", features);
|
||||||
|
result.set("permissions", permissions);
|
||||||
|
result.set("requiredApps", requiredApps);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
"permissions": {
|
"permissions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"xml": {
|
"xml": {
|
||||||
"name": "hosts",
|
"name": "permissions",
|
||||||
"wrapped": true
|
"wrapped": true
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
"permissions": {
|
"permissions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"xml": {
|
"xml": {
|
||||||
"name": "hosts",
|
"name": "permissions",
|
||||||
"wrapped": true
|
"wrapped": true
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
"permissions": {
|
"permissions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"xml": {
|
"xml": {
|
||||||
"name": "hosts",
|
"name": "permissions",
|
||||||
"wrapped": true
|
"wrapped": true
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user