completecoding / serverless-auto-swagger

79 stars 48 forks source link

Swagger is not generated with loopback host 0.0.0.0 #97

Closed DallasO closed 1 year ago

DallasO commented 1 year ago

Adding --host 0.0.0.0 when running serverless (framework v3) prevents auto-swagger from generating files locally.

# Will generate successfully
sls offline start

# Will not generate
sls offline --host 0.0.0.0 start

Packages:

Still working on a minimal reproduction, so I can share that once its available

bfaulk96 commented 1 year ago

As serverless-auto-swagger doesn't deal with any configuration related to host, I would think this would be a bug with serverless-offline and perhaps how it handles the various lifecycle hooks.

bfaulk96 commented 1 year ago

To further help you dig into this one the serverless-offline side, serverless-auto-swagger makes use of the following two hooks:

      'before:offline:start:init': this.preDeploy,
      'before:package:cleanup': this.preDeploy,

And preDeploy will generate your swagger files if you have generateSwaggerOnDeploy set to true (or true by default), on top of creating the endpoint.

For a temporary workaround, you should be able to run sls generate-swagger to manually create the files, assuming sls offline --host 0.0.0.0 start at least creates the swagger endpoints

DallasO commented 1 year ago

Thank you for your prompt response. I posted this out of frustration and as I though about it more, I came to a similar conclusion that it would make more sense that serverless-offline is the culprit.

Thank you for the additional details as well, I'm still learning some of the serverless ecosystem, so this is helpful. sls offline --host 0.0.0.0 start does not even create the swagger endpoints for me, but I will dig into this more.

DallasO commented 1 year ago

I have not had time to confirm or deny if this is still an issue so I will close this until I can reliably reproduce. To your point, I doubt it is this repo causing this issue.

Thank you for your time and for maintaining this project.