Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

C# byte type incorrectly translated to OpenAPI type:string/format:byte #235

Open
nickmcummins opened this issue Sep 9, 2020 · 0 comments

Comments

@nickmcummins
Copy link

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant