-
Notifications
You must be signed in to change notification settings - Fork 73
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
Adding read/write json methods to entity #924
Adding read/write json methods to entity #924
Conversation
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
schema, | ||
self.extensions, | ||
); | ||
checker.validate_entity(&entity)?; |
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 API is a potential footgun, wonder if it can be reworked
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.
validate_entity()
?
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.
Yes. It seems easy to forget to call that, or have a flow through a function that doesn't call it. Violates the parse-don't-validate guideline
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.
That suggests an alternate API would have a different type for validated and not-yet-validated entities. The validated one would get the Entity
name I presume.
Signed-off-by: Aaron Eline <aeline+github@amazon.com> Co-authored-by: John Kastner <130772734+john-h-kastner-aws@users.noreply.github.com>
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
cedar-policy/src/api.rs
Outdated
@@ -263,6 +263,8 @@ impl Entity { | |||
} | |||
|
|||
/// Parse an entity from an in-memory JSON value | |||
/// If a schema is provided, it is handled identically to | |||
/// [Entities](https://docs.rs/cedar-policy/latest/cedar_policy/struct.Entities.html#method.from_json_str) |
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.
Why not just the auto doc link?
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.
How do you auto-doc link to a specific method?
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.
[Entities::from_json_str]
i think
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
Signed-off-by: Aaron Eline <aeline+github@amazon.com> Co-authored-by: John Kastner <130772734+john-h-kastner-aws@users.noreply.github.com>
Description of changes
Adds methods for reading and writing individual
Entity
objects as JSONIssue #, if available
#807
Checklist for requesting a review
The change in this PR is (choose one, and delete the other options):
cedar-policy
(e.g., addition of a new API).I confirm that this PR (choose one, and delete the other options):
I confirm that
cedar-spec
(choose one, and delete the other options):