-
Notifications
You must be signed in to change notification settings - Fork 38
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
Explore Options for CALM Schema to TypeScript Generation - Library Evaluation #701
Comments
Linked to this issue is a PR containing a basic setup of the library to generate models The library seems a little buggy when it comes to generating type definitions for defs that are not referenced via any schemas. I checked in generated output even though if we were to use, this would not be necessary. Some observations/questions that arose from this poc:-
being added to every defintiion Current Conclusion Relationship Type Model Question Do we want:- export interface Relationship {
"unique-id": string;
description?: string;
"relationship-type": ComposedOfType | InteractsType | ConnectsType | DeployedInType; or export interface Relationship {
"unique-id": string;
description?: string;
"relationship-type": {
interacts?: InteractsType;
connects?: ConnectsType;
"deployed-in"?: DeployedInType;
"composed-of"?: ComposedOfType;
[k: string]: unknown;
}; The later being more inlined to what it is currently on main |
Feature Request
Description of Problem:
There are many use cases for the CALM (Common Architecture Language Model) language, such as generating architecture implementation files (#444), documentation (#478), and more. Since the CALM specification is defined using JSON Schema, it is often necessary to convert the CALM model into strongly typed representations, making it easier to manipulate and use for generating code outputs or documentation.
Currently, there is no clear or standardised approach for converting CALM schemas (JSON Schema) into usable TypeScript types. It should consider the potential for extension.
Potential Solutions:
Define our own internal model manually: We could parse the CALM schema into a custom internal model, but this would require significant time and effort to implement and maintain.
Use an existing JSON Schema to TypeScript generator: We could leverage an established npm library (such as json-schema-to-typescript ) to automatically generate TypeScript types from the CALM schemas. This approach would save time and reduce the complexity of creating a custom solution, but it may not always be a perfect fit for CALM’s unique and extension needs.
Write our own TypeScript generator: We could write our own custom generator (AST) tailored specifically to the CALM schema. While this would give us the most control, it would also require significant effort to develop and maintain, as well as deal with any edge cases specific to CALM.
Focus of this Issue
This issue will focus on Solution 2. Will explore json-schema-to-typescript which seems the most widely adopted npm library for JSON Schema to TypeScript conversion, as it is the most straightforward and efficient approach to meet our needs. We want to evaluate whether this approach will work effectively with CALM schemas and whether there are any limitations or modifications needed to integrate it fully into our toolchain.
The text was updated successfully, but these errors were encountered: