-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Description
There are some properties I want to set in the input fields dynamically. Right now this isn't possible. Something similar to parameterMacro in SwaggerUI is what I'm looking for: https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/
Function. Function to set default value to parameters. Accepts two arguments parameterMacro(operation, parameter). Operation and parameter are objects passed for context, both remain immutable.
Technically this is doable with lodash
import { cloneDeepWith } from 'lodash';
onSpecLoaded(data) {
function updateTag(tag) {
const picker = (value, key) => {
if (!value || typeof value !== 'object') {
return value;
}
// Works on parameters array [{ name: 'userId', ... }]
if (value.name === 'userId') {
value.example = this.$store.state.profile?.userId;
value.default = this.$store.state.profile?.userId;
return value
}
if (Object.prototype.hasOwnProperty.call(value, 'default') && !value.example) {
return Object.assign(value, { example: value.default });
}
return undefined;
};
return cloneDeepWith(tag, picker);
}
data.detail.tags = data.detail.tags.map(tag => updateTag(tag));
}Metadata
Metadata
Assignees
Labels
No labels