joukevandermaas / saule

JSON API library for ASP.Net Web API 2.
https://joukevandermaas.github.io/saule
MIT License
76 stars 37 forks source link

Moved QueryContext action parameter initialization to more common place #213

Open sergey-litvinov-work opened 5 years ago

sergey-litvinov-work commented 5 years ago

Hi Jouke,

We had a case when WebApi action has ObjectContext parameter and then HandlesQuery attribute passes current ObjectContext value as paramter. So endpoint can consume\handle current context.

I did two changes there:

  1. I moved that code that initialize ObjectContext in action's parameter to more common place QueryContextUtils so now it will be available to any action that needs it, and not only by action that has HandlesQuery. So if endpoint with AllowsQuery wants to get current context for logging\other reasons, then it can get it

  2. I also added Fieldset initialization to HandlesQuery so now it also can use fields logic too. As before that it would ignore it and ObjectContext won't parse actual Fieldset value

joukevandermaas commented 5 years ago

Thanks, this looks quite useful!

Just to make sure, this is not a breaking change, correct? It seems like it is not, but I'd rather make sure.

Also, do you think it is possible to write a test for this new functionality? I'd love not to break it accidentally in the future.

sergey-litvinov-work commented 5 years ago

@joukevandermaas sorry for so long answer. I missed your answer. so it didn't work for us so well, so we handled it in different way on top of Saule. It shouldn't be breaking changes as initially it worked only for HandlesAttribute and after that change it will be working for every case

If you want this change, i can add more unit tests and update PR