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

JSON Schema => Capability Types #647

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

DeividasK
Copy link
Collaborator

@DeividasK DeividasK commented Jul 10, 2024

Long-term, we need JSON Schema to generate types for various different capability use cases to be able to interoperate. Currently, I'm creating JSON Schemas by hand for each and then generating the go types.

Long-term, this is probably not the right place for this CLI tool. Will aim to move it to capabilities repo.

Credits:
Heavily inspired by @nolag prototype:
https://github.com/smartcontractkit/ryantinianovscratch/tree/rtinianov_jsonSchemaToBuilder/jsonschematobuilder

go.mod Show resolved Hide resolved
@@ -0,0 +1,82 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move it to an actual streams folder in a follow-up. This should be the real deal (today; duplicating for testing purposes as it might change later).

@@ -0,0 +1,128 @@
// Code generated by pkg/capabilities/cli, DO NOT EDIT.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what will be generated for each capability. Will need work to include capability type, maybe figure out the encoded string => []byte conversion, too.

}

// UnmarshalJSON implements json.Unmarshaler.
func (j *StreamsCapabilityOutputsElem) UnmarshalJSON(b []byte) error {
Copy link
Collaborator Author

@DeividasK DeividasK Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could swap this to Proto/Values generation. Also, whether that would be useful.

go.mod Outdated
Comment on lines 56 to 58
)

require (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know why the tooling sometimes creates these extra indirect blocks, but if you combine them, then tidy will sort them for you.

Suggested change
)
require (

@DeividasK DeividasK changed the title Ryan/Deividas - capability types generator JSON Schema => Capability Types Jul 11, 2024
@DeividasK DeividasK marked this pull request as ready for review July 11, 2024 14:30
@DeividasK DeividasK requested review from a team as code owners July 11, 2024 14:30
@DeividasK
Copy link
Collaborator Author

PR is failing because of failures in downstream dependencies, namely smartcontractkit/chainlink#13820

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

Successfully merging this pull request may close these issues.

2 participants