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

Any way to incorporate binary streams? #24

Open
travis-leith opened this issue Aug 12, 2021 · 1 comment
Open

Any way to incorporate binary streams? #24

travis-leith opened this issue Aug 12, 2021 · 1 comment

Comments

@travis-leith
Copy link

I am dealing with a response spec like this

"responses": {
          "200": {
            "description": "Retrieved media content",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/error"
          }
        }

The return data can be very large, far larger than can fit into memory.
In this case, I have no choice but to consume it as a stream.

For content type application/octet-stream would you consider returning as a stream?

@Zaid-Ajaj
Copy link
Owner

Hi @travis-leith this is an interesting case 🤔 When encountering an application/octet-stream, the generator assumes that it is byte[] by default.

I can imagine having the knowledge of a couple of endpoints that are known to return a large stream of data, in which case maybe it is an option to tell Hawaii that these endpoints should be returning Stream for these endpoints?

We can implement such an option via configuration:

{
    "streamingOperations": ["getLargeFile", "downloadMovie"] 
}

The implementation however is another story and will require quite a bit of work 😅

What do you think about the proposal? Because by default, I do believe byte[] is a good response type for ease of use (not having to deal with streams because they are not beginner-friendly)

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

No branches or pull requests

2 participants