From 0a577861f2579bcc3c58e8cb53ef09a66c280dc4 Mon Sep 17 00:00:00 2001 From: darrell-thobe-sp Date: Mon, 18 Nov 2024 13:22:19 -0500 Subject: [PATCH] adding Experimental back to createApiPageMD and fixing auth section --- createApiPageMD.ts | 12 +-- .../ApiExplorer/SecuritySchemes/index.tsx | 76 +++++++++++-------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/createApiPageMD.ts b/createApiPageMD.ts index 2f23e1400..ae8251791 100644 --- a/createApiPageMD.ts +++ b/createApiPageMD.ts @@ -73,6 +73,7 @@ export function createApiPageMD({ frontMatter.show_extensions ? createVendorExtensions(extensions) : undefined, + createExperimentalNotice(parameters), createDeprecationNotice({ deprecated, description: deprecatedDescription }), createDescription(description), requestBody || parameters ? createRequestHeader("Request") : undefined, @@ -86,17 +87,6 @@ export function createApiPageMD({ ]); } - -function createDeprecation({ deprecated, description }: { deprecated?: boolean; description?: string }) { - if (deprecated == true) { - if (description !== undefined) { - return `:::caution deprecated\n\n${description}\n\n:::`; - } else { - return `:::caution deprecated\n\nThis endpoint has been deprecated and may be replaced or removed in future versions of the API.\n\n:::`; - } - } -} - function createExperimentalNotice(parameters){ if (parameters && parameters.some(element => element.in === 'header' && element.name === 'X-SailPoint-Experimental')) { return ":::warning experimental\n\nThis API is currently in an experimental state. The API is subject to change based on feedback and further testing. You must include the X-SailPoint-Experimental header and set it to `true` to use this endpoint.\n\n:::\n\n"; diff --git a/src/theme/ApiExplorer/SecuritySchemes/index.tsx b/src/theme/ApiExplorer/SecuritySchemes/index.tsx index 2e03a0c67..1a4944473 100644 --- a/src/theme/ApiExplorer/SecuritySchemes/index.tsx +++ b/src/theme/ApiExplorer/SecuritySchemes/index.tsx @@ -8,6 +8,8 @@ function SecuritySchemes(props: any) { const selected = useTypedSelector((state: any) => state.auth.selected); const infoAuthPath = `/${props.infoPath}#authentication`; + console.log(props) + if (selected === undefined) return null; if (options[selected]?.[0]?.type === undefined) { @@ -16,7 +18,7 @@ function SecuritySchemes(props: any) { const selectedAuth = options[selected]; return ( -
+

Authorization: {selectedAuth[0].name ?? selectedAuth[0].type} @@ -180,6 +182,7 @@ function SecuritySchemes(props: any) { } if (isOauth2) { + console.log(auth) const { name, key, type, scopes, flows, ...rest } = auth; return ( @@ -190,39 +193,46 @@ function SecuritySchemes(props: any) { background: "var(--openapi-card-background-color)", }} > - - name:{" "} - {name ?? key} - - - type: - {type} - - {scopes && scopes.length > 0 && ( - - scopes: + {props.item['security'] && props.item['security'].length > 0 && ( - {auth.scopes.length > 0 ? auth.scopes.toString() : "[]"} + {props.item['security'].map((sec: any, index: number) => { + const key = Object.keys(sec)[0]; + const securityScheme = props.item['securitySchemes']?.[key]; + return ( +
+ type: + {securityScheme ? ( + + {securityScheme['x-displayName']} + + ) : ( + {key} // Fallback to key if no displayName found + )} + {scopes && scopes.length > 0 && ( +
+ + scopes: + + {auth.scopes.length > 0 ? auth.scopes.join(', ') : "[]"} + + +
+ )} + {props.item['x-sailpoint-userLevels'] && props.item['x-sailpoint-userLevels'].length > 0 && key !== 'applicationAuth' && ( +
+ + user levels: + + {props.item['x-sailpoint-userLevels'].length > 0 ? props.item['x-sailpoint-userLevels'].join(', ') : "[]"} + + +
+ )} + {index < props.item['security'].length - 1 && (
) } +
+ ); + })}
-
- )} - {Object.keys(rest).map((k, i) => { - return ( - - {k}: - {typeof rest[k] === "object" - ? JSON.stringify(rest[k], null, 2) - : String(rest[k])} - - ); - })} - {flows && ( - - - flows: - {JSON.stringify(flows, null, 2)} - - )}
@@ -277,4 +287,4 @@ function SecuritySchemes(props: any) { ); } -export default SecuritySchemes; +export default SecuritySchemes; \ No newline at end of file