Skip to content
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

Marketplace software zapier request middleware #18907

Merged
merged 3 commits into from
Jun 12, 2024
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 @@ -103,7 +103,7 @@ module.exports = {
{{/allParams}}
},{{/isMultipart}}
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return {{#returnType}}{{#returnTypeIsPrimitive}}{ data: results }{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}results{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}results{{/returnType}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const searchMiddleware = (action) => {
return action
}

const requestOptionsMiddleware = (z, bundle, requestOptions) => {
// TODO: modify the request options for all outgoing request to your api
// if you are using session authentication without a Bearer token.
// This may be true if your API uses basic authentication or api keys.
return requestOptions
}

module.exports = {
replacePathParameters: replacePathParameters,
childMapping: childMapping,
Expand All @@ -31,4 +38,5 @@ module.exports = {
hasSearchRequisites: hasSearchRequisites,
isSearchAction: isSearchAction,
searchMiddleware: searchMiddleware,
}
requestOptionsMiddleware: requestOptionsMiddleware,
}
16 changes: 8 additions & 8 deletions samples/client/petstore/zapier/apis/PetApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
...Pet.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -127,7 +127,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -170,7 +170,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -214,7 +214,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -254,7 +254,7 @@ module.exports = {
...Pet.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -307,7 +307,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -364,7 +364,7 @@ module.exports = {
},
body: formData,
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down
8 changes: 4 additions & 4 deletions samples/client/petstore/zapier/apis/StoreApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return { data: results };
Expand Down Expand Up @@ -118,7 +118,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -158,7 +158,7 @@ module.exports = {
...Order.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down
16 changes: 8 additions & 8 deletions samples/client/petstore/zapier/apis/UserApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
...User.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = {
...User.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -119,7 +119,7 @@ module.exports = {
...User.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -162,7 +162,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -206,7 +206,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -257,7 +257,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return { data: results };
Expand Down Expand Up @@ -294,7 +294,7 @@ module.exports = {
body: {
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down Expand Up @@ -339,7 +339,7 @@ module.exports = {
...User.mapping(bundle),
},
}
return z.request(options).then((response) => {
return z.request(utils.requestOptionsMiddleware(z, bundle, options)).then((response) => {
response.throwForStatus();
const results = response.json;
return results;
Expand Down
10 changes: 9 additions & 1 deletion samples/client/petstore/zapier/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const searchMiddleware = (action) => {
return action
}

const requestOptionsMiddleware = (z, bundle, requestOptions) => {
// TODO: modify the request options for all outgoing request to your api
// if you are using session authentication without a Bearer token.
// This may be true if your API uses basic authentication or api keys.
return requestOptions
}

module.exports = {
replacePathParameters: replacePathParameters,
childMapping: childMapping,
Expand All @@ -31,4 +38,5 @@ module.exports = {
hasSearchRequisites: hasSearchRequisites,
isSearchAction: isSearchAction,
searchMiddleware: searchMiddleware,
}
requestOptionsMiddleware: requestOptionsMiddleware,
}
Loading