swagger-tools validate hangs when using external ref with absolute URLs - node.js

I am currently breaking down a swagger.json file following this guide: https://github.com/swagger-api/swagger-spec/blob/master/guidelines/REUSE.md
I made a mistake somewhere, and I would like to use the swagger-tools to find out where is my problem. When I run the tool, it just get stuck and doesn't produce any output.
I am using a localhost server, and my $ref are pointing to the localhost using absolute URLs such as:
"$ref": "http://localhost:8080/api-docs/v1/parameters.json#/myParameter"
I tried running using the file from the filesystem or served by the local server: none is working.
swagger-tools validate http://localhost:8080/api-docs/v1/swagger.json
However, if I shutdown the server and try to validate from the file system, the tools complains that it cannot resolve the references so somehow that proves that the file is parsed and swagger-tools tries to validate it.
Platform: Windows 7 Pro
Powershell
npm --version: 2.11.3
swagger-tools --version: 0.9.2
installed using npm -g install

I found the solution: the problem was coming from self-references in the definitions file that were using absolute URLs.
Using relative reference such as:
"$ref" : "#/myReference"
solved the issue and the swagger-tools validate is now working as expected.
I started suspecting something like that when I looked at the Node.js process and saw it was consuming 1.2 Go RAM and 25% CPU.

Related

Swagger-editor local installation not working

I'm trying to set up swagger-editor locally.
After cloning, I ran it using npm start but it never works on the browser .
and the browser gives the error:
This page isn’t working localhost sent an invalid response.
ERR_INVALID_REDIRECT
My nodejs version is 10.16.1 and npm version is 6.9.0.
Does it work only with 6.x version of nodejs? Did I miss anything here?
Or is there any other tool for setting up swagger-editor locally or using it?
Thanks.

Node package dependencies on IBM Cloud Foundry - require/module is not defined (Package not loading)

I am working on an application via the toolchain tool on IBM Cloud and editing the code via the Eclipse Orion IDE. As I am not accessing this through my local cli, my understanding is that in order to so call npm install {package}, I would just need to include the package in the package.json file under dependencies and require it in my app. However, when I load the application, I get the require is not defined indicating that the package has not been installed. Moreover, the require() is being used in the app.js file with the application being launched but not from files in my public directory.
After playing around further, it seems it might have to do with the way the directory tree is being traced as the error is only thrown in subdirectories. For example, require('express') works in app.js which is in the main directory ./ but fails when it is called in test.js in ./subdirectory/test.js. I feel like I'm missing something painfully simple like configuration of endpoint or something.
I've been searching around but I can't seem to find how to get the packages loaded, preferably without using the cli. Appreciate any pointers. Thanks!
Update: After playing around further, I am also getting module is not defined error when trying to require from another file in the same directory. For example module.exports = 'str' returns this error. While trying to require('./file') returns the require is not defined. It might have to do with how node is wrapping the functions?
Update 2: Tried "start": "npm install && node app.js" in package.json but no luck. Adding a build stage which calls npm install before deployment also does not work
Update 3: After adding npm install build stage, I am able to see that the dependencies have been successfully built via the logs. However, the require is not defined error still persists.
Update 4: Trying npm install from my CLI doesn't work as well even though all packages and dependencies are present
Update 5: Running cf restage or configuring cache via cacheDirectories does not work as well
Opened a related question regarding deployment here
Found out my confusion was caused due to me not realizing that require() cannot be used on the client side unless via tools such as Browserify.

react-native attempting to resolve built-in fetch function

I'm attempting to use the fetch function in react-native to grab a piece of data from the web. from what I understand reading the docs, the fetch function is built in to react-native.
when doing so, I get the module resolution error in the attached screenshot, where for whatever reason the react-native bundler is attempting to use the fetch provided by typescript from my ~/.cache directory.
I've previously had typescript 2.6 installed globally via npm, I uninstalled it to see if that might fix things, but the error persists.
I should note that the only things I've done for this project are to create it with create-react-native-app, add a little snippet to the App.js component stolen from the react docs to fetch some JSON, and yarn run eject the project (this error persisted before and after the ejection)
well in my turkey-induced frenzy, it appears I hadn't properly uninstalled the global typescript install on my computer.
having done so properly, the issue is resolved;
however the issue of react-native's module resolution strategy being incompatible with a global typescript installation persists.

No certificate is generated in .hfc-key-store

I'm using an AWS Ubuntu 16.04 LTS following Hyperledger Fabric readthedocs tutorial. I followed steps in "Writing Your First Applications". When I ran "node enrollAdmin.js", a eCert and key material is expected to be generated in a hfc-key-store directory, but nothing is generated in this folder, which means the folder is still empty after running the command. I looked into the code in this js file, in lines 54-55, only two arguments are provided, but from the API from this link:https://jimthematrix.github.io/FabricCAClient.html#enroll__anchor, the fabric_ca_client.enroll function should receive three arguments, which means the third argument 'csr' is not given in the js file. Strangely, no error information is shown after running the command, and the only information i got from the terminal is "store path: $mypath/hfc-key-store".
Any one knows what the problem occurs?
Thanks
After I switch node version from 6.12.0 to 6.9.5, this issue is resolved. Looks like the node version has to be 6.9.x

Trying to get MEAN maps to work on windows

I cloned this mean map that I watched on a azure mongodb video , and I did the same steps in the readme like they did
https://github.com/scotch-io/mean-google-maps
So
npm install
node server.js
// I didn't do any mongodb , as there is a config.js that is pointing at an amazon mongodb.
On the video they didn't do any mongodb locally
I see that in chrome console it throws an error with modernizr
#!/usr/bin/env node
That line is red squiggly , it that line causing the map to not load? Is that even going to work on a Windows 10 machine I'm running?
This error has nothing to do with mongodb.
The problem is the Modernizr link in the public/index.html (line 18) points to a script which is designed to be run server side.
The shebang #!/usr/bin/env node indicate a javascript file that must be run with Nodejs. Your browser can't run this kind of script.
It's looks like a confusion in bower dependency management.
(I think it is generaly not a good practive to include bower_components directory into git repository)
Maybe you can try to fix it by replacing the link with a cdnjs version of Modernizer:
https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js
Or just delete the line, you use a recent Chrome browser after all...

Resources