Skip to content

Commit d056253

Browse files
committed
Select variables in server url
1 parent af9e66e commit d056253

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/react-openapi/src/OpenAPIServerURLVariable.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,25 @@ export function OpenAPIServerURLVariable(props: {
1212
variable: OpenAPIV3.ServerVariableObject;
1313
}) {
1414
const { variable } = props;
15+
16+
if (variable.enum && variable.enum.length > 0) {
17+
return (<select
18+
className={classNames(
19+
'openapi-section-select',
20+
'openapi-select',
21+
)}
22+
value={variable.default}
23+
>
24+
{
25+
variable.enum?.map((value: string) => {
26+
return (
27+
<option key={value} value={value}>
28+
{value}
29+
</option>
30+
);
31+
}) ?? null}
32+
</select>);
33+
34+
}
1535
return <span className={classNames('openapi-url-var')}>{variable.default}</span>;
1636
}

0 commit comments

Comments
 (0)