Skip to content

v2 : OpenAPI 2.0 file Type Parsing Incorrectly Handled #2303

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
huaxing-yuan opened this issue Apr 3, 2025 · 0 comments · Fixed by #2305
Closed

v2 : OpenAPI 2.0 file Type Parsing Incorrectly Handled #2303

huaxing-yuan opened this issue Apr 3, 2025 · 0 comments · Fixed by #2305
Milestone

Comments

@huaxing-yuan
Copy link

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

  1. Load the PetStore OpenAPI 2.0 example: https://petstore.swagger.io/v2/swagger.json
  2. Examine the /pet/{petId}/uploadImage operation
  3. Observe the file parameter 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

Image

Image

Additional context

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants