convector-rest-api icon indicating copy to clipboard operation
convector-rest-api copied to clipboard

Cannot find ClassName in apiGeneratorClass

Open BardoBravo opened this issue 5 years ago • 2 comments

Hi, When following the instructions for the Auto-generated REST API (link here), during the command conv-rest-api generate api -c car -f ./org1.car.config.json I get the error: "TypeError: Cannot read property 'getClassorThrow' of undefined". This is raised by reflectionUtils.js [152:41].

I am using a newer version of convector, where the file /org1.car.cconfig.json is now named as car.config.json, so I used that file.

I could notice that in class apiGenerator, the controllerName object was not retrieving the right data to variables plainName and controllersPattern. So I did a test and directly changed the file:

case 0:
  plainName = controllerName.replace('Controller', '').toLowerCase();
  controllersPattern = path_1.join(process.cwd(), ".") +
    ("/packages/**-cc/src/" + "car" + ".controller.ts");
    return [4, reflectionUtils_1.ReflectionUtils.getClassMethods(controllersPattern, 
       "CarController")];//controllerName)];

I have basically inserted the CarController name, and then it worked.

Do you have any idea on why the correct name for the class is not being used in the application?

BardoBravo avatar Nov 09 '19 23:11 BardoBravo

Hi @BardoBravo I have the same problem did you find any solution?

krafugo avatar Jan 09 '20 14:01 krafugo

Hi @krafugo ,

In fact, I described the solution above, but did not received any feedback on why the original application is wrong, or if my solution is really the best one.

in the end, i recommend you to reach the official Discord channel - there they are way more active than here at GitHub.

[]s

BardoBravo avatar Jan 13 '20 16:01 BardoBravo