Skip to content

Commit

Permalink
docs: fix missing type description (#5099)
Browse files Browse the repository at this point in the history
Fixes MRGFY-4058

Change-Id: Ibc5ba040c15da8efd44f8f6ad64022419dff818d
  • Loading branch information
jd authored Sep 10, 2024
1 parent 82b804a commit ec438d0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/Tables/ConfigOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function getTypeLink(ref: string): string | undefined {
return undefined;
}

function getItemFromSchema(schema: object, path: string): object {
const refPath = path.replace('#', ''); // Clean the path
return jsonpointer.get(schema, refPath);
}

/**
* Resolves a JSON Schema item, following $refs until a complete type is found.
* @param schema - The root JSON schema.
Expand All @@ -59,20 +64,16 @@ function getTypeLink(ref: string): string | undefined {
*/
export function resolveSchema(schema: object, item: object): object {
if (item.$ref) {
// Resolve the $ref using jsonpointer
const refPath = item.$ref.replace('#', ''); // Clean the $ref path
const resolvedItem = jsonpointer.get(schema, refPath);

// Recursively resolve if the resolved item is another $ref
return resolveSchema(schema, resolvedItem);
return resolveSchema(schema, getItemFromSchema(schema, item.$ref));
} else {
// Return the item if it's a complete definition (not a $ref)
return item;
}
}

function getTypeDescription(ref: object): string {
return resolveSchema(configSchema, ref).description;
return getItemFromSchema(configSchema, resolveSchema(configSchema, ref)).description;
}

export function getValueType(definition: any): React.ReactElement {
Expand Down

0 comments on commit ec438d0

Please sign in to comment.