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

feat: handling x-www-form-urlencoded #687

Conversation

maximeroucher
Copy link
Contributor

@maximeroucher maximeroucher commented Nov 29, 2023

closes #632

Description
Hello,

I discovered this project, and it looked awesome, so I used it in order to replace my custom API call handling functions. It works perfectly for application/json.
However, my API implements OIDC, and thus uses application/x-www-form-encoded instead of application/json.
When running, the generated code for those API routes was throwing error.
After some research, I found that this issue has already been reported, so I am proposing a fix for it.

How does it work?
Until now, x-www-form-encoded were handled the same way as multipart (in swagger_models/requests/swagger_request.dart).
I created a new parameter called isUrlencoded to dissociate these two cases, and used to it handle the right way specified here : https://hadrien-lejard.gitbook.io/chopper/requests#sending-application-x-www-form-urlencoded-data

Checklist
[x] I have performed a self-review of my code
[x] My code follows the code style of this project
[x] I have commented my code, particularly in hard-to-understand areas
If you think this change may be interesting to add to swagger-dart-code-generator, I will be happy to improve the pull request based on received feedback and suggestions.

Best regards

@Vovanella95
Copy link
Collaborator

Hi @maximeroucher , thanks for contribution

Copy link

codecov bot commented Dec 1, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f874a5d) 55.73% compared to head (2d2fd0c) 54.92%.
Report is 5 commits behind head on master.

Files Patch % Lines
...rc/code_generators/swagger_requests_generator.dart 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #687      +/-   ##
==========================================
- Coverage   55.73%   54.92%   -0.81%     
==========================================
  Files          10       10              
  Lines        1229     1238       +9     
==========================================
- Hits          685      680       -5     
- Misses        544      558      +14     

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

@Vovanella95
Copy link
Collaborator

@maximeroucher please resolve conflicts

@maximeroucher maximeroucher force-pushed the fix/supporting-x-www-form-urlencoded branch from 7c495e0 to 2d2fd0c Compare December 1, 2023 19:32
@maximeroucher
Copy link
Contributor Author

Here you go !

@Vovanella95 Vovanella95 merged commit fd408fe into epam-cross-platform-lab:master Dec 4, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ContentType application/x-www-form-urlencoded generates wrong chopper code generation
2 participants