|
1
|
import React from "react" |
|
2
|
import type { MDXContentClientProps } from "@/components/MDXContent/Client" |
|
3
|
import type { MDXContentServerProps } from "@/components/MDXContent/Server" |
|
4
|
import type { OpenAPI } from "types" |
|
5
|
import getSecuritySchemaTypeName from "@/utils/get-security-schema-type-name" |
|
6
|
import clsx from "clsx" |
|
7
|
import { Loading } from "docs-ui" |
|
8
|
import dynamic from "next/dynamic" |
|
9
|
|
|
10
|
const MDXContentClient = dynamic<MDXContentClientProps>( |
|
11
|
async () => import("@/components/MDXContent/Client"), |
|
12
|
{ |
|
13
|
loading: () => <Loading />, |
|
14
|
} |
|
15
|
) as React.FC<MDXContentClientProps> |
|
16
|
|
|
17
|
const MDXContentServer = dynamic<MDXContentServerProps>( |
|
18
|
async () => import("@/components/MDXContent/Server"), |
|
19
|
{ |
|
20
|
loading: () => <Loading />, |
|
21
|
} |
|
22
|
) as React.FC<MDXContentServerProps> |
|
23
|
|
|
24
|
export type SecurityDescriptionProps = { |
|
25
|
securitySchema: OpenAPI.SecuritySchemeObject |
|
26
|
isServer?: boolean |
|
27
|
} |
|
28
|
|
|
29
|
const SecurityDescription = ({ |
|
30
|
securitySchema, |
|
31
|
isServer = true, |
|
32
|
}: SecurityDescriptionProps) => { |
|
33
|
return ( |
|
34
|
<> |
|
35
|
<h2 data-testid="title">{securitySchema["x-displayName"] as string}</h2> |
|
36
|
{isServer && <MDXContentServer content={securitySchema.description} />} |
|
37
|
{!isServer && <MDXContentClient content={securitySchema.description} />} |
|
38
|
<p data-testid="security-scheme-type"> |
|
39
|
<strong>Security Scheme Type:</strong>{" "} |
|
40
|
{getSecuritySchemaTypeName(securitySchema)} |
|
41
|
</p> |
|
42
|
{(securitySchema.type === "http" || securitySchema.type === "apiKey") && ( |
|
43
|
<p |
|
44
|
className={clsx("bg-medusa-bg-subtle", "p-1")} |
|
45
|
data-testid="security-scheme-type-details" |
|
46
|
> |
|
47
|
<strong> |
|
48
|
{securitySchema.type === "http" |
|
49
|
? "HTTP Authorization Scheme" |
|
50
|
: "Cookie parameter name"} |
|
51
|
: |
|
52
|
</strong>{" "} |
|
53
|
<code data-testid="security-scheme-type-details-value"> |
|
54
|
{securitySchema.type === "http" |
|
55
|
? securitySchema.scheme |
|
56
|
: securitySchema.name} |
|
57
|
</code> |
|
58
|
</p> |
|
59
|
)} |
|
60
|
<hr /> |
|
61
|
</> |
|
62
|
) |
|
63
|
} |
|
64
|
|
|
65
|
export default SecurityDescription |