'use client';
import * as React from 'react';
import classNames from 'classnames';
import { OpenAPIV3 } from 'openapi-types';
/**
* Interactive component to show the value of a server variable and let the user change it.
*/
export function OpenAPIServerURLVariable(props: {
name: string;
variable: OpenAPIV3.ServerVariableObject;
selectionIndex?: number;
selectable: boolean;
}) {
const { selectable, selectionIndex, name, variable } = props;
if (variable.enum && variable.enum.length > 0) {
if (!selectable) {
return {!isNaN(Number(selectionIndex)) ? variable.enum[Number(selectionIndex)] : variable.default};
}
return (
v === variable.default)
}
/>
);
}
return {variable.default};
}
/**
* Render a select if there is an enum for a Server URL variable
*/
function VariableSelector(props: {
value?: number;
name: string;
variable: OpenAPIV3.ServerVariableObject;
}) {
const { value, name, variable } = props;
return (
);
}