Fix for issue 20256: Bug Report: converting circular structure to JSON error

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-01-27 22:59:17 +01:00
parent 920715f98b
commit 4131bd2724
3 changed files with 8 additions and 5 deletions
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import { JsonObject } from '@backstage/types';
import { stringify, parse } from 'flatted';
import { FieldValidation, UiSchema } from '@rjsf/utils';
function isObject(value: unknown): value is JsonObject {
@@ -123,7 +124,7 @@ export const extractSchemaFromStep = (
inputStep: JsonObject,
): { uiSchema: UiSchema; schema: JsonObject } => {
const uiSchema: UiSchema = {};
const returnSchema: JsonObject = JSON.parse(JSON.stringify(inputStep));
const returnSchema: JsonObject = parse(stringify(inputStep));
extractUiSchema(returnSchema, uiSchema);
return { uiSchema, schema: returnSchema };
};