anil614sagar / openapi2apigee

OpenAPI to Apigee API Proxy using Node.js Utility
MIT License
33 stars 45 forks source link

Cannot provide a local file path to generateApi with no scheme #37

Open ts46235 opened 6 years ago

ts46235 commented 6 years ago

Schemes is required due to:

Error occurs due to generateTargetEndPoint.js:43 that expects these to exist: httpTargetConn.ele('URL', {}, api.schemes[0] + "://" + api.host + api.basePath);

My code is blowing up when it tries to access first item in api.schemes array, but schemes is not declared and so it blows up:

C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\lib\commands\generateApi\generateTargetEndPoint.js:43 httpTargetConn.ele('URL', {}, api.schemes[0] + "://" + api.host + api.basePath); ^


    at generateTargetEndPoint (C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\lib\commands\generateApi\generateTargetEndPoint.js:43:44)
    at C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\lib\commands\generateApi\generateApi.js:39:15
    at C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:3880:24
    at eachOfArrayLike (C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:1069:9)
    at eachOf (C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:1117:5)
    at _parallel (C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:3879:5)
    at Object.parallelLimit [as parallel] (C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:3962:5)
    at C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\lib\commands\generateApi\generateApi.js:27:15
    at C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\lib\commands\generateApi\generateSkeleton.js:23:7
    at C:\Users\guils\AppData\Roaming\nvm\v8.11.1\node_modules\openapi2apigee\node_modules\async\dist\async.js:1140:9```
apetrosian commented 6 years ago

Hi, seems like you don't have schemes defined in your spec, see example below:

   "schemes":[  
      "https",
      "http"
   ]

https://swagger.io/docs/specification/2-0/api-host-and-base-path/