-
Couldn't load subscription status.
- Fork 270
Description
Describe the bug
When parsing OpenAPI 2.0 specifications containing parameters with type: file, the library (2.0.0-preview.16) converts these to string type without setting format: binary. In my expectation, when viewing OpenAPI 3.x examples, the old file type should be parsed as string with binary format.
We can take a look at /uploadImage service from petStore example
there is a file parameter of type file
"/pet/{petId}/uploadImage": {
"post": {
"tags": [ "pet" ],
"summary": "uploads an image",
"description": "",
"operationId": "uploadFile",
"consumes": [ "multipart/form-data" ],
"produces": [ "application/json" ],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "additionalMetadata",
"in": "formData",
"description": "Additional data to pass to server",
"required": false,
"type": "string"
},
{
"name": "file",
"in": "formData",
"description": "file to upload",
"required": false,
"type": "file"
}
],But after debugging, i found this parameter is parsed to string type with format = null.
I didn't find another usable property in schemas to detect it's binary file and not a string.
OpenApi File To Reproduce
- Load the PetStore OpenAPI 2.0 example: https://petstore.swagger.io/v2/swagger.json
- Examine the
/pet/{petId}/uploadImageoperation - Observe the
fileparameter is parsed as:
type = "string",
format = null // -> Expected Format = "binary"
Expected behavior
Parameters with type: file in OpenAPI 2.0 should be parsed as:
type = "string",
format = "binary"
Screenshots/Code Snippets
Additional context
- OpenAPI 3.x replaced file
typewithstring + binaryformat (spec reference: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#considerations-for-file-uploads) - Current behavior breaks compatibility for tools that rely on format: binary to detect file upload parameters
- This affects code generation where parameters should be treated as binary data (byte[]/Stream) rather than strings

