nodebuilder icon indicating copy to clipboard operation
nodebuilder copied to clipboard

Support `"in": "body"` parameter

Open thnguyendn opened this issue 4 years ago • 9 comments

This is a bug report related to the generation of a node from a Swagger definition.

Description

I have the following Swagger definition 2.0 that I want to generate the node using nodebuilder by executing the following command : npm run generate

I generated successfully the node with this command,

However, I got the following error while I add the generated files in the following directory \packages\nodes-base\nodes{myDirectory} of the project n8n (see the following image) :

!image

Could you please review the tool nodebuilder, so that it can fix the generated error Swagger_def.txt ?

Thank you in advance for your help

thnguyendn avatar Oct 29 '21 16:10 thnguyendn

Thank you for your report. The fixes will be merged soon - meanwhile here is the correct output.

Note that nodebuilder builds most of the node, but not yet all of it - it does not create the credentials file and the icon. You will also need to fill in the placeholders USERTASK in openApiRequestAllItems in GenericFunctions.ts.

ivov avatar Nov 02 '21 08:11 ivov

Thank you for your quick reply. I will check and keep you informed

thnguyendn avatar Nov 02 '21 10:11 thnguyendn

I have just checked the generated file. The generation process terminated well. And I can add the generated file as a custom node in the n8n project.

But, there is still a problem... When you look into the Swagger definition, you will have a "schema" block that has been predefined for query parameter and for response as follows

image

However, I cannot find the code generated for schema of query parameter and schema of response.

Does your generation tool take into account these pieces of information during its generation process ?

thnguyendn avatar Nov 02 '21 11:11 thnguyendn

@ivov Do you have any idea about my question ?

thnguyendn avatar Nov 08 '21 08:11 thnguyendn

Dereferencing is supported. This works correctly for the sample Lichess spec and also for OpenCell. You can inspect the dereferenced spec at ./src/input/_deref.json after generation.

https://github.com/ivov/nodebuilder/blob/06f9d1a351429125153da8d22c35e4150146a919/src/services/OpenApiStager.ts#L36-L45

What is not supported is the "in": "body" parameter, as it had not come up in my own use cases. Will keep this issue open and support this in future, hopefully soon, as time allows.

https://github.com/ivov/nodebuilder/blob/06f9d1a351429125153da8d22c35e4150146a919/src/types/params.d.ts#L72-L80

ivov avatar Nov 11 '21 10:11 ivov

Hello @ivov , thank you very much for your reply.

I hope you can soon support "in": "body" parameter

thnguyendn avatar Nov 15 '21 10:11 thnguyendn

Hello @ivov ,

I found the file _deref.json that has been generated by processing dereferencing. However, I do not know where to add this dereferenring file in n8n project so that n8n can take into consideration this file. Any idea ?

thnguyendn avatar Nov 15 '21 13:11 thnguyendn

Nodebuilder dereferences the spec (i.e. replaces its references at $ref with the actual params) into _deref.json and then parses that file into an n8n node. Therefore, _deref.json is an only intermediate output, not meant for the user. I mentioned it above to make clear that dereferencing is taken care of.

What remains to be done is enabling the parser to generate params for "in": "body", as it does for "path", "query" and "header".

ivov avatar Nov 15 '21 14:11 ivov

Hi @ivov : Do you have good news about the implementation of the parser for parameter "in": "body"

thnguyendn avatar Nov 22 '21 11:11 thnguyendn