C# byte type incorrectly translated to OpenAPI type:string/format:byte
nickmcummins opened this issue · 0 comments
nickmcummins commented
In the Data Types - Format section of the OpenAPI/Swagger spec, it defines the byte
as a format of the string type:
byte
– base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==
However in C# a byte
is an 8-bit unsigned integer (i.e. numeric value of 0 to 255). With the current implementation, calling an API using the generated API client (from the OpenAPI spec generated by this tool) will result in an error when parsing the JSON payload of an object which has a byte field, as the payload has this property as a numeric rather than string:
"byteProperty": 0,
Lines 23 and 38 of TypeExtensions.cs should likely be changed such that the generated OpenAPI schema result in byte properties as:
byteProperty:
type: integer
minimum: 0
maximum: 255