Examples not reads when `format: byte`
See original GitHub issueHello there,
From the openapi-style-validator project, we have an issue with properties of type string
and format byte
where the example
is not read: https://github.com/OpenAPITools/openapi-style-validator/issues/132
Schema:
schemas:
Response:
required:
- content
properties:
content:
type: string
format: byte
example: "VGhpc1Nob3VsZFBhc3MK"
Expected:
An OpenAPI with example
set for the content
property.
Actual:
example
is null
.
We do not know if this is expected behaviour or an issue on the parser, can someone tell us more on that “issue” ?
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Problems with writing bytes format of string data in Text File in ...
Your first file is binary, in a way. It just so happens that bytes represent human-readable text. The f and F in your...
Read more >Understanding Big and Little Endian Byte Order
If we store and read data one byte at a time, it will work on any computer. ... This example does not depend...
Read more >struct — Interpret bytes as packed binary data — Python 3.11 ...
Iteratively unpack from the buffer buffer according to the format string format. This function returns an iterator which will read equally sized chunks...
Read more >read
The read() function shall attempt to read nbyte bytes from the file associated with the open file descriptor, fildes, into the buffer pointed...
Read more >FileStream.Read Method (System.IO) - Microsoft Learn
Reads a block of bytes from the stream and writes the data in a given buffer. ... The following example reads the contents...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gervaisb
we have added indeed such conversion in https://github.com/swagger-api/swagger-core/pull/4147, therefore you can use it if it fits your needs (by using parser “as is” , with no
swaggerParserBinaryAsString
property/env set).The first possible issue with this approach is that the conversion / data binding is opinionated, as it uses
getBytes()
to encode the string into bytes, while e.g. the serialized string could be meant to be a Base64 encoded representation of the bytes (Jackson e.g. uses Base64 for default binding ofstring
tobyte[]
)Another issue is serialization of the parsed string, in this case the serialized value will be encoded in Base64, resulting in a different string from the one parsed.
We might choose to try using Base64 in the
cast
method above, but again this would be an opinionated choice, given also that e.g.example
is ofany
type in OAS 3.0, possibly including any encoding/representation of binary valuesAn additional issue is serialization to
YAML
; YAML is capable to represent binary using tags, and indeed default serialization uses that, therefore a YAML version of the same spec, with the same string value in example as the one in JSON version, would not be parsed correctly (would actually break).We could further address the points above by e.g. providing more options and addressing the different cases, but on top of adding quite some complexity and being not trivial, the expected behaviour would be dependent on the specific spec.
no fixed ETA but probably within first week of April