I have followed [this][1] link to add swagger to my existing project. I encountered the following error while setting up swagger. Any leads will be highly appreciated.
:xxx\node_modules\swagger-node-express\Common\node\
swagger.js:84
self.appHandler.get(self.resourcePath.replace(self.formatString, self.jsonSuff
ix), resourceListing);
^TypeError: Cannot read property 'get' of null
[1]: https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs
This error is popping out because of -
var applicationUrl = 'http://localhost:9000'; //application runs properly on this url
swagger.configure(applicationUrl, '1.0.0');//error here
Looking at the line of code in question node-swagger-express it seems as if you need to call :
swagger.setAppHandler(app);
Before the configure call.
I specifically see the maintainer of the project you are using (https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs) has a commit message related to setAppHandler in his last commit. Perhaps there is now an issue related to it.
Related
I realized that when I try to access one of the paths defined in my swagger 2.0 with an incorrect method (ie. GET instead of POST), I receive the following message:
{"message":"Route defined in Swagger specification (/movie) but there is no defined get operation.","allowedMethods":["POST"]}
I am getting the above error. I am using nodeJs server and What i will add into the nodejs file.. Anyone help me how to solve this error.
I'm trying to run Heat Clinic 6.0.1 locally following getting started tutorial: https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally
I managed to run admin and site but not the API project. The application starts without problems but when I go to http://localhost:8082/api/v1/swagger-ui.html I get a 404. In the log I see this exception:
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Also trying to log in directly in the API with user broadleafapi and password gives 404.
My environment: Windows 10, jdk 8, maven 3.6
What's wrong? Can you help me? Thank you
Thanks for the report. I reproduced this and it looks like that with the update to Spring Boot 2.0, we did not appropriately override the updated property that specifies the servlet location to embedded Tomcat. Thus, when you went to /api/v1/swagger-ui.html, the application treats it exactly like that URL which is what gave the 404.
Setting the server.servlet.contextPath=/api/v1 property appropriately stripped off this path as part of the servlet context and resolved the 404.
I tested around a bit and was able to 'Authorize' the app (button at the top right of the Swagger page) with the credentials information that get spit out in the logs:
Basic auth configured with user broadleafapi and password: <<generated>>
then I was able to hit the API endpoints.
The changes you will need to make locally in your project to consume the fix are at https://github.com/BroadleafCommerce/DemoSite/commit/422d1cdc37f847afd8bec0be477ab784cbad2e9d#diff-991c59b6dbb0f619b8570d8f8779eaddR11. You will notice that I moved the original definition in default.properties over to common.properties and I recommend that you do the same. To be clear, follow these steps:
Delete the server.servlet.contextPath entry in `api/src/main/resources/runtime-properties/default.properties
Change server.servletPath in api/src/main/resources/runtime-properties/common.properties to server.servlet.contextPath
Thanks for trying out Broadleaf and the report, sorry for the rough early start!
I am just a newbie in mean.io . I want to build an event module just like the post which can be found the default module when you make an installation. I have taken everything from the post and renamed it as event. Now when I am trying to insert a new record in the event schema its showing an error like
there was an error sending the query Error: GraphQL error: Unknown type "EventInput". Did you mean "PostInput"?
GraphQL error: Cannot query field "addEvent" on type "Mutation". Did you mean "addPost"?
So can someone tell me what I am doing wrong here? Any suggestion or help will be really appreciable.
The problem is with innograph.
The addPost is coming from this npm module and not the actual /server/ changes that you have made.
innograph is initialised in express.js
The solution is to copy the innograph code into you application. Make all the changes and actually remove innograph from package.json.
If its too much just remove innograph, graphql, apollo packages and then simply use express.js that is also pre-built into mean.io.
The second step requires changes to be made into /server/ folder. I had to do some debugging to actually make it work.
In order to setup Google Identity Toolkit for my Website I started with the Quick-start App for Node.js.
It worked fine on localhost.
But when I moved it to an actual app-engine instance it did not work anymore.
I got this error returned by gitkitClient.verifyGitkitToken():
Invalid token: Unable to verify the ID Token: Wrong recipient, payload
audience != requiredAudience
I found a very helpful post on stackoverflow about more or less the same issue, for Java instead of node.js: It looks like there is a mismatch between projectId and clientId.
I changed my gitkit-server-config.json file to swap the projectId and clientId values and it worked!
This sound very much like a major bug on google side, doesn't it?
Why does it work on localhost?
Will this be changed/fixed in the future?
Maybe the problem is in the tutorial?
I have a working solution for now, but I do not feel safe to keep it like that...
I hope a googler will read this!
[EDIT]
Following wyhao31's comment I had a closer look at the gitkitclient.js source code and both projectId and clientId are added to the same audiences array.
After more test I found out that you must only put the project ID ('my-project-name') in the gitkit-server-config.json file.
The nasty thing is that if you add it with a 'clientId' property name it is also working...
Based on your description, and if you read gitkit-server-config.json file like this
var gitkitClient = new GitkitClient(JSON.parse(fs.readFileSync('./gitkit-server-config.json')));
I think the problem might caused by using old nodejs client lib. Could you try to update your client lib to latest version(0.0.6)? Or you can use the code directly.
I am running meteor inside a folder, like this
ROOT_URL="http://localhost:3000/registration" meteor
Also, i am using tap:i18n package for internationalisation support. The problem is that tap_i18n doesn't update the url for the localisation files and still makes request to http://localhost:3000/tap-i18n/en-US.json which is not a valid address, and hence throws 404 error. It should make request to http://localhost:3000/registration/tap-i18n/en-US.json. Notice the registration folder that was passed via ROOT_URL while starting meteor.
How can i tell tap_i18n package to honor ROOT_URL?
Ranjan,
I've setup a small demo project with some explanations on how to achieve your configuration. Please let me know if you could solve your issue.
How to configure tap:i18n with custom ROOT_URL
Check the configuration, you can set the i18n_files_route parameter
Configuring tap-i18n
To configure tap-i18n add to it a file named project-tap.i18n.
This JSON can have the following properties. All of them are optional.
The values bellow are the defaults.
project-root/project-tap.i18n
----------------------------- {
"helper_name": "_",
"supported_languages": null,
"i18n_files_route": "/tap-i18n",
"cdn_path": null
}
Source link for configuration