fix(codegen): update Level enum to include NONE value and adjust JSON…#243
Open
apoorv7g wants to merge 2 commits into
Open
fix(codegen): update Level enum to include NONE value and adjust JSON…#243apoorv7g wants to merge 2 commits into
apoorv7g wants to merge 2 commits into
Conversation
… schema generation - Added 'NONE' value to the Level enum in the model definition. - Removed $id assignment for inlined map schemas to prevent conflicts in JSON schema generation. - Updated related test snapshots to reflect changes in the Level enum. Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com> Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates code generation fixtures and tests to avoid Sinon stub leakage, and improves generated outputs by replacing an empty CTO enum with an explicit value while removing $id from inlined map schemas to prevent Ajv schema-ID collisions.
Changes:
- Add test cleanup to restore Sinon sandbox between tests.
- Define a concrete
Levelenum value (NONE) in the CTO model and refresh snapshots accordingly. - Stop emitting
$idfor inlined map schemas in JSON Schema generation to avoid Ajv conflicts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/codegen/fromcto/typescript/typescriptvisitor.js | Adds afterEach cleanup intended to prevent Sinon leakage across tests. |
| test/codegen/fromcto/data/model/hr_base.cto | Replaces an empty enum with a concrete enum member (NONE) to drive consistent codegen. |
| lib/codegen/fromcto/jsonschema/jsonschemavisitor.js | Removes $id from inlined map schemas to prevent Ajv $id collisions (notably with inherited fields). |
| test/codegen/snapshots/codegen.js.snap | Updates snapshots to reflect the enum addition and $id removal in generated schemas. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+41
to
+44
| // Leaked Sinon stub doesn't break hr_integration tests | ||
| afterEach(() => { | ||
| sandbox.restore(); | ||
| }); |
| typescriptVisitor = new TypescriptVisitor(); | ||
| mockFileWriter = sinon.createStubInstance(FileWriter); | ||
| }); | ||
| // Leaked Sinon stub doesn't break hr_integration tests |
Comment on lines
1037
to
1040
| type Level int | ||
| const ( | ||
| NONE Level = 1 + iota | ||
| ) |
…N schema generation - Introduced tests to verify the correct handling of non-empty enums, ensuring they emit valid values and compile with Ajv. - Added a test to confirm that schemas with empty enums fail Ajv compilation as expected. - Updated the JSON schema visitor to accommodate these new test cases. Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com>
Contributor
Author
|
@mttrbrts Let me know if any more changes are required, If this gets merged I can create a new PR for verification of the generated code for
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(jsonschema): make HR fixture JSON Schema pass Ajv validation
Closes #240
Fixes JSON Schema verification failures for the canonical HR fixtures (
hr_base.ctoandhr_base.cto+hr.cto). Generated schemas fromJSONSchemaVisitornow compile with Ajv, matching the approach used for the TypeScript HR fixes in #237 / #241.Related issue: accordproject/concerto-codegen#240
Changes
NONEto the emptyLevelenum inhr_base.ctoso Ajv no longer rejectsenum: []$idon inlined map field schemas injsonschemavisitor.jsso inherited fields (e.g.Person.nextOfKinonEmployee,Contractor,Manager) do not share one id and break AjvLevelenum and JSON Schema outputhr_baseandhr_integrationintest/verification/cases.js(removed pending skips)Flags
Level.NONEis a minimal fixture placeholder for an enum that was empty; adjust values if product semantics need more levels{ schema: ... }wrapper for compatibility with existingJSONSchemaVisitorunit tests; only the duplicate$idwas removednpm run mochaScreenshots or Video
Before (Bug 1 -
hr_baseonly):Before (Bug 2 -
hr_base+hr):After: both repro scripts below print
OK.Reproduce / verify locally
Bug 1 - empty
Levelenum (hr_baseonly):Bug 2 - duplicate
$idonPerson.nextOfKin(hr_base+hr):Related Issues
Author Checklist
--signoffoption of git commit.mainfromfork:branchname