OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.28k stars 6.44k forks source link

[BUG] multipart/form-data in Swift URL instead of Data #15871

Open goors opened 1 year ago

goors commented 1 year ago

This part:


"requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "Trekk": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },

generates

open class func adventuresUploadTrackWithRequestBuilder(id: String, trekk: URL? = nil) -> RequestBuilder<String> {///} and then inside that it generates


let localVariableFormParams: [String: Any?] = [
            "Trekk": trekk?.encodeToJSON(), // json?
        ]

Adding --global-property skipFormModel=false does not do anything.

teameh commented 4 weeks ago

This is expected behaviour. This the url later be loaded from disk when encoding the request. See https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache#L527

So when executing the actual request the file is loaded from disk and added to the request body