diff --git a/.changeset/tame-colts-know.md b/.changeset/tame-colts-know.md new file mode 100644 index 000000000..18ab09109 --- /dev/null +++ b/.changeset/tame-colts-know.md @@ -0,0 +1,7 @@ +--- +'@gitbook/openapi-parser': patch +'@gitbook/react-openapi': patch +'gitbook': patch +--- + +Support for x-enumDescriptions and x-gitbook-enum diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css index 9405781a2..6051155af 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css @@ -244,7 +244,11 @@ /* Schema Enum */ .openapi-schema-enum { - @apply flex flex-row text-sm leading-relaxed flex-wrap text-tint; + @apply flex flex-row text-sm leading-relaxed gap-2 flex-wrap text-tint; +} + +.openapi-schema-enum-list { + @apply flex flex-row gap-1.5 items-center; } .openapi-schema-enum-value { @@ -693,3 +697,7 @@ opacity: 0; } } + +.openapi-copy-button { + @apply hover:brightness-95; +} diff --git a/packages/openapi-parser/src/types.ts b/packages/openapi-parser/src/types.ts index d94436a89..3b55c21ab 100644 --- a/packages/openapi-parser/src/types.ts +++ b/packages/openapi-parser/src/types.ts @@ -47,6 +47,21 @@ export interface OpenAPICustomOperationProperties { * Description in Document format. */ 'x-gitbook-description-document'?: object; + + /** + * Enums with name and description + */ + 'x-enumDescriptions'?: object; + + /** + * Enums with name and description + */ + 'x-gitbook-enum'?: { + [key: string]: { + description?: string; + name?: string; + }; + }; } /** diff --git a/packages/react-openapi/src/OpenAPICopyButton.tsx b/packages/react-openapi/src/OpenAPICopyButton.tsx index 6cf93b311..954ff9b6a 100644 --- a/packages/react-openapi/src/OpenAPICopyButton.tsx +++ b/packages/react-openapi/src/OpenAPICopyButton.tsx @@ -6,10 +6,16 @@ import { Button, type ButtonProps, Tooltip, TooltipTrigger } from 'react-aria-co export function OpenAPICopyButton( props: ButtonProps & { value: string; + children: React.ReactNode; + label?: string; + /** + * Whether to show a tooltip. + * @default true + */ + withTooltip?: boolean; } ) { - const { value } = props; - const { children, onPress, className } = props; + const { value, label, children, onPress, className, withTooltip = true } = props; const [copied, setCopied] = useState(false); const [isOpen, setIsOpen] = useState(false); @@ -21,12 +27,19 @@ export function OpenAPICopyButton( setTimeout(() => { setCopied(false); + setIsOpen(false); }, 2000); }); }; return ( - +