Skip to content
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

Properly generate $ref types on nodes, interfaces #486

Closed
willosborne opened this issue Oct 17, 2024 · 1 comment
Closed

Properly generate $ref types on nodes, interfaces #486

willosborne opened this issue Oct 17, 2024 · 1 comment
Assignees
Labels
CLI Generator Pattern Instantiation Generator

Comments

@willosborne
Copy link
Member

Feature Request

Description of Problem:

Currently the generator can generate arrays, strings, integers, consts properly. But if you have a schema with a $ref to a type, it just outputs {{ REF_[ key name ] }} and doesn't recursively instantiate.

For example, generating an interface that is based on the rate-limit-interface defined here. The usage example is the following. Note that only the interfaces are shown for brevity:

{
    "$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/interface.json#/defs/rate-limit-interface",
    "type": "object",
    "properties": {
        "unique-id": {
            "const": "rate-limit-info"
        }
    }
}
{
          "unique-id": "unique-id-here",
          "key": "{{ REF_KEY }}",
          "time": -1,
          "time-unit": "{{ REF_TIME_UNIT }}",
          "calls": -1
 }

You can see key is a flat string that contains none of the structure of the real definititon.
What this should look like is:

{
    "key": {
        "rate-limit-key": "{{ RATE_LIMIT_KEY }}"
    }
}

This is really confusing because it implies it's just a single field, not an object - and obscures optional/additional fields.

Potential Solutions:

We can already do this recursive instantiation for metadata objects.
A relatively simple solution would be to unify the instantiation code to all use the generic/recursive system which would then bring these benefits to nodes and relationships.
Note that we would still need to keep the node/relationship-specific logic and merge the final objects together.

@willosborne willosborne self-assigned this Oct 25, 2024
@willosborne willosborne added CLI Generator Pattern Instantiation Generator labels Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Oct 25, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 14, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 18, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Nov 21, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
willosborne added a commit to willosborne/architecture-as-code that referenced this issue Dec 2, 2024
rocketstack-matt pushed a commit that referenced this issue Dec 2, 2024
* add instantiate module and move relationships/metadata to use it

* #486 initial unification

* #486 add path context to generate command logging

* #486 fix condition when instantiating

* 486 clean up functions and split property instantiation

* #486 lint

* #486 always instantiate 'interfaces' block

* 486 test improvements

* #486 comments cleanup

* #486 test improvements

* Workspace Bin Movement

Now that I know more about workspaces, the published CLI didn't have a bin element so wasn't being linked as part of the release/install.

Also ran lint-fix - so some other line ending fixes.

* Instantiate refs and qualify relative paths when generating

* Extract update logic to higher-order function

* Add schema directory test for qualifying refs

* Properly instantiate enums (first cut)

* Fix typing issue and enum placeholder logic

* Log potential values for an enum when instantiated

* Suggested change to appendPath

* Lint

---------

Co-authored-by: Thels <[email protected]>
rocketstack-matt added a commit that referenced this issue Dec 3, 2024
* CLI Version Upgrade
Also fixing the CLI by;
Introducing `tsup` to bundle our packages together into a useable executable.
Migrated `spectral` into `shared` - updated README and steps - now the steps aren't referenced via file and are part of the code itself. Simplfying validation code.

* Cleaned up Spectral from CODEOWNERS

* Update dependency ts-graphviz to v2.1.5 (#629)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Missing package-lock.json (#631)

* Update docusaurus monorepo to v3.6.2 (#605)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matthew Bain <[email protected]>

* Update dependency @types/node to v22.10.1 (#635)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update docusaurus monorepo to v3.6.3 (#633)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* This fixes #316 (#634)

Introducing a `-pretty` flag to the validate command.

* #486 Unify instantiation mechanisms (#521)

* add instantiate module and move relationships/metadata to use it

* #486 initial unification

* #486 add path context to generate command logging

* #486 fix condition when instantiating

* 486 clean up functions and split property instantiation

* #486 lint

* #486 always instantiate 'interfaces' block

* 486 test improvements

* #486 comments cleanup

* #486 test improvements

* Workspace Bin Movement

Now that I know more about workspaces, the published CLI didn't have a bin element so wasn't being linked as part of the release/install.

Also ran lint-fix - so some other line ending fixes.

* Instantiate refs and qualify relative paths when generating

* Extract update logic to higher-order function

* Add schema directory test for qualifying refs

* Properly instantiate enums (first cut)

* Fix typing issue and enum placeholder logic

* Log potential values for an enum when instantiated

* Suggested change to appendPath

* Lint

---------

Co-authored-by: Thels <[email protected]>

* #639 - Github Action Chore - Standardizing Existing - Introducing Docs Build for PRs (#643)

* chore: fixes #639

* Code review fixes

---------

Co-authored-by: Matthew Bain <[email protected]>

* Update docs url to new domain (#644)

* Update dependency globals to v15.13.0 (#641)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update typescript-eslint monorepo to v8.17.0 (#602)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

---------

Co-authored-by: Thels <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matthew Bain <[email protected]>
Co-authored-by: Will Osborne <[email protected]>
Co-authored-by: David Johnston <[email protected]>
rocketstack-matt pushed a commit to rocketstack-matt/architecture-as-code that referenced this issue Dec 5, 2024
* add instantiate module and move relationships/metadata to use it

* finos#486 initial unification

* finos#486 add path context to generate command logging

* finos#486 fix condition when instantiating

* 486 clean up functions and split property instantiation

* finos#486 lint

* finos#486 always instantiate 'interfaces' block

* 486 test improvements

* finos#486 comments cleanup

* finos#486 test improvements

* Workspace Bin Movement

Now that I know more about workspaces, the published CLI didn't have a bin element so wasn't being linked as part of the release/install.

Also ran lint-fix - so some other line ending fixes.

* Instantiate refs and qualify relative paths when generating

* Extract update logic to higher-order function

* Add schema directory test for qualifying refs

* Properly instantiate enums (first cut)

* Fix typing issue and enum placeholder logic

* Log potential values for an enum when instantiated

* Suggested change to appendPath

* Lint

---------

Co-authored-by: Thels <[email protected]>
@willosborne
Copy link
Member Author

This is done as of #521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Generator Pattern Instantiation Generator
Projects
None yet
Development

No branches or pull requests

1 participant