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

[Query] Dynamic Querystring Parameters implemented #435

Merged
merged 21 commits into from
Aug 3, 2024

Conversation

JeremyBP
Copy link
Contributor

Well, first of all, my apologies about such a git log. It was a rebasing spagetti nigthmare as I decided to start from the apizr branch instead of the main one. It gives that over commiting git log, but actually brings no other changes than the Dynamic Querystring Parameters feature implementation, plus some specific Apizr code adjustments.
I think I really need holidays :)

That said, the main change here to reach our goal as discussed into #417 is about the ParameterExtractor.
When the threshold is set to 2 or more, it now returns the filtered parameters to be added to the method, plus the query params types to be created under interfaces.
It works with or without Apizr as it has no dependency with it.
It comes with many new tests to cover it and an updated documentation.
It's once again a big fat fish to descover, understand and test before merging.

Again, sorry about my git rebase marmelade gift ^^

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 99.22330% with 4 lines in your changes missing coverage. Please review.

Project coverage is 95.89%. Comparing base (cf6cd27) to head (b13015b).
Report is 1 commits behind head on main.

Files Patch % Lines
src/Refitter.Core/ParameterExtractor.cs 95.08% 0 Missing and 3 partials ⚠️
src/Refitter.Tests/SwaggerPetstoreApizrTests.cs 99.64% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #435      +/-   ##
==========================================
+ Coverage   95.41%   95.89%   +0.47%     
==========================================
  Files          70       71       +1     
  Lines        3406     3853     +447     
==========================================
+ Hits         3250     3695     +445     
  Misses        114      114              
- Partials       42       44       +2     
Flag Coverage Δ
unittests 95.89% <99.22%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@christianhelle christianhelle self-assigned this Jul 31, 2024
@christianhelle christianhelle added the enhancement New feature, bug fix, or request label Jul 31, 2024
Copy link
Owner

@christianhelle christianhelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation, tests, and documentation updates look good. Great work as usual @JeremyBP

As mentioned in a comment below, I have mixed feelings about --dynamic-querystring-parameters-threshold, which I think should be refactored to be a boolean flag instead. Perhaps something called --dynamic-query-string-parameters

Copy link
Owner

@christianhelle christianhelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeremyBP Please include #nullable enable in the generated code when generating dynamic query string parameter wrappers

@JeremyBP
Copy link
Contributor Author

JeremyBP commented Aug 1, 2024

here are most of your suggestions implemented.

But about the #nullable enable directive, I'm quite confused.
First of all, my query wrappers are generated into the same namespace as the interfaces so the #nullable enable directive added by RefitGenerator should apply when it's there.
IMHO, the problem comes from the ? suffixing optional types and depending on openapi definition, where the #nullable enable directive depends on settings.OptionalParameters to true.
It means that we could have code with ? symbol because of openapi def, but no #nullable enable directive because of settings.OptionalParameters set to false.
This is exactly what I get if I run refitter CLI from its latest stable public version with a command like:

refitter https://petstore3.swagger.io/api/v3/openapi.yaml

Again I'm a bit tired the day before my holidays, so I could missunderstand something here.
In my opinion, we should add #nullable enable directive only based on ? check in code, and not on OptionalParameters which is here to reorder et set default value to parameters.
Or maybe, allways add #nullable enable directive from RefitGenerator, no matter of any condition.

@christianhelle
Copy link
Owner

Or maybe, allways add #nullable enable directive from RefitGenerator, no matter of any condition.

You have a point @JeremyBP, and with that in mind, I think that always adding #nullable enable would be the ideal solution

Copy link

sonarqubecloud bot commented Aug 2, 2024

@JeremyBP
Copy link
Contributor Author

JeremyBP commented Aug 2, 2024

Here is our nullable enable 👼
That said, I think I'm done with query feature.
If not, today is my last day at the office so the last chance to change things, otherwise feel free to adjust what needs to be when you're back 👍

@christianhelle
Copy link
Owner

Thanks for this awesome contribution @JeremyBP

Enjoy your well-deserved summer holiday!

@christianhelle christianhelle merged commit 7b80483 into christianhelle:main Aug 3, 2024
424 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants