Comments (8)
Well, there are a couple of options to dealing with cors:
- Just install and use a middleware like cors. It's generic, but it works in most cases. This is actually part of the default pipeline in the new swagger-node-runner. If you do this, you don't need to include anything specific in your swagger, but it also won't show up in your documentation - if that's something you want.
- Manually add the options operation to each of your Swagger paths with an appropriate controller that returns the necessary information for options.
from swagger-express.
Thank you! I will implement cors and give it a go. You mentioned that it
is the new swagger-node-runner module. Is that currently released?
On Dec 3, 2015 9:46 AM, "Scott Ganyo" [email protected] wrote:
Well, there are a couple of options to dealing with cors:
Just install and use a middleware like cors
https://www.npmjs.com/package/cors. It's generic, but it works in
most cases. This is actually part of the default pipeline in the new
swagger-node-runner. If you do this, you don't need to include anything
specific in your swagger, but it also won't show up in your documentation -
if that's something you want.
2.Manually add the options operation to each of your Swagger paths with
an appropriate controller that returns the necessary information for
options.—
Reply to this email directly or view it on GitHub
#3 (comment)
.
from swagger-express.
If you're using [email protected], you're already using the latest. If not, you'll need to do a little upgrade work... But it's pretty easy, start here: https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.0.
from swagger-express.
I am indeed running 0.6.0. Do I need to install cors or just implement it
according to the cors npm documentation?
On Dec 3, 2015 10:30 AM, "Scott Ganyo" [email protected] wrote:
If you're using [email protected], you're already using the
latest. If not, you'll need to do a little upgrade work... But it's pretty
easy, start here:
https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.0.—
Reply to this email directly or view it on GitHub
#3 (comment)
.
from swagger-express.
Actually, if you're running the latest, you don't even need to do that. You just need to make sure the existing fitting is listed for your pipe. The swagger_controllers pipe should look something like this and have "cors" listed as the first item after the error handler...
swagger_controllers:
- onError: json_error_handler
- cors
- swagger_params_parser
- _swagger_security
- _swagger_validate
- express_compatibility
- _router
If you have that, it should automatically route all request through the cors for any of your declared paths.
If you have that and it's not working, we'll need to dig deeper to figure out what's happening for you...
from swagger-express.
Bummer... I do indeed have that. I detailed my setup and the problem at stack overflow:
http://stackoverflow.com/questions/34016007/swagger-ajax-preflight-options
It seemed odd to me that it wasn't working. Take a look and see if anything comes up.
from swagger-express.
Scott,
Have you had a chance to look at the comments I posted including the stack
overflow posst?
http://stackoverflow.com/questions/34016007/swagger-ajax-preflight-options
Thanks again!
Rusty
On Thu, Dec 3, 2015 at 10:51 AM, Scott Ganyo [email protected]
wrote:
Actually, if you're running the latest, you don't even need to do that.
You just need to make sure the existing fitting is listed for your pipe.
The swagger_controllers pipe should look something like this and have
"cors" listed as the first item after the error handler...swagger_controllers: - onError: json_error_handler - cors - swagger_params_parser - _swagger_security - _swagger_validate - express_compatibility - _router
If you have that, it should automatically route all request through the
cors for any of your declared paths.If you have that and it's not working, we'll need to dig deeper to figure
out what's happening for you...—
Reply to this email directly or view it on GitHub
#3 (comment)
.
from swagger-express.
Hey Rusty,
Sorry I haven't gotten back to this before now. Do you happen to have a project you can share that recreates the issue? I've attempted to recreate myself, but I can't seem to hit whatever it is that you're hitting.
from swagger-express.
Related Issues (20)
- How to get data from response object HOT 6
- Validation error with swagger-express-mw 0.6.0 HOT 2
- how to "deny" extra elements on request through the schema HOT 1
- How to setup swagger middleware for testing in mocha with supertest HOT 1
- Error when using new "flattened" node_modules
- req.swagger.params not defined HOT 2
- Upgrade to swagger-node v0.7.1 HOT 1
- 404 Error with 0.7.0 which does not appear with 0.1.0 HOT 2
- Known vulnerability is found HOT 2
- Support for Swagger 3.0? HOT 1
- XML Support Attributes
- Module not found: Error: Can't resolve 'swagger-schema-official/schema' HOT 1
- How to change default 404 response while accessing url not listed in swagger.yaml
- How to allow for nullable values HOT 1
- 0.10.3 on NPM has a security vulnerability [email protected]
- Is this project dead? HOT 3
- Multipart -> Error: req.files must be provided for 'formData' parameters of type 'file' HOT 2
- @types/swagger-express-mw vulnerabilities HOT 3
- swagger validate stop working since version 0.6.0
- Why I have to access params through req.swagger.params
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-express.