You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Question:
Is there a setting or a way I can add default headers that are visible when sending a request in an API Playground?
Background:
In my OpenAPI spec, a header for Content-Type: application/json is required for all Post's and Put's.
In the examples, it correctly shows needing the header:
However, when running/testing the api call, the user has to add this manually for each Post and Put.
I can force it to happen, similar to adding an authentication header like this:
const plugins = [
{
getIdentities: async (context) => [
{
id: "auth",
label: "Authentication",
authorizeRequest: async (request) => {
const token = await context.authentication?.getAccessToken();
if (!token) {
throw new Error("No authentication token available");
}
request.headers.set("Authorization", `Bearer ${token}`);
// Automatically set Content-Type header for POST, PUT, PATCH requests
const method = request.method?.toUpperCase();
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
// Only set if not already set
if (!request.headers.has("Content-Type")) {
request.headers.set("Content-Type", "application/json");
}
}
return request;
},
},
],
},
] as const
export default plugins;
However, while that does add the header, it hides it from the user, I would rather have it added and shown to the user in the UI to better help them.
I imagine there is already a built-in way to do this, but im not finding it in the documentation or here in GitHub.
If it doesn't exist, i think it would be a helpful setting to have. Where it can either populate the required headers from the API spec, or be over-ridden by a zudoku setting.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question:
Is there a setting or a way I can add default headers that are visible when sending a request in an API Playground?
Background:

In my OpenAPI spec, a header for
Content-Type: application/jsonis required for all Post's and Put's.In the examples, it correctly shows needing the header:
However, when running/testing the api call, the user has to add this manually for each Post and Put.

I can force it to happen, similar to adding an authentication header like this:
However, while that does add the header, it hides it from the user, I would rather have it added and shown to the user in the UI to better help them.
I imagine there is already a built-in way to do this, but im not finding it in the documentation or here in GitHub.
If it doesn't exist, i think it would be a helpful setting to have. Where it can either populate the required headers from the API spec, or be over-ridden by a zudoku setting.
Beta Was this translation helpful? Give feedback.
All reactions