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

[BUG] example for byte buffer body not rendered properly #2256

Closed
sebarys opened this issue Jun 21, 2022 · 2 comments · Fixed by #2257
Closed

[BUG] example for byte buffer body not rendered properly #2256

sebarys opened this issue Jun 21, 2022 · 2 comments · Fixed by #2257

Comments

@sebarys
Copy link

sebarys commented Jun 21, 2022

Tapir version: 0.20.2

Scala version: 2.13.8

Describe the bug
for out of type byteBufferBody when I provided example value:

      .out(
        byteBufferBody.example(Example.of(ByteBuffer.wrap(SampleExportContent.getBytes)))
          and header("Content-Type", "text/csv")
      )

generated openapi example is java.nio.HeapByteBuffer[pos=0 lim=2018 cap=2018], not provided, stringified value

      responses:
        '200':
          description: ''
          headers:
            Content-Type:
              required: true
              schema:
                type: string
          content:
            text/csv:
              schema:
                type: string
                format: binary
              example: java.nio.HeapByteBuffer[pos=0 lim=2018 cap=2018]

Additional information

IMO for binary responses only text examples makes sense (are possible to display e.g. in swagger) so maybe we could convert provided example ByteBuffer to string?

@adamw
Copy link
Member

adamw commented Jun 21, 2022

@sebarys Would you assume a utf-8 string? or hex?

@sebarys
Copy link
Author

sebarys commented Jun 21, 2022

I think utf-8 (maybe it could be configurable if you see any use case for hex example in docu)

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 a pull request may close this issue.

2 participants