-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add response type text #1
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
out/ | ||
dist/ | ||
/node_modules/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,23 @@ export class Codegen { | |
return Case.pascal(value); | ||
}); | ||
|
||
this.engine.registerHelper('concat', (...values: string[]) => { | ||
this.engine.registerHelper('if_eq', function(a, b, opts) { | ||
if (a == b) { | ||
return opts.fn(this); | ||
} else { | ||
return opts.inverse(this); | ||
} | ||
}); | ||
|
||
this.engine.registerHelper('assign', function (varName, varValue, options) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The structure should be immutable. No assign allowed |
||
if (!options.data.root) { | ||
options.data.root = {}; | ||
} | ||
options.data.root[varName] = varValue; | ||
}); | ||
|
||
// tslint:disable-next-line | ||
this.engine.registerHelper('concat', (...values) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why typescript without types? |
||
const options = values.pop(); | ||
|
||
return values.join(''); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,12 +104,38 @@ export class {{className info.title}} { | |
} | ||
{{/first}}{{/each}} | ||
|
||
{{#each responses}} | ||
{{#if @first}} | ||
{{#with (deref this)}}{{#first content}}{{#switch @key}} | ||
{{#case "application/json"}} | ||
{{assign 'responseType' 'json'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You do not need to have |
||
{{/case}} | ||
{{#case "text/csv"}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is too strict should me some match against MIME top class |
||
{{assign 'responseType' 'text'}} | ||
{{/case}} | ||
{{#default}} | ||
{{assign 'responseType' 'json'}} | ||
{{/default}} | ||
{{/switch}}{{/first}}{{/with}} | ||
{{/if}} | ||
{{/each}} | ||
|
||
{{#if_eq @root.responseType 'json'}} | ||
return this.httpClient.request<any>('{{method}}', `${this.basePath}${path}`, { | ||
{{#with (deref requestBody @root)}}body: this._encodeHttpBody(body, {{#first content}}'{{@key}}'{{/first}}),{{/with}} | ||
responseType: 'json', | ||
params, | ||
headers, | ||
{{! withCredentials: this.configuration.withCredentials, }} | ||
}); | ||
{{/if_eq}} | ||
{{#if_eq @root.responseType 'text'}} | ||
return this.httpClient.request('{{method}}', `${this.basePath}${path}`, { | ||
{{#with (deref requestBody @root)}}body: this._encodeHttpBody(body, {{#first content}}'{{@key}}'{{/first}}),{{/with}} | ||
responseType: 'text', | ||
params, | ||
headers, | ||
}); | ||
{{/if_eq}} | ||
} | ||
|
||
{{/inline}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? Use
{#if (eq? a b)}