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(gen client): added support to work with multiple mimes #3042

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Jan 3, 2024

  1. fix: no longer sort producers and consumers
    The client runtime picks the first one, so the order is relevant.

  2. feat: added extra options to set media type
    For client codegen only, AND whenever a single group of operations
    deals with more than one media for producers OR more than one media
    for consumers , THEN we generate an extra set of convenience ClientOption
    functions to switch media type.

    Generates generic options to set the mime as an arbitrary string
    (comes in handy to set mime extensions):

    WithContentType(string) (to negotiate consumers)
    WithAccept(string) (to negotiate producers)

    Generate shorthands with a mangled name such as:
    WithContentTypeApplicationxWwwFormUrlencoded
    to be used directly as an option.

  • Simple APIs with a single producer and a single consumer are not
    affected.

  • Server codegen is not affected

  • test: content type is not sorted

  • test: asserted codegen

NOTE: see #2773 on github issues for a complete analysis.
The part of that issue relative to the runtime client not supporting
file upload with application/x-www-form-urlencoded is obviously not
fixed by this PR.

Signed-off-by: Frédéric BIDON fredbi@yahoo.com

* fixes go-swagger#2773

1. fix: no longer sort producers and consumers
   The client runtime picks the first one, so the order is relevant.

2. feat: added extra options to set media type
   For client codegen only, AND whenever a single group of operations
   deals with more than one media for producers OR more than one media
   for consumers , THEN we generate an extra set of convenience ClientOption
   functions to switch media type.

   Generates generic options to set the mime as an arbitrary string
   (comes in handy to set mime extensions):

   WithContentType(string) (to negotiate consumers)
   WithAccept(string) (to negotiate producers)

   Generate shorthands with a mangled name such as:
	`WithContentTypeApplicationxWwwFormUrlencoded`
   to be used directly as an option.

* Simple APIs with a single producer and a single consumer are not
affected.
* Server codegen is not affected

* test: content type is not sorted
* test: asserted codegen

> NOTE: see go-swagger#2773 on github issues for a complete analysis.
> The part of that issue relative to the runtime client not supporting
> file upload with application/x-www-form-urlencoded is obviously not
> fixed by this PR.

Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
@fredbi fredbi force-pushed the fix/2773-part1-mime-ordering branch from 0b235d0 to 353609c Compare January 3, 2024 21:02
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (876c950) 0.00% compared to head (0b235d0) 0.00%.

❗ Current head 0b235d0 differs from pull request most recent head f494956. Consider uploading reports for the commit f494956 to get more accurate results

Additional details and impacted files
@@      Coverage Diff       @@
##   master   #3042   +/-   ##
==============================
==============================

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

@fredbi fredbi changed the title no longer sort producers and consumers feat(gen client): added support to work with multiple mime Jan 3, 2024
@fredbi fredbi marked this pull request as ready for review January 3, 2024 21:09
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
@fredbi fredbi changed the title feat(gen client): added support to work with multiple mime feat(gen client): added support to work with multiple mimes Jan 3, 2024
@fredbi fredbi merged commit 8003cfb into go-swagger:master Jan 4, 2024
18 checks passed
@fredbi fredbi deleted the fix/2773-part1-mime-ordering branch January 4, 2024 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request Content-Type isn't multipart/form-data
2 participants