-
Notifications
You must be signed in to change notification settings - Fork 211
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
Fix JSON schema output for custom contracts #1427
Conversation
Signed-off-by: Nicko Guyer <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1427 +/- ##
=======================================
Coverage 99.99% 99.99%
=======================================
Files 321 321
Lines 23068 23088 +20
=======================================
+ Hits 23066 23086 +20
Misses 1 1
Partials 1 1 ☔ View full report in Codecov by Sentry. |
internal/apiserver/ffi2swagger.go
Outdated
}, | ||
// // TODO change to operation schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand what's left for this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did it and forgot to remove the comment :) I will remove it
internal/apiserver/ffi2swagger.go
Outdated
@@ -193,6 +192,40 @@ func contractJSONSchema(ctx context.Context, params *fftypes.FFIParams, hasLocat | |||
return openapi3.NewSchemaRef("", s), nil | |||
} | |||
|
|||
/** | |||
* Parse the FFI and build a corresponding JSON Schema to describe the response body for "invoke" or "query". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this response body is only for query outputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Good catch. Misleading comments are the worst kind of comments.
Signed-off-by: Nicko Guyer <[email protected]>
Previously we were generating an incorrect JSON Schema for the response body on custom contract endpoints. This PR fixes this so that:
/inovke
endpoints always return the correct schema for a FireFly Operation (which is the actual payload they return)/query
endpoints now return the correct schema based on the return value of the smart contract itselfoutput
,output1
,output2
, etc. like ETH/EVMConnect name them