-
Notifications
You must be signed in to change notification settings - Fork 12
Is there any way to define what is being returned from the service (wrapping it into a class)? #515
Comments
Hi @caiobiodere, Would be nice to see some pseudocode you have in mind if you can write that down. |
@KnisterPeter yeah that's exactly what I meant sorry english is not one of my best things yet, still getting in there :) yes sure can do that give me a couple of days will figure out how to do that |
@caiobiodere no need to say sorry 😃 We all are non native speakers. You're welcome. Before start coding a rough scribble of pseudo code might help me to understand your requirements. Maybe what you try to achieve is already possible, not sure. |
@KnisterPeter thanks for understanding mate! getting into it, the idea behind all of this would be something similar to this:
|
Hi @caiobiodere, In general I could think of adding this feature, I like it. |
Hi mate @KnisterPeter,
I could use keyPath as "user" and tell the decorator to wrap into the User class from it, this would save a lot of scenarios I can tell that because most of the time API's are not in the way you really want them to be |
Instead I would propose to allow this to be a function. Then if the reponse is not matching it could be updated by that. Like this: @Response(type: User, transform: (input) => input.user)
public async get(id: string, parameters: any) : User {} |
I like your idea better, do you want me to help with that? I really want this to be part of my current working project |
You can give it a try. I would accept a PR if you like. |
Lets get this running, will be watching and forking this project from now on, do you have an idea of how much time would it take to you to get a first version of this done? |
if you think you can finish this in a couple of days I can wait mate, that would be no problem at all |
@caiobiodere I'll definitely build this this week I think. |
This implements data mappers to create classes from responses with optional transform step. Closes #515
@KnisterPeter hey mate I saw you started it already, how is it going do you have an estimated time? |
The PR could be reviewed by you, it's already done. |
@caiobiodere Any comments or thoughts? I'd like to make a release out of this. |
These are the docs in the README |
This implements data mappers to create classes from responses with optional transform step. Closes #515
Released in v3.1.0 |
thanks mate! I think that's good enough regarding it also fixes my case :) |
Hey everyone first of all thanks for creating this, I was thinking about doing something like this for a project but you guys got it covered! second here comes my question I still don't know if it is possible to define a response type like a class being created from what is returned from the service. I would probably also want to define which path of the object should be pointed to this class this could be a decorator. What do you guys think about all of this? I might be interested in helping this project it is really what I have been doing with Swift using Sourcery :)
The text was updated successfully, but these errors were encountered: