adding Experimental back to createApiPageMD and fixing auth section

This commit is contained in:
darrell-thobe-sp
2024-11-18 13:22:19 -05:00
parent 0c9358d084
commit 0a577861f2
2 changed files with 44 additions and 44 deletions

View File

@@ -73,6 +73,7 @@ export function createApiPageMD({
frontMatter.show_extensions frontMatter.show_extensions
? createVendorExtensions(extensions) ? createVendorExtensions(extensions)
: undefined, : undefined,
createExperimentalNotice(parameters),
createDeprecationNotice({ deprecated, description: deprecatedDescription }), createDeprecationNotice({ deprecated, description: deprecatedDescription }),
createDescription(description), createDescription(description),
requestBody || parameters ? createRequestHeader("Request") : undefined, 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){ function createExperimentalNotice(parameters){
if (parameters && parameters.some(element => element.in === 'header' && element.name === 'X-SailPoint-Experimental')) { 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"; 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";

View File

@@ -8,6 +8,8 @@ function SecuritySchemes(props: any) {
const selected = useTypedSelector((state: any) => state.auth.selected); const selected = useTypedSelector((state: any) => state.auth.selected);
const infoAuthPath = `/${props.infoPath}#authentication`; const infoAuthPath = `/${props.infoPath}#authentication`;
console.log(props)
if (selected === undefined) return null; if (selected === undefined) return null;
if (options[selected]?.[0]?.type === undefined) { if (options[selected]?.[0]?.type === undefined) {
@@ -16,7 +18,7 @@ function SecuritySchemes(props: any) {
const selectedAuth = options[selected]; const selectedAuth = options[selected];
return ( return (
<details className="openapi-security__details" open={false}> <details className="openapi-security__details" open={true}>
<summary className="openapi-security__summary-container"> <summary className="openapi-security__summary-container">
<h4 className="openapi-security__summary-header"> <h4 className="openapi-security__summary-header">
Authorization: {selectedAuth[0].name ?? selectedAuth[0].type} Authorization: {selectedAuth[0].name ?? selectedAuth[0].type}
@@ -180,6 +182,7 @@ function SecuritySchemes(props: any) {
} }
if (isOauth2) { if (isOauth2) {
console.log(auth)
const { name, key, type, scopes, flows, ...rest } = auth; const { name, key, type, scopes, flows, ...rest } = auth;
return ( return (
<React.Fragment key={selected}> <React.Fragment key={selected}>
@@ -190,39 +193,46 @@ function SecuritySchemes(props: any) {
background: "var(--openapi-card-background-color)", background: "var(--openapi-card-background-color)",
}} }}
> >
<span> {props.item['security'] && props.item['security'].length > 0 && (
<strong>name:</strong>{" "} <code>
<Link to={infoAuthPath}>{name ?? key}</Link> {props.item['security'].map((sec: any, index: number) => {
</span> const key = Object.keys(sec)[0];
<span> const securityScheme = props.item['securitySchemes']?.[key];
return (
<div key={key}>
<strong>type: </strong> <strong>type: </strong>
{type} {securityScheme ? (
</span> <Link to={infoAuthPath}>
{securityScheme['x-displayName']}
</Link>
) : (
<Link to={infoAuthPath}>{key}</Link> // Fallback to key if no displayName found
)}
{scopes && scopes.length > 0 && ( {scopes && scopes.length > 0 && (
<div>
<span> <span>
<strong>scopes: </strong> <strong>scopes: </strong>
<code> <code>
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"} {auth.scopes.length > 0 ? auth.scopes.join(', ') : "[]"}
</code> </code>
</span> </span>
</div>
)} )}
{Object.keys(rest).map((k, i) => { {props.item['x-sailpoint-userLevels'] && props.item['x-sailpoint-userLevels'].length > 0 && key !== 'applicationAuth' && (
return ( <div>
<span key={k}> <span>
<strong>{k}: </strong> <strong>user levels: </strong>
{typeof rest[k] === "object" <code>
? JSON.stringify(rest[k], null, 2) {props.item['x-sailpoint-userLevels'].length > 0 ? props.item['x-sailpoint-userLevels'].join(', ') : "[]"}
: String(rest[k])} </code>
</span> </span>
</div>
)}
{index < props.item['security'].length - 1 && (<hr></hr>) }
</div>
); );
})} })}
{flows && (
<span>
<code>
<strong>flows: </strong>
{JSON.stringify(flows, null, 2)}
</code> </code>
</span>
)} )}
</pre> </pre>
</React.Fragment> </React.Fragment>