Generated java code using RAML, but while sending response it includes metadata also. How can I exclude this? I only want to send entity as a response


#1

{
“length”: -1,
“language”: null,
“location”: null,
“allowedMethods”: [],
“metadata”: {
“Content-Type”: [
“application/json”
]
},
“mediaType”: {
“type”: “application”,
“subtype”: “json”,
“parameters”: {},
“wildcardType”: false,
“wildcardSubtype”: false
},
“status”: 200,
“date”: null,
“headers”: {
“Content-Type”: [
“application/json”
]
},
“entity”: {
“user”: “abcd”,
“password”: “xyz123”,
“group”: “mail”
},
“lastModified”: null,
“cookies”: {},
“links”: [],
“statusInfo”: “OK”,
“entityTag”: null,
“stringHeaders”: {
“Content-Type”: [
“application/json”
]
}
}


#2

So you are leaving a bit out that might help sole this… what code generator is being used? Is it RAML2JAXRS? I assume that you are using JSON Schema and the POJOs being created have extra properties you want to exclude. You may need to configure the plugin (assuming you are using Maven RAML2JARS plugin), as well as add/modify the JSON Schema to indicate to the generator to exclude stuff. I think there is, for example, the ability to put additionalProperties: false in your JSON Schema.