Add support for JSON Schema in http response

Location: Node 'http in' > Node 'swagger-doc' > Responses

Currently responses can only have simple data types. It is not possible to define a more complex response through the UI. The request body already supports JSON Schema, it would be great if responses could also support JSON Schema.

Hi Alex, welcome to the community.

Can't deny that being able to validate inputs against a schema is pretty important. However, on first thought, it doesn't necessarily feel as though the core nodes would/should be amended to deal with this when a contributed node would do just as well and potentially be more flexible?

Hi, thanks for the welcome.

This feature request isn't really about validation (though I agree that validation is pretty important), but rather documentation. When you create a rest api, where's the first place anyone will check to find out how to use the endpoint? Swagger. It's already possible to define what the response will look like, it's just that the definition can't be used for complex types*.

*Actually it's already possible to define complex response types if you edit the json file directly. So JSON Schema for responses is already supported in the background, just not in the UI.

@TotallyInformation to clarify, this request is in relation to node-red-node-swagger (node) - Node-RED - a node that plugins into the HTTP nodes to add api documentation and automatically generate a swagger doc for them.

The functionality is purely around generating API docs - it doesn't modify the behaviour of the nodes.

The node is fairly old and in need of a number of updates - such as updating to newer versions of OpenAPI.

@Alex5M in terms of your request, it is a good suggestion. I'm just not sure if its something I'll have time to look at soon. But thank you for raising it.

2 Likes

Tags updated for clarity :slight_smile: