I use swagger-ui-react in my application. But I don't know how to config to add the authorization into api requests.
I had found an answer use in swagger ui from here:
window.swaggerUi = new SwaggerUi({...})
...
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", "header"));
But I don't know how to use in swagger-ui-react. Here is my code:
import styles from './index.less';
import React from 'react';
// tslint:disable
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';
// tslint:able
const SwaggerComp = params => {
const auth = params.authorization;
return (
<div className={styles.wrapper}>
<SwaggerUI
url="/v2/swagger-file-url"
withCredentials
/>
</div>
)
};
export default SwaggerComp;