Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix missing type description #5099

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/components/Tables/ConfigOptions.tsx
Original file line number Diff line number Diff line change
@@ -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.
@@ -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 {