Conversation
|
Sounds good.
Currently away. I'll check this when back home.
…--
Jérôme
|
c7b8924 to
c2de7d9
Compare
a594ef7 to
d880079
Compare
|
Updated the method for adding resolver functions and am now providing a way to allow those functions to have access to the FieldConverter instance so that they call other methods like |
|
Although #476 was merged, GH still presents the whole diff. Do you think you could ensure it only shows the diff from this PR only? You could close and recreate a new PR, but maybe it works by just push-forcing, I don't know. |
c2de7d9 to
e80cebe
Compare
|
Just rebased and forced pushed. I would want to squash the last two commits before merging. Leaving here for now to show multiple ways this could work. |
bffe67b to
4deeea7
Compare
|
I just pushed an additional commit in which I change This makes it closes to former design while still separating responsibilities. Just a suggestion, we can revert it. Feedback welcome. @Bangertm if that suits you, I think we can merge.
|
New class is called FieldConverter and contains field2property and it's dependencies
Now passing the ret dictionary to all attribute functions
4deeea7 to
3001cda
Compare
|
I like the mixin approach - simpler for the user and less logic with passing around callbacks. Just added some documentation. Can you take a look and make sure it's clear. |
|
Yes, I like mixin too. The separation still leaks since Looks good to me. Thanks ! You may squash some commits before merging if you wish. I don't mind either way. Perhaps also add a note to the CHANGELOG if you can. Otherwise, we'll do it later. |
d70e004 to
137813b
Compare
|
Ideally I would have extracted the field logic as a mixin originally. Let's just leave all the commits as is... |
|
Should we mention half of Also, could it be worth making |
I took a shot at making
field2propertyextensible for users to add custom attribute functions that can add attributes to the property dictionary.FieldConverter.field2propertyfor a specific field.I think that this is probably fine for most applications that I have seen in the issues. There are a couple of things I'm not super happy with:
Many of the attribute functions we have today depend on being a method so that they can have access toself. For examplefield2write_onlyrelies on the OpenAPI version number. The logic for handling Nested, List, and Dictionary fields rely on calling other methodsresolve_nested_fieldandfield2property. The current mechansim wouldn't allow for that flexibility.Right now I haveMarshmallowPlugininitialized with parameters that only needs to pass on to other classes. Might make more sense to allowMarshmallowPluginto be initialized with an instance ofOpenAPIConverterand then update it wheninit_specis called. Or maybe there is something else we can do.Note: I have this pull request targeted to my latest branch to make the changes easier to understand.