apigee-127 / swagger-express

Other
52 stars 58 forks source link

Problem with newer swagger-node-runner #5

Closed BanovMiroslav closed 8 years ago

BanovMiroslav commented 8 years ago

I am not sure where to report this. I tried to update to the latest version of the swagger express mw, to try to resolve problems with validation errors having status 500. But then all my endpoints ended up returning 404.

Tried the simplest setup I can think of - using swagger generator, and it still failed. Here are the steps to reproduce: $ swagger project create hello-world (choose express) edit package.json and change MW version to: "swagger-express-mw": "apigee-127/swagger-express#fcc8541c9af0fefc08c0c14d8c546c0d8e95e65c" $ npm install The version of swagger-node-runner is "0.6.13" $ mocha test --recursive OR Test manually with swagger editor.

This is the error that is returned: TypeError: Cannot read property 'name' of undefined

BanovMiroslav commented 8 years ago

Well I did manage to upgrade the hello-world example, using the upgrade steps: https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.0

But I am still having troubles trying to post json from swagger ui, I am getting some strange error: "Error: Path [/hello] defined in Swagger, but OPTIONS operation is not."

BanovMiroslav commented 8 years ago

OK I managed to resolve the problem by removing cors from fittings, and using the latest cors directly as middleware.

~~The version of cors that is in express-node-runner doesn't support express-4 because this issue is not fixed in it: https://github.com/expressjs/cors/issues/21~~ Never mind. I am using express-4 and I have no idea why the fitting didn't work.

theganyo commented 8 years ago

Strange. I'm not seeing this. I did the same thing using express@4.13.3 and swagger-express-mw@0.6.0 and and see no issues using the standard cors fitting, running the editor, and trying the endpoint through that with and without a name. There must be something else going on...

BanovMiroslav commented 8 years ago

Just to ask - are we supposed to add OPTIONS operation in the yaml? Because previous version it wasn't necessary.

And one clarification/reminder - the default GET endpoint defined by swagger generator did work correctly, after I did the upgrade steps for 0.6.0. But when I added a POST, then I started seeing the problem with OPTIONS operation not defined. When I replaced the cors fitting with cors middleware e.g. "app.use(cors())", it started woring for me.

Can't be sure but #3 might be the same issue I am experiencing.

theganyo commented 8 years ago

You shouldn't need to. The cors fitting should be performing the same function as adding the middleware. I tried adding a post to my example, but I still can't recreate your issue here. Maybe you can send an example and how to recreate?

JADurham909 commented 8 years ago

@BanovMiroslav Please reference this: https://github.com/theganyo/swagger-node-runner/issues/26

This fixes the problem.

theganyo commented 8 years ago

Yes, this should be fixed now. It will pick this version of swagger_node_runner automatically when you install/update swagger-express. The easiest way to ensure you get the update is to just delete your node_modules directory and run npm install on your project again. If there are issues, let me know.