Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur

{{/hasFormParams}}
{{#bodyParam}}
{{^consumes}}
localVarHeaderParameter['Content-Type'] = 'application/json';
{{/consumes}}
{{#consumes.0}}
localVarHeaderParameter['Content-Type'] = '{{mediaType}}';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@masaeedu Please use {{{mediaType}}} to use the original value fo the media type as I remember there are edge cases causing issues with the HTML-escaped values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wing328 Good catch. Should we be doing this for things like {{className}}, {{paramName}} etc. as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@masaeedu yes please

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI. I've filed #7073 to clean up {{mediaType}} in other templates.

{{/consumes.0}}

{{/bodyParam}}
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
Expand All @@ -223,7 +228,8 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
localVarRequestOptions.body = localVarFormParams.toString();
{{/hasFormParams}}
{{#bodyParam}}
localVarRequestOptions.body = JSON.stringify({{paramName}} || {});
const needsSerialization = (<any>"{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "");
{{/bodyParam}}

return {
Expand Down
45 changes: 26 additions & 19 deletions samples/client/petstore/typescript-fetch/builds/default/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const COLLECTION_FORMATS = {
* @interface FetchAPI
*/
export interface FetchAPI {
(url: string, init?: any): Promise<any>;
(url: string, init?: any): Promise<Response>;
}

/**
Expand Down Expand Up @@ -360,7 +360,8 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand Down Expand Up @@ -562,7 +563,8 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand Down Expand Up @@ -689,7 +691,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -709,7 +711,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -785,7 +787,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -806,7 +808,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1165,7 +1167,8 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand All @@ -1188,7 +1191,7 @@ export const StoreApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1393,7 +1396,8 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand Down Expand Up @@ -1424,7 +1428,8 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand Down Expand Up @@ -1455,7 +1460,8 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"Array&lt;User&gt;" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand Down Expand Up @@ -1614,7 +1620,8 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration)
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
localVarRequestOptions.body = JSON.stringify(body || {});
const needsSerialization = (<any>"User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");

return {
url: url.format(localVarUrlObj),
Expand All @@ -1637,7 +1644,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1656,7 +1663,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1675,7 +1682,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1694,7 +1701,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1751,7 +1758,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1771,7 +1778,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
Loading