When security schemes are detected, the radio group now offers Custom (configure manually) and None (skip auth) options. The + Add header button only appears when Custom is selected or when no auth presets exist.
Unified · Split
| @@ -467,10 +467,15 @@ export default function AddOpenApiSource(props: { · 466 unmodified lines | ||
| 467 | 467 | const selectPreset = (index: number) => { |
| 468 | 468 | setPresetIndex(index); |
| 469 | 469 | const preset = index >= 0 ? presets[index] : null; |
| 470 | − setCustomHeaders((ch) => [ | |
| 471 | − ...(preset ? presetEntriesFromHeaderPreset(preset) : []), | |
| 472 | − ...ch.filter((h) => !h.fromPreset), | |
| 473 | − ]); | |
| 470 | + const userHeaders = customHeaders.filter((h) => !h.fromPreset); | |
| 471 | + if (preset) { | |
| 472 | + setCustomHeaders([...presetEntriesFromHeaderPreset(preset), ...userHeaders]); | |
| 473 | + } else if (index === -2 && userHeaders.length === 0) { | |
| 474 | + // "Custom" selected with no existing user headers — seed one empty row | |
| 475 | + setCustomHeaders([{ name: "", secretId: null, presetKey: undefined }]); | |
| 476 | + } else { | |
| 477 | + setCustomHeaders(userHeaders); | |
| 478 | + } | |
| 474 | 479 | }; |
| 475 | 480 | |
| 476 | 481 | const addCustomHeader = () => { |
| @@ -635,8 +640,8 @@ export default function AddOpenApiSource(props: { · 158 unmodified lines | ||
| 635 | 640 | <section className="space-y-2.5"> |
| 636 | 641 | <Label>Authentication</Label> |
| 637 | 642 | |
| 638 | − {/* Strategy picker — only when spec declares multiple strategies */} | |
| 639 | − {hasAuth && presets.length > 1 && ( | |
| 643 | + {/* Strategy picker */} | |
| 644 | + {hasAuth && ( | |
| 640 | 645 | <RadioGroup |
| 641 | 646 | value={String(presetIndex)} |
| 642 | 647 | onValueChange={(v) => selectPreset(Number(v))} |
| @@ -661,6 +666,18 @@ export default function AddOpenApiSource(props: { · 18 unmodified lines | ||
| 661 | 666 | </label> |
| 662 | 667 | ))} |
| 663 | 668 | |
| 669 | + <label | |
| 670 | + className={`flex items-center gap-2.5 rounded-lg border px-3 py-2 cursor-pointer transition-colors ${ | |
| 671 | + presetIndex === -2 | |
| 672 | + ? "border-primary/50 bg-primary/[0.03]" | |
| 673 | + : "border-border hover:bg-accent/50" | |
| 674 | + }`} | |
| 675 | + > | |
| 676 | + <RadioGroupItem value="-2" /> | |
| 677 | + <span className="text-xs font-medium text-foreground">Custom</span> | |
| 678 | + <span className="ml-auto text-[10px] text-muted-foreground">configure manually</span> | |
| 679 | + </label> | |
| 680 | + | |
| 664 | 681 | <label |
| 665 | 682 | className={`flex items-center gap-2.5 rounded-lg border px-3 py-2 cursor-pointer transition-colors ${ |
| 666 | 683 | presetIndex === -1 |
| @@ -694,14 +711,16 @@ export default function AddOpenApiSource(props: { · 27 unmodified lines | ||
| 694 | 711 | </div> |
| 695 | 712 | )} |
| 696 | 713 | |
| 697 | − <Button | |
| 698 | − variant="outline" | |
| 699 | − size="sm" | |
| 700 | − className="w-full border-dashed" | |
| 701 | − onClick={addCustomHeader} | |
| 702 | − > | |
| 703 | − + Add header | |
| 704 | − </Button> | |
| 714 | + {(!hasAuth || presetIndex === -2) && ( | |
| 715 | + <Button | |
| 716 | + variant="outline" | |
| 717 | + size="sm" | |
| 718 | + className="w-full border-dashed" | |
| 719 | + onClick={addCustomHeader} | |
| 720 | + > | |
| 721 | + + Add header | |
| 722 | + </Button> | |
| 723 | + )} | |
| 705 | 724 | </section> |
| 706 | 725 | |
| 707 | 726 | {/* Add error */} |