From 4ad45f855dd4a6783a0544f30a4080461dc78ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Gorej?= Date: Wed, 24 May 2023 15:43:08 +0200 Subject: [PATCH] fix(oas31): avoid capitalizing first character of components.schemas (#8710) Refs #8611 --- src/core/plugins/json-schema-2020-12/fn.js | 6 ++++-- src/core/plugins/oas31/components/models/models.jsx | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/core/plugins/json-schema-2020-12/fn.js b/src/core/plugins/json-schema-2020-12/fn.js index 2f77bacf51e..9e7b16e17aa 100644 --- a/src/core/plugins/json-schema-2020-12/fn.js +++ b/src/core/plugins/json-schema-2020-12/fn.js @@ -11,8 +11,10 @@ export const upperFirst = (value) => { } export const getTitle = (schema) => { - if (schema?.title) return upperFirst(schema.title) - if (schema?.$anchor) return upperFirst(schema.$anchor) + const fn = useFn() + + if (schema?.title) return fn.upperFirst(schema.title) + if (schema?.$anchor) return fn.upperFirst(schema.$anchor) if (schema?.$id) return schema.$id return "" diff --git a/src/core/plugins/oas31/components/models/models.jsx b/src/core/plugins/oas31/components/models/models.jsx index d3017f1d72c..5ea7c2c9515 100644 --- a/src/core/plugins/oas31/components/models/models.jsx +++ b/src/core/plugins/oas31/components/models/models.jsx @@ -12,7 +12,6 @@ const Models = ({ layoutActions, getComponent, getConfigs, - fn, }) => { const schemas = specSelectors.selectSchemas() const hasSchemas = Object.keys(schemas).length > 0 @@ -92,7 +91,7 @@ const Models = ({ key={schemaName} ref={handleJSONSchema202012Ref(schemaName)} schema={schema} - name={fn.upperFirst(schemaName)} + name={schemaName} onExpand={handleJSONSchema202012Expand(schemaName)} /> ))} @@ -118,9 +117,6 @@ Models.propTypes = { show: PropTypes.func.isRequired, readyToScroll: PropTypes.func.isRequired, }).isRequired, - fn: PropTypes.shape({ - upperFirst: PropTypes.func.isRequired, - }).isRequired, } export default Models