Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

openapi2conv: invalid transformation for type: file #979

Closed
reversearrow opened this issue Jul 9, 2024 · 0 comments
Closed

openapi2conv: invalid transformation for type: file #979

reversearrow opened this issue Jul 9, 2024 · 0 comments

Comments

@reversearrow
Copy link
Contributor

reversearrow commented Jul 9, 2024

OpenAPI Version 2 (Swagger) supports a primitive type type: file to denote the response as being a file. Data Types documentation.

However, OpenAPI 3.0 does not have a "file" type; instead, file is defined as type: strings with the format: binary (reference).

When using openapi2conv to convert from OAS v2 to v3, the converter does not correctly convert type: "file" to type: "string" with format: "binary". This results in a OpenAPI V3 validation error.

For example, a v2 path with a GET operation:

 "/foo": {
    "get": {
        "description": "foo",
        "operationId": "foo",
        "produces": [
            "application/pdf",
            "application/json"
        ],
        "responses": {
            "200": {
                "description": "returns all information about foo",
                "schema": {
                    "type": "file"
                }
            },
            "400": {
                "description": "bad request"
            },
            "500": {
                "description": "internal server error"
            }
        },
        "summary": "get foo document"
    }
}

Gets converted to V3 document with type: file as type: file instead of the type: "string" with format: "binary"

 "/foo": {
    "get": {
        "description": "foo",
        "operationId": "foo",
        "responses": {
            "200": {
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "file"
                        }
                    },
                    "application/pdf": {
                        "schema": {
                            "type": "file"
                        }
                    }
                },
                "description": "returns all information about foo"
            },
            "400": {
                "description": "bad request"
            },
            "500": {
                "description": "internal server error"
            }
        },
        "summary": "get foo document"
    }
}

The type: "file" should be converted to type: "string" and format: "binary".

 "/foo": {
    "get": {
        "description": "foo",
        "operationId": "foo",
        "responses": {
            "200": {
                "content": {
                    "application/json": {
                        "schema": {
                            "format": "binary",
                            "type": "string"
                        }
                    },
                    "application/pdf": {
                        "schema": {
                            "format": "binary",
                            "type": "string"
                        }
                    }
                },
                "description": "returns all information about foo"
            },
            "400": {
                "description": "bad request"
            },
            "500": {
                "description": "internal server error"
            }
        },
        "summary": "get foo document"
    }
}
@reversearrow reversearrow closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant