-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor nodejs generated code structure (#4909)
* read directly from templates * refactor nodejs structure * dont inject into global scope * move to 2 spaces consistently
- Loading branch information
Showing
17 changed files
with
765 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
modules/swagger-codegen/src/main/resources/nodejs/controller.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
'use strict'; | ||
|
||
var url = require('url'); | ||
var utils = require('../utils/writer.js'); | ||
{{#operations}} | ||
|
||
var {{classname}} = require('./{{classname}}Service'); | ||
var {{classname}} = require('../{{implFolder}}/{{classname}}Service'); | ||
{{#operation}} | ||
|
||
module.exports.{{nickname}} = function {{nickname}} (req, res, next) { | ||
{{classname}}.{{nickname}}(req.swagger.params, res, next); | ||
{{#allParams}} | ||
var {{paramName}} = req.swagger.params['{{baseName}}'].value; | ||
{{/allParams}} | ||
{{classname}}.{{nickname}}({{#allParams}}{{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}}) | ||
.then(function (response) { | ||
utils.writeJson(res, response); | ||
}) | ||
.catch(function (response) { | ||
utils.writeJson(res, response); | ||
}); | ||
}; | ||
{{/operation}} | ||
{{/operations}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.