Type base64 encoded FileAttachment.contentBytes as a string #322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for taking the time to review this PR!
This PR changes the described type of
contentBytes
fromNullableOption<number>
toNullableOption<string>
.Why was it mistyped?
The documentation, imprecisely describes it in contradicting terms:
Edm.Binary
and "The base64-encoded contents of the file." The field cannot be both at the same time. Instead, it is clear from use of the Api that the contents sent and accepted by the Api are base64 encoded (string) of a binary. After decoding, the type would be anEdm.Binary
, but not in the FileAttachment object itself.Impact
Because the type incorrectly describes the contents as a number, test fixtures built using actual FileAttachment responses appear as the wrong shape to Typescript, forcing the test author to cast through
unknown
and effectively reducing the value of the type.It was described in this issue: #23 and never resolved. I suspect this happened because the contradiction of the docs wasn't clearly discussed. We all know base64 encoded binaries are strings, the docs simply mis-describe this in the type field while accurately describing it in the description field.
Reference: https://docs.microsoft.com/en-us/graph/api/resources/fileattachment?view=graph-rest-1.0