-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repository generator uses Handlebars template
- Loading branch information
Showing
6 changed files
with
118 additions
and
117 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
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
43 changes: 43 additions & 0 deletions
43
packages/generator/src/openapi/templates/repositoryAction.hbs
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,43 @@ | ||
{{#*inline "get"}} | ||
return this.callApi(api => api.path(`{{{path}}}`) | ||
{{~#if isResponseArray~}} | ||
.getEntities({{responseType}}{{#if action.queryParam}}, query{{/if}}) | ||
{{~else~}} | ||
.getEntity({{responseType}}{{#if action.queryParam}}, query{{/if}}) | ||
{{~/if~}} | ||
); | ||
{{/inline}} | ||
{{#*inline "post"}} | ||
// TODO {{action.method}} {{path}} | ||
return this.callApi(api => api.path(`{{{path}}}`).postEntity(payload{{#if response}}, {{responseTypeDeclaration}}{{/if}})); | ||
{{/inline}} | ||
{{#*inline "put"}} | ||
// TODO {{action.method}} {{path}} | ||
return this.callApi(api => api.path(`{{{path}}}`).putEntity(payload{{#if response}}, {{responseTypeDeclaration}}{{/if}})); | ||
{{/inline}} | ||
{{#*inline "patch"}} | ||
// TODO {{action.method}} {{path}} | ||
return this.callApi(api => api.path(`{{{path}}}`).patchEntity(payload{{#if response}}, {{responseTypeDeclaration}}{{/if}})); | ||
{{/inline}} | ||
{{#*inline "delete"}} | ||
// TODO {{action.method}} {{path}} | ||
return this.callApi(api => api.path(`{{{path}}}`).delete({{#if action.requestBody}}payload{{/if}})); | ||
{{/inline}} | ||
{{#*inline "option"}} | ||
// TODO {{action.method}} {{path}} | ||
{{/inline}} | ||
{{#*inline "head"}} | ||
// TODO {{action.method}} {{path}} | ||
{{/inline}} | ||
{{#*inline "trace"}} | ||
// TODO {{action.method}} {{path}} | ||
{{/inline}} | ||
{{#if action.description}} | ||
/** {{action.description}} */ | ||
{{/if}} | ||
{{camelCase action.name}}({{#each parameters}}{{{this}}}{{#unless @last}}, {{/unless}}{{/each}}) { | ||
{{> (lookup action "method")}} | ||
{{#each responses}} | ||
// HTTP {{statusCode}}: {{returnType}}{{#unless returnType}}EMPTY{{/unless}} | ||
{{/each}} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/generator/src/openapi/templates/repositoryFile.hbs
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,13 @@ | ||
import RepositoryBase from "./repositoryBase"; | ||
{{#each imports}} | ||
{{{this}}} | ||
{{/each}} | ||
|
||
export default class {{repositoryName}} extends RepositoryBase { | ||
{{#each actions}} | ||
{{{this}}} | ||
{{#unless @last}} | ||
|
||
{{/unless}} | ||
{{/each}} | ||
} |
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