ad-on-is / adonis-autoswagger

Auto-Generate swagger docs for AdonisJS
MIT License
97 stars 32 forks source link

No such file or directory #61

Closed icodefuture closed 3 months ago

icodefuture commented 3 months ago

I am using this pacakge with Adonis 6.2.1 It works well locally but after deploying it to the production its not generating the files as its still trying to access the controllers with ts extension. However after the build process the path build/app/controllers only contains .js files.

{"message":"ENOENT: no such file or directory, open '/var/www/myapp/build/config/../app/controllers/auth_controller.ts'","name":"Error","status":500,"frames":[]}

The steps I have followed are

node ace docs:generate
node ace build --production
cp swagger.yml build/

any feedback would be appreciated. Thanks.

ad-on-is commented 3 months ago

Autoswagger requires NODE_ENV to be set to "production" to load the generated yaml file.

HasanAshab commented 3 months ago

I have the same error but in different context. I'm not on production but error occured for changing default location of controllers from app/controllers to app/http/controllers

here is my error

ENOENT: no such file or directory, open 'file:///data/data/com.termux/files/home/js/adonis/boilerplate/config/swagger.ts/../app/controllers/v1/dashboard_controller.ts'

It seems like AutoSwagger find controllers statically. It would be better if it look on adonisrc.ts for paths

export default defineConfig({
  directories: {
    commands: 'app/commands',
    providers: 'app/providers',
    httpControllers: 'app/http/controllers',
    middleware: 'app/http/middleware',
    validators: 'app/validation/validators',
  },
//...
})
ad-on-is commented 3 months ago

I have the same error but in different context. I'm not on production but error occured for changing default location of controllers from app/controllers to app/http/controllers

here is my error

ENOENT: no such file or directory, open 'file:///data/data/com.termux/files/home/js/adonis/boilerplate/config/swagger.ts/../app/controllers/v1/dashboard_controller.ts'

It seems like AutoSwagger find controllers statically. It would be better if it look on adonisrc.ts for paths

export default defineConfig({
  directories: {
    commands: 'app/commands',
    providers: 'app/providers',
    httpControllers: 'app/http/controllers',
    middleware: 'app/http/middleware',
    validators: 'app/validation/validators',
  },
//...
})

I think your issue might be related to this one: https://github.com/ad-on-is/adonis-autoswagger/issues/56

ad-on-is commented 3 months ago

Done in version 3.0