/** * @prettier */ import React from "react" import PropTypes from "prop-types" import ImPropTypes from "react-immutable-proptypes" class Auths extends React.Component { static propTypes = { definitions: ImPropTypes.iterable.isRequired, getComponent: PropTypes.func.isRequired, authSelectors: PropTypes.object.isRequired, authActions: PropTypes.object.isRequired, errSelectors: PropTypes.object.isRequired, specSelectors: PropTypes.object.isRequired, } constructor(props, context) { super(props, context) this.state = {} } onAuthChange = (auth) => { let { name } = auth this.setState({ [name]: auth }) } submitAuth = (e) => { e.preventDefault() let { authActions } = this.props authActions.authorizeWithPersistOption(this.state) } logoutClick = (e) => { e.preventDefault() let { authActions, definitions } = this.props let auths = definitions .map((val, key) => { return key }) .toArray() this.setState( auths.reduce((prev, auth) => { prev[auth] = "" return prev }, {}) ) authActions.logoutWithPersistOption(auths) } close = (e) => { e.preventDefault() let { authActions } = this.props authActions.showDefinitions(false) } render() { let { definitions, getComponent, authSelectors, errSelectors } = this.props const AuthItem = getComponent("AuthItem") const Oauth2 = getComponent("oauth2", true) const Button = getComponent("Button") const authorized = authSelectors.authorized() const authorizedAuth = definitions.filter((definition, key) => { return !!authorized.get(key) }) const nonOauthDefinitions = definitions.filter( (schema) => schema.get("type") !== "oauth2" && schema.get("type") !== "mutualTLS" ) const oauthDefinitions = definitions.filter( (schema) => schema.get("type") === "oauth2" ) const mutualTLSDefinitions = definitions.filter( (schema) => schema.get("type") === "mutualTLS" ) return (
{nonOauthDefinitions.size > 0 && (
{nonOauthDefinitions .map((schema, name) => { return ( ) }) .toArray()}
{nonOauthDefinitions.size === authorizedAuth.size ? ( ) : ( )}
)} {oauthDefinitions.size > 0 ? (

Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.

API requires the following scopes. Select which ones you want to grant to Swagger UI.

{definitions .filter((schema) => schema.get("type") === "oauth2") .map((schema, name) => { return (
) }) .toArray()}
) : null} {mutualTLSDefinitions.size > 0 && (
{mutualTLSDefinitions .map((schema, name) => { return ( ) }) .toArray()}
)}
) } } export default Auths