Skip to content

Conversation

Harshdev098
Copy link

Fix: #3507

  • Fixed the deployContract to throw error if get any additional property
  • Used ajv and to validate the requests
  • Used json-schema-ref-parser to handle the nullable property in the openAPI as ajv was throwing errors becuase it require a type keyword when using nullable, while openapi.json uses nullable in contexts. So preferred to go with ref-parser instead of updating the openAPI

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

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

@Harshdev098 Thank you for your contribution! Overall, looking pretty good, but I did have a few minor change requests that you can see above. On top of those, I'll also ask that you amend your commit message to match the text that you've put in the PR description.
If you need help with any of these tasks/updates just let me know I'm happy to help out. If you want to take advantage of that help you can also join the daily pair programming sessions on Discord at 10 AM Pacific Time (runs most weekdays).

@Harshdev098
Copy link
Author

@petermetz Thanks for the detailed feedback! I have updated the PR with required changes, can you please review it

Copy link
Contributor

@outSH outSH left a comment

Choose a reason for hiding this comment

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

Looks great, thanks you! I've left few comments


async function preprocessSchema() {
const resolvedSchema = await RefParser.dereference(OAS);
function adjustNullable(obj: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of any you can accept Record<string, unknown>

Comment on lines 50 to 63
let validateDeployContract: any;
(async () => {
const ajv = new Ajv({
allErrors: true,
strict: false,
allowMatchingProperties: true,
});
const processedSchema = await preprocessSchema();
ajv.addSchema(processedSchema, "openapi.json");

validateDeployContract = ajv.compile({
$ref: "openapi.json#/components/schemas/DeployContractV1Request",
});
})();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think IIFE is safe here, it may not finish until handleRequest is first called. Please use memoization instead (e.g. add function getValidateDeployContract that will compile the schema or return already compiled schema if available.

Copy link
Author

Choose a reason for hiding this comment

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

@outSH, Done with the changes!

Copy link
Contributor

@outSH outSH left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@petermetz
Copy link
Contributor

@Harshdev098 Sorry for the slow response, LGMT!

Fix: hyperledger-cacti#3507

- Fixed the deployContract to throw error if get any additional property
- Used ajv and to validate the requests
- Used json-schema-ref-parser to handle the nullable property in the openAPI as ajv was throwing errors becuase it require a type keyword when using nullable, while openapi.json uses nullable in contexts. So preferred to go with ref-parser instead of updating the openAPI

Signed-off-by: Harshdev098 <[email protected]>
@RafaelAPB
Copy link
Contributor

Thank you for your contribution. @Harshdev098 please update the MR, rebasing it as per your availability. Please note that we will close stale MRs to cleanup in a close future.

@outSH
Copy link
Contributor

outSH commented Jul 28, 2025

@RafaelAPB If there are no conflicts, you can select and click:

image

or rebase it manually first (e.g. to see if some optional tests are passing - recommended)

image

That way we can save some time and not require more actions from the contributors :)

I will not run them now, so you can experiment and see if that's acceptable for you

@RafaelAPB
Copy link
Contributor

@outSH not sure that would work. because DCO is failing, and we are trying to priortize rebases over merge commits.
@Harshdev098 could you please do the required updates?

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.

fix(connector-ethereum): additional properties to deployContract does not throw error
4 participants