6 - Implement swagger node middleware as the base API structure#23
6 - Implement swagger node middleware as the base API structure#23n0rbs wants to merge 5 commits intoIBM-Blockchain-Starter-Kit:masterfrom
Conversation
Signed-off-by: Norbert Aluba Dela Pena <norbert@sg.ibm.com>
Signed-off-by: Norbert Aluba Dela Pena <norbert@sg.ibm.com>
Signed-off-by: Norbert Aluba Dela Pena <norbert@sg.ibm.com>
…ger file Signed-off-by: Norbert Aluba Dela Pena <norbert@sg.ibm.com>
dda7c00 to
d66235a
Compare
|
@eymorale you can check how the middleware works and please let me know what you think. I haven't added the authentication libs as I just want to showcase the base template |
|
@n0rbs I'm not very familiar with swagger-node-runner. How would you mount middleware functions to a specific path(s) with this implementation? |
|
@eymorale For now, we can just wrap the original function with the middleware we want to use. or Source: apigee-127/swagger-tools#291 |
|
@n0rbs sorry for the delay. I've pulled down your changes and I'm in the middle of testing it out. I got it working mostly out of the box with a few tweaks that I'll add as inline comments in the code changes for you to address. Specifically I want to thoroughly test the bit about mounting route level middleware functions ^. We are working on adding a middleware function for some fabric plumbing code (plus any other middleware requirements someone might have). But if all that checks out, I think this code is good. I also think it would be helpful to add a section in the README about the swagger-node-runner and how that works regarding registering your paths to the application and doing the middleware to route them to their controllers, etc as some developers (including myself) might be unfamiliar with it and how to use it. |
| @@ -36,7 +46,6 @@ paths: | |||
| examples: | |||
| application/json: { "success": "true", "message": "Server is up!", "status": "UP" } | |||
|
|
|||
There was a problem hiding this comment.
Realized we don't have the ping route in the swagger so the route wasn't registered:
/ping:
x-swagger-router-controller: ping
get:
operationId: pingMe
tags:
- Ping
description: Ping blockchain network
responses:
200:
description: Ping response
schema:
$ref: "#/definitions/ResponseBody"
| /** | ||
| * pingMe | ||
| */ | ||
| controller.pingMe = (req, res) => { |
There was a problem hiding this comment.
this should be controller.pingMe = async (req, res) => {
| */ | ||
| controller.pingMe = (req, res) => { | ||
| try { | ||
| const result = Ping.pingCC(); |
There was a problem hiding this comment.
This should be const result = await Ping.pingCC();
|
@eymorale please take your time reviewing. Since we will be collaborating and you will be writing the code, you need to fully grasp how it works. Let's further discuss and make sure you're comfortable with the framework. Yes, I didn't add the re Swagger definition Controller |
…ementation Signed-off-by: Norbert Aluba Dela Pena <norbert@sg.ibm.com>
Summary