Merge branch 'master' into next

This commit is contained in:
Vladimir Gorej
2023-03-21 14:19:43 +01:00
4 changed files with 59 additions and 10 deletions

View File

@@ -3,6 +3,16 @@ import ImmutablePureComponent from "react-immutable-pure-component"
import ImPropTypes from "react-immutable-proptypes"
import PropTypes from "prop-types"
const decodeRefName = uri => {
const unescaped = uri.replace(/~1/g, "/").replace(/~0/g, "~")
try {
return decodeURIComponent(unescaped)
} catch {
return unescaped
}
}
export default class Model extends ImmutablePureComponent {
static propTypes = {
schema: ImPropTypes.map.isRequired,
@@ -22,10 +32,10 @@ export default class Model extends ImmutablePureComponent {
getModelName =( ref )=> {
if ( ref.indexOf("#/definitions/") !== -1 ) {
return ref.replace(/^.*#\/definitions\//, "")
return decodeRefName(ref.replace(/^.*#\/definitions\//, ""))
}
if ( ref.indexOf("#/components/schemas/") !== -1 ) {
return ref.replace(/^.*#\/components\/schemas\//, "")
return decodeRefName(ref.replace(/^.*#\/components\/schemas\//, ""))
}
}