forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/es6 angular (swagger-api#5495)
* module code added for es6-angular client code generation * typescript wiped out the core gitignore file * added USE_ES6 cli option to javascript-closure-angular, will use the javascript-es6-angular templates instead * fixed issue with module file * added annotations to the templates * moved default output folder declaration * moved es6 template folder under closure-angular
- Loading branch information
1 parent
ba4ecea
commit 85850b2
Showing
4 changed files
with
119 additions
and
10 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
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
64 changes: 64 additions & 0 deletions
64
modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/es6/api.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @fileoverview AUTOMATICALLY GENERATED service for {{package}}.{{classname}}. | ||
* Do not edit this file by hand or your changes will be lost next time it is | ||
* generated.{{#appDescription}} | ||
* | ||
* {{ appDescription }}{{/appDescription}}{{#version}} | ||
* Version: {{version}}{{/version}}{{#appContact}} | ||
* Contact: {{appContact}}{{/appContact}} | ||
{{^hideGenerationTimestamp}} | ||
* Generated at: {{generatedDate}} | ||
{{/hideGenerationTimestamp}} | ||
* Generated by: {{generatorClass}} | ||
*/{{#licenseInfo}} | ||
/** | ||
* @license {{licenseInfo}}{{#licenseUrl}} | ||
* {{licenseUrl}}{{/licenseUrl}} | ||
*/ | ||
{{/licenseInfo}} | ||
|
||
{{#operations}} | ||
|
||
export default class {{classname}} { | ||
/** | ||
{{#description}} | ||
* {{&description}} | ||
{{/description}} | ||
* @constructor | ||
* @param {!angular.$resource} $resource | ||
* @ngInject | ||
*/ | ||
constructor($resource) { | ||
this.basePath = '{{basePath}}'; | ||
return $resource(null, {}, { | ||
{{#operation}} | ||
'{{operationId}}': this.{{operationId}}(), | ||
{{/operation}} | ||
}); | ||
} | ||
|
||
{{#operation}} | ||
|
||
/** | ||
* {{summary}} | ||
* {{notes}} {{#pathParams}} | ||
* @param {object} { {{paramName}} : !{{{dataType}}}{{^required}}={{/required}} } path parameters required by resource {{/pathParams}}{{#bodyParams}} | ||
* @param {object} { {{paramName}} : !{{{dataType}}}{{^required}}={{/required}} } postData required by resource {{/bodyParams}} | ||
* @param {function} Success Callback | ||
* @param {function} Error Callback | ||
* @return {object} | ||
*/ | ||
{{operationId}}() { | ||
return { | ||
method: '{{httpMethod}}', | ||
url: this.basePath + '{{path}}' | ||
{{#pathParams}} | ||
.replace('{' + '{{baseName}}' + '}', ':{{paramName}}') | ||
{{/pathParams}} | ||
} | ||
} | ||
{{/operation}} | ||
} | ||
{{/operations}} |
18 changes: 18 additions & 0 deletions
18
modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/es6/module.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{#apiInfo}} | ||
{{#apis}} | ||
{{#operations}} | ||
import {{classname}} from './resources/{{classname}}'; | ||
{{/operations}} | ||
{{/apis}} | ||
|
||
let moduleName = '{{appName}}'.toLowerCase().replace(/\s/g, '.'); | ||
|
||
export default angular | ||
.module(moduleName, []) | ||
{{#apis}} | ||
{{#operations}} | ||
.service('{{classname}}', {{classname}}) | ||
{{/operations}} | ||
{{/apis}}; | ||
|
||
{{/apiInfo}} |