|
1 | 1 | import clsx from 'clsx';
|
2 | 2 |
|
3 |
| -import type { OpenAPICustomOperationProperties, OpenAPIV3 } from '@gitbook/openapi-parser'; |
| 3 | +import type { |
| 4 | + OpenAPICustomOperationProperties, |
| 5 | + OpenAPIStability, |
| 6 | + OpenAPIV3, |
| 7 | +} from '@gitbook/openapi-parser'; |
4 | 8 | import { Markdown } from './Markdown';
|
5 | 9 | import { OpenAPICodeSample } from './OpenAPICodeSample';
|
6 | 10 | import { OpenAPIPath } from './OpenAPIPath';
|
@@ -29,14 +33,24 @@ export function OpenAPIOperation(props: {
|
29 | 33 | return (
|
30 | 34 | <div className={clsx('openapi-operation', className)}>
|
31 | 35 | <div className="openapi-summary" id={operation.summary ? undefined : context.id}>
|
| 36 | + {(operation.deprecated || operation['x-stability']) && ( |
| 37 | + <div className="openapi-summary-tags"> |
| 38 | + {operation.deprecated && ( |
| 39 | + <div className="openapi-deprecated">Deprecated</div> |
| 40 | + )} |
| 41 | + {operation['x-stability'] && ( |
| 42 | + <OpenAPIOperationStability stability={operation['x-stability']} /> |
| 43 | + )} |
| 44 | + </div> |
| 45 | + )} |
32 | 46 | {operation.summary
|
33 | 47 | ? context.renderHeading({
|
34 | 48 | deprecated: operation.deprecated ?? false,
|
| 49 | + stability: operation['x-stability'], |
35 | 50 | title: operation.summary,
|
36 | 51 | })
|
37 | 52 | : null}
|
38 | 53 | <OpenAPIPath data={data} context={context} />
|
39 |
| - {operation.deprecated && <div className="openapi-deprecated">Deprecated</div>} |
40 | 54 | </div>
|
41 | 55 | <div className="openapi-columns">
|
42 | 56 | <div className="openapi-column-spec">
|
@@ -89,3 +103,26 @@ function OpenAPIOperationDescription(props: {
|
89 | 103 | </div>
|
90 | 104 | );
|
91 | 105 | }
|
| 106 | + |
| 107 | +const stabilityEnum = { |
| 108 | + experimental: 'Experimental', |
| 109 | + alpha: 'Alpha', |
| 110 | + beta: 'Beta', |
| 111 | + stable: 'Stable', |
| 112 | +} as const; |
| 113 | + |
| 114 | +function OpenAPIOperationStability(props: { stability: OpenAPIStability }) { |
| 115 | + const { stability } = props; |
| 116 | + |
| 117 | + const foundStability = stabilityEnum[stability]; |
| 118 | + |
| 119 | + if (!foundStability) { |
| 120 | + return null; |
| 121 | + } |
| 122 | + |
| 123 | + return ( |
| 124 | + <div className={`openapi-stability openapi-stability-${foundStability.toLowerCase()}`}> |
| 125 | + {foundStability} |
| 126 | + </div> |
| 127 | + ); |
| 128 | +} |
0 commit comments