How to add description for JSON body

I can see the Query Parameters, Multipart Body or Formdata body have the option of add descriptions for the fields but not for the JSON body. Please support adding the JSON body description with a raw body type like following

{
   "name": "Gurkirat Singh", // User's first name
   "age": 22, // Age of the user
   "handle": "@tbhaxor" // Handle of the user
}

The above body can be interpreted by postman backend as the following

[
   { field: "name", type: "String", "description": "User's first name", value: "Gurkirat Singh" },
   { field: "age", type: "Number", "description": "Age of the user", value: 22 },
   { field: "handle", type: "String", "description": "Handle of the user", value: "@tbhaxor" }
]

Since the types of POJOs are inferrable, you can autocomplete it for the developers for their ease

That’s not a Postman limitation, that’s a limitation with JSON. The format doesn’t support comments. See: https://stackoverflow.com/questions/244777/can-comments-be-used-in-json.

4 Likes

So can’t we add an extension or parser to the JSON body before sending it to the request body? Here is the regex I created to filter out comments, key, value and for type we can do a post processing after regex extraction

You could certainly define a body and then just parse out what you need as your payload in the pre-request tab.

const body_with_comments = {
   "name": "Gurkirat Singh", // User's first name
   "age": 22, // Age of the user
   "handle": "@tbhaxor" // Handle of the user
};

I don’t know the full context of why you want descriptions but I suspect you might get better results using descriptive variable names. Something like:

{
   "name": "{{user_name}}",
   "age": "{{user_age}}",
   "handle": "{{user_handle}}"
}
1 Like