Skip to content

Commit

Permalink
feat: append schema title to objects (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenRover authored Feb 23, 2024
1 parent c5b1c6f commit b7f3cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/src/helpers/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ describe('SchemaHelpers', () => {
const result = SchemaHelpers.toSchemaType(schema);
expect(result).toEqual(`number | string | boolean`);
});

test('should handle append title to object', () => {
const schema = new Schema({ type: 'object', title: 'SampleType' });
const result = SchemaHelpers.toSchemaType(schema);
expect(result).toEqual('object [SampleType]');
});
});

describe('.prettifyValue', () => {
Expand Down
4 changes: 4 additions & 0 deletions library/src/helpers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export class SchemaHelpers {
if (combinedType) {
return combinedType;
}

if (type === 'object' && schema.title()) {
type += ' [' + schema.title() + ']';
}
return type;
}

Expand Down

0 comments on commit b7f3cf8

Please sign in to comment.