feat(codegen-verification) :Add cross-format verification tests for four targets (TypeScript, JSON Schema, GraphQL and Protobuf)#244
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>
…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>
- Updated the JSONSchemaVisitor to correctly handle empty enums by using the 'not' keyword instead of an empty 'enum' array. - rewrote tests to verify that schemas with empty enums compile successfully with Ajv. Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com>
…ss multiple formats - Introduced new test files for GraphQL, JSON Schema, Protobuf, and TypeScript to verify the correctness of model generation. - Each test case checks that the generated output compiles and parses correctly, ensuring robust verification of the code generation process. - Implemented a shared utility for managing test cases and environment setup. Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com>
…and enums - Updated GraphQLVisitor to write placeholder members for empty enums and types, ensuring compliance with GraphQL specifications. - Enhanced ProtobufVisitor to emit empty marker messages for abstract types and correctly handle map types in generated Protobuf definitions. - Added tests to verify the correct behavior of these enhancements, ensuring robust code generation across formats. Signed-off-by: Apoorv <130035517+APOORV7G@users.noreply.github.com>
There was a problem hiding this comment.
Can you explain this problem a bit more? Why would this break Ajv? shouldn't all nextOfKin FQNs be the same?
There was a problem hiding this comment.
Yes, you are correct. All nextOfKin FQNs are same as they are inherited fields. When the previous visitor was building the JSON Schema , it gave $id to all of these four ( Person and the three inherited - > Employee, Contractor and Manager ). Ajv uses $id for $ref resolution and this will break with with same $id being repeated multiple times as FQNs is used to build the IDs. So that fix is workable as they are inline and not top level definitions.
ekarademir
left a comment
There was a problem hiding this comment.
Let's remove the protobuf changes at least. Maybe even JSONSchema changes as well. Le'ts also add the actual CI with just the targets you've created tests for so that this PR starts the actual verification.
|
|
||
| let key = ModelUtil.isPrimitiveType(keyType) ? this.concertoToProto3PrimitiveType(keyType) : keyType; | ||
| let value = ModelUtil.isPrimitiveType(valueType) ? this.concertoToProto3PrimitiveType(valueType) : valueType; | ||
| const key = this.concertoToProto3MapType(mapDeclaration.getKey(), mapDeclaration, true); |
There was a problem hiding this comment.
This logic change is not 1:1. It's converting the DateTime to string, but the previous logic would convert that to google.protobuf.Timestamp
There was a problem hiding this comment.
I will read more about this.
| } | ||
|
|
||
| describe('verification', function () { | ||
| this.timeout(60000); |
There was a problem hiding this comment.
Do we need 10 mins? I think 2 mins would be more than generous.
There was a problem hiding this comment.
Okay, I just wanted to be safe. We will stick to 2 mins.
Edit : That is 1 minute. Do you want me to extend it to 2 mins?
|
@ekarademir I will create a new PR with 2 Targets with the CI checks so actual verification starts happening. I will create issues and resolve those issues for Protobuf and GraphQL and then add them to the checks. |
Adds end-to-end verification tests that generate output from real Concerto models and validate it with format-specific tooling (Ajv, GraphQL parser, protobufjs, tsc). Fixes GraphQL and Protobuf visitors so models with empty enums and abstract types
Changes
test/verification/cases.js) with reusable model fixtures (metamodel,hr_base,hr_integration,stringlength,model-base,agreement,circular) and atest:verifynpm scriptjsonschema.validate.test.js)graphqlparser (graphql.parse.test.js)protobuf.parse.test.js)tsc(typescript.compile.test.js)GraphQLVisitorto emit distinct placeholders for empty types vs. empty enums (_: Booleanfor object types,_for enums) so generated SDL satisfies the GraphQL spec ref: The ability to represent empty objects graphql/graphql-spec#568 (comment)ProtobufVisitorto emit marker messages for abstract types, handle map fields withmap<key, value>syntax, and improve enum/empty-type generation.protofixtures and codegen snapshotsFlags
not: {}; GraphQL: placeholder enum member_; Protobuf: empty enum / marker message)ENABLE_MAP_TYPEandIMPORT_ALIASINGto match real-world codegen usage; some fixtures previously required skips that are no longer needed after these fixesSSNmay still need follow-up if used as map keys in user models, the current workaround in this PR being changing to typestring)Testing
run
npm run test:verifyto confirm all 28 verification cases pass.Author Checklist
--signoffoption of git commit.mainfromfork:branchname