Skip to content

Commit

Permalink
Merge pull request #10 from cjzamora/feature/allow-idea-props
Browse files Browse the repository at this point in the history
allow idea props to be accessed by generators. I was able to review, download this PR and verify this is working. Thanks @cjzamora
  • Loading branch information
cblanquera authored Jun 10, 2024
2 parents 25a16a6 + ea26553 commit 1fcd828
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/idea-transformer/src/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default class Transformer<T extends {}> {
const parent = transformer.schema;
//soft merge the object values of enum,
//type, model from parent to schema
if (parent.prop) {
schema.prop = { ...parent.prop, ...schema.prop };
}
if (parent.enum) {
schema.enum = { ...parent.enum, ...schema.enum };
}
Expand All @@ -67,7 +70,6 @@ export default class Transformer<T extends {}> {
}
//finalize schema
delete schema.use;
delete schema.prop;
//set schema
this._schema = schema;
}
Expand Down
1 change: 1 addition & 0 deletions packages/idea-transformer/tests/Transformer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Transformer Tests', () => {
expect(actual.type && 'Address' in actual.type).to.be.true;
expect(actual.type && 'Contact' in actual.type).to.be.true;
expect(actual.enum && 'Roles' in actual.enum).to.be.true;
expect(actual.prop && 'Config' in actual.prop).to.be.true;
}).timeout(20000);

it('Should make enums', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/idea-transformer/tests/another.idea
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
prop Config {
module "another-idea"
}

enum Roles {
OWNER "owner"
MODERATOR "moderator"
Expand Down

0 comments on commit 1fcd828

Please sign in to comment.