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

How to specify the return type for an API that writes to the output directly via stream #81

Open
dtyree-spyderbat opened this issue Jun 9, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@dtyree-spyderbat
Copy link

Hi,

We're returning a large ndjson stream on some calls, and the problem we have is that we can't figure out how to get fizz go generate an openapi spec that indicates that ndjson is returned as the output, so instead the spec indicates nothing is returned.

We're essentially writing x-ndjson directly to the Writer on the context.

We tried using a fizz.Response(200...) but we can't override that.

@sberryman
Copy link

I ran into this problem today and it doesn't look possible with tonic.

https://github.com/loopfz/gadgeto/blob/ecd126f80b95fae7372be52e0e0f119d4e46f5d2/tonic/handler.go#L37-L65
The options function appears useless because the tonic.Route struct is mostly private.

@wI2L
Copy link
Owner

wI2L commented Jul 27, 2022

The media type of the operations' response is defined by the media type that Tonic uses to encode responses, and it is limited to json and xml.

It think we should allow to override the media type per operation for the response using a fizz.Option, when the route is declared.

Does any one of you wish to send a PR ? Otherwise I'll look into it when I have the time.

@mcorbin
Copy link
Contributor

mcorbin commented Jul 31, 2022

Does any one of you wish to send a PR ? Otherwise I'll look into it when I have the time.

I did it in loopfz/gadgeto#87 a while ago on Tonic, and mcorbin@1b8b7d7 on Fizz to generate the proper OpenAPI doc based on routes media types.

@wI2L
Copy link
Owner

wI2L commented Aug 18, 2022

@mcorbin Reviewed the PR on tonic, waiting for another approval/check. Once its ok, send the PR on fizz to close this issue, and I'll review it.

@wI2L wI2L added the enhancement New feature or request label Aug 18, 2022
@mcorbin
Copy link
Contributor

mcorbin commented Sep 5, 2022

Thank you @wI2L . There is a lot of interesting MR on Tonic which should be interesting to merge (for now I forked both repositories and merged everything on my side).
Do you know what is Tonic status regarding maintenance ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants