@scalar/oas-utils
Version:
Open API spec and Yaml handling utilities
15 lines (13 loc) • 440 B
JavaScript
/** Retrieve example values for server variables */
const getServerVariableExamples = (server) => {
const examples = {};
if (server.variables) {
for (const [key, variable] of Object.entries(server.variables)) {
examples[key] = variable.enum?.filter((v) => typeof v === 'string') ?? [
variable.default,
];
}
}
return examples;
};
export { getServerVariableExamples };