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

feat: add dynamic payload support in schema controller #46

Merged

Conversation

ashwin275
Copy link
Contributor

This pull request adds the ability for the schema controller in the Issuer Agent to handle dynamic payloads. This means the API can now work with different types of data sent in requests. Currently, the API only accepts the expected request payload and directly passes it to SDK functions, which can throw errors if the payload format doesn't match.

In this PR, validation has been added to extract only the necessary fields before passing them to the function. Now, the API can accept different JSON formats while still extracting the required fields. Additionally, an interface for properties has been created to align with the Cord SDK

Copy link
Member

@amarts amarts left a comment

Choose a reason for hiding this comment

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

LGTM

return res.status(400).json({ error: validationError });
}

data = extractSchemaFields(data)
Copy link
Member

Choose a reason for hiding this comment

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

do you want to take it as a separate variable?

It may help in debug and other reasons later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I treat it as a separate variable, I will encounter a type error when passing it to the buildFromProperties function, indicating that the following properties are missing from the type 'ISchema': $id, $schema

@ashwin275 ashwin275 merged commit cddba89 into dhiway:main Sep 27, 2024
1 check passed
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