swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Fail to connect swagger editor to backend (Mongo Lab)

Open aumerhadi opened this issue 10 years ago • 3 comments

Hi Sahar

I am trying to user Mongo lab as backend with swagger editor, but it's fail to connect

On defaults.json I changed the following:

  1. "useBackendForStorage": true,
  2. "backendEndpoint": "http://api.mlab.com/api/1/databases/swagger/collections/specs?apiKey=<my_API>",

When I run the editor, I get the following error XMLHttpRequest cannot load http://api.mlab.com/api/1/databases/swagger/collections/specs?XXXXXXXXXXXXXXXXXX. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access.

To solve the cross domain issue I am using CORS plugin in Chrome. But I get different error, it look like Swagger editor try to send object to mongolab.

Error: ui-ace cannot use an object or an array as a model at Array.<anonymous> (ui-ace.js:267) at ngModelWatch (angular.js:26943) at Scope.$digest (angular.js:17064) at Scope.$apply (angular.js:17337) at done (angular.js:11572) at completeRequest (angular.js:11778) at XMLHttpRequest.requestLoaded (angular.js:11711)

error_messge

I tried connect Swagger Editor to different backend , always get the same error Please let me know if you want more details

aumerhadi avatar Apr 26 '16 21:04 aumerhadi

Your AJAX preflight is failing. It's probably your API that causes the issue.

saharj avatar Apr 28 '16 04:04 saharj

Hi Sahar, Do you have working sample I can check and compare with my code?

aumerhadi avatar Apr 28 '16 15:04 aumerhadi

Check out this module: https://www.npmjs.com/package/swagger-editor-server

saharj avatar May 17 '16 06:05 saharj