ad-on-is/adonis-autoswagger

/swagger-yaml throws internal server error when running with build files

Closed this issue · 4 comments

when i try to access /docs which calls /swagger-yml on develop it works fine but it doesnt with build files
that request fails with 500 with this console output

    request_id: "rrgltxnqc2pogpkh1g23yzc4"
    x-request-id: "rrgltxnqc2pogpkh1g23yzc4"
    err: {
      "type": "Error",
      "message": "ENOENT: no such file or directory, open '...\\adonis-bug-rep\\build\\app\\models\\pom'",
      "stack":
          Error: ENOENT: no such file or directory, open '...\adonis-bug-rep\build\app\models\pom'
      "errno": -4058,
      "code": "ENOENT",
      "syscall": "open",
      "path": "...\\adonis-bug-rep\\build\\app\\models\\pom",
      "status": 500
    }

Reproduceable Repo: https://github.com/MrSharpp/adonis-bug-rep

I guess it's most probably because the swagger endpoint shouldn't be available in prod build files, maybe thats why it's throwing 500.
my fix would be to just omit /docs or /swagger-yml on build files.

Dupe of #75
Just fixed in 3.12.0

Edit: Oh... Sorry... your issue is totally different from the dupe I mentioned. You need to run the docs:generate script as mentioned in the docs, to make it work in production.

Production environment

did the same in the given steps in docs, the issue is same.
you can try the reproduceable repository which i added.

ENOENT: no such file or directory....

i dont know why it trying to access models & other folders without the js extension, if i remove the js extension it shows error for the next file

Is your NODE_ENV set to "production"?

If you did everything correctly, you should have a swagger.yml generated, which you MUST deploy to your production environment. On production, AutoSwagger will obviously not parse any js/ts files, but it will read the generated "swagger.yml" instead, and it should work.

Edit:

did the same in the given steps in docs, the issue is same. you can try the reproduceable repository which i added.

You clearly did not create the commands file for the generation as described in the Readme.

Please follow Readme and report back if it doesn't work