-
Bug
-
Resolution: Done
-
Medium
-
Oxygen, Oxygen SR3, Oxygen SR2, Fluorine, Oxygen SR1, Fluorine SR1
-
High
In oxygen and newer version, the class org.opendaylight.netconf.sal.rest.doc.jaxrs.ApidocApplication is changed to use a GsonProvider as MessageBodyWriter
for swagger api object, such as ApiDelaration and ResourceList and so on.
GsonProvider uses com.google.gson.Gson to convert a JavaBean to a json string and is not compatitble with
the ApiDelaration which has a defined field, com.fasterxml.jackson.databind.node.ObjectNode models for the swagger model object.
The problem is that the ObjectNode is a concept in fasterxml not in Gson. com.google.gson.Gson can't correctly convert com.fasterxml.jackson.databind.node.ObjectNode,
because the converted result contains "_children" which does not belong to a JavaBean.
The Correct result converted by com.fasterxml.jackson.databind.ObjectMapper:
"models": { "unique_empty_identifier": {}, "(config)general-entity_modulePOST": { "$schema": "http://json-schema.org/draft-04/schema", "type": "object", "id": "(config)general-entity_modulePOST", "properties": { "entity": { "type": "array", "items": { "$ref": "general-entity(config)entity" } } } }, Incorrect result converted by com.google.gson.Gson: "models": { "_children": { "unique_empty_identifier": { "_children": {}, "_nodeFactory": { "_cfgBigDecimalExact": false } }, "(config)general-entity_modulePOST": { "_children": { "$schema": { "_value": "http://json-schema.org/draft-04/schema" } , "type": { "_value": "object" } , "id": { "_value": "(config)general-entity_modulePOST" } , "properties": { "_children": { "entity": { "_children": { "type": { "_value": "array" } , "items": { "_children": { "$ref": { "_value": "general-entity(config)entity" } }, "_nodeFactory": { "_cfgBigDecimalExact": false } } }, "_nodeFactory": { "_cfgBigDecimalExact": false } } }, "_nodeFactory": { "_cfgBigDecimalExact": false } } }, "_nodeFactory": { "_cfgBigDecimalExact": false } },
So, the com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider class should be used to serialize an instance of ApidocApplication. The GsonProvider class can't be used for ApidocApplication.