I’m having several problems with cbSwagger.
Since there would be a lot to say, I ask you if I’m configuring it right.
my custom modules are in
/apps
my api are in
/apps/api
my handlers are in
/apps/api/controllers
the cbswagger module is in
/modules/cbswagger
my Coldbox.cfc is in
/config/Coldbox.cfc
Here, I have this setup:
modulesExternalLocation : [ "/apps" ],
My ModuleConfig.cfc in /apps/api is:
component{
this.entryPoint = "/api";
function configure(){
conventions = { handlersLocation: "controllers" }
layoutSettings = { defaultLayout = "api.cfm" };
}
}
The first problem is this: I can’t use the module because inside the getHandlerMetadata() method (at about lines 510), the value of "invocationPath " is wrong:
if (
len( module ) && structKeyExists(
arguments.route,
"moduleInvocationPath"
)
) {
var invocationPath = arguments.route[ "moduleInvocationPath" ] & ".handlers." & handlerRoute;
} else {
var invocationPath = getHandlersInvocationPath() & "." & handlerRoute;
}
nor the if ( arguments.route…) in the else (getHandlersInvocationPath()) correctly instantiate my path.
The error is:
Type: cbSwagger.RoutesParse.handlerSyntaxException
Message: The handler at controllers.ProductController could not be parsed. The error that occurred: invalid component definition, can't find component [controllers.ProductController]
Some current values in getHandlerMetadata():
- handlerRoute = “ProductController”;
- getHandlersInvocationPath() = “controllers”;
- moduleInvocationPath = “modules.api”;
//error: should be “apps.api” - invocationPath = “modules.api.handlers.ProductController”;
//error: should be “apps.api.controlles.ProductController”
I solved this error editing the code (but it’s just a workaround that probably generated other problems), like so:
#1 remove moduleInvocationPath from arguments.route
StructDelete( arguments.route, "moduleInvocationPath" );
Because I’m in module, but my handlers are not in “handlers” as written here:
invocationPath = arguments.route[ "moduleInvocationPath" ] & ".handlers." & handlerRoute;
#2 add “apps.api.” ad invocationPath
return util.getInheritedMetadata( "apps.api." & invocationPath );
But I asked myself: am I doing something wrong in the configuration? The only thing I configured in practice is “modulesExternalLocation” in Coldbox.cfc and handlersLocation in ModuleConfig.cfc
Many thanks for any hints