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

add shorthand functions for serialization #177

Open
baywet opened this issue Nov 2, 2023 · 2 comments
Open

add shorthand functions for serialization #177

baywet opened this issue Nov 2, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@baywet
Copy link
Member

baywet commented Nov 2, 2023

to facilitate serialization and deserialization of models and collections of models, we're adding static helper functions.
More details to be found at microsoft/kiota#3406

For serialization we need:

  • Serialize(contentType, model): string
  • Serialize(contentType, model): stream
  • SerializeCollection(contentType, models): string
  • SerializeCollection(contentType, models): stream
  • Serialize(model): stream (maps to same one passing the json content type as a constant)
  • Serialize(model): string (same)
  • Serialize(models): stream (same)
  • Serialize(models): string (same)

Note: if converting from stream to string is trivial we can ommit the string overloads
Note: if another parameter for the serialization method needs to be added, feel free to do so
Note: if both a string and and stream method need to be added, but can't have the same name, name the string methods with AsString suffix
Note: if the Json methods and the ones accepting the same content type can't have the same namde/would need to be aliased in the consuming code to avoid conflicts, as a ToJsonSuffix (full convention with string SerializeCollectionToJsonAsString)

For deserialization we need:

  • Deserialize(contentType, stream, createTFromDiscriminatorMethod): T
  • Deserialize(contentType, string, createTFromDiscriminatorMethod): T
  • Deserialize(contentType, stream): T (uses reflection, only if possible, calls into the previous one)
  • Deserialize(contentType, string): T (same)
  • DeserializeCollection(contentType, stream, createCallback): T[]
  • DeserializeCollection(contentType, string, createCallback): T[]
  • reflection version x2
  • Json equivalent with constant for all the previous

Note: the same notes as serialization apply
Note: if the collection and single methods can have the same name, make them same

@baywet baywet added the enhancement New feature or request label Nov 2, 2023
@samwelkanda samwelkanda removed their assignment Jan 31, 2024
@baywet baywet added this to Kiota Feb 21, 2024
@github-project-automation github-project-automation bot moved this to Todo in Kiota Feb 21, 2024
@noethig
Copy link

noethig commented Jun 12, 2024

What is the status here? Has there been any development or is it stuck in a state 'not just yet'? I currently needs this feature to build a workaround for another part of Graph API Python SDK that is broken.

@baywet
Copy link
Member Author

baywet commented Jun 12, 2024

no work has started for this in python at this point. We're happy to review any pull request if you want to take this on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo 📃
Development

No branches or pull requests

3 participants