Skip to content

Invalid Swift code for multipart POST with query parameters #2557

@tomekc

Description

@tomekc

When endpoint is multipart/form-data and contains both form params and query params, like this one

/profile/{id}/photo:
    post:
      operationId: addProfilePhoto
      consumes:
        - multipart/form-data
      parameters:
        - name: id
          in: path
          required: true
          type: string
        - name: file
          in: formData
          required: true
          type: file
          minLength: 1
          maxLength: 10000000  # ~10MB
        - name: attachmentType
          in: query
          type: string
          required: true
        - name: utf8FileName
          in: query
          type: string
          required: true

Resulting code has double "falsefalse" argument in

        return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: falsefalse)

I have found mustache template for this:

isBody: {{^queryParams}}{{^formParams}}true{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}}{{#formParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/formParams}}

and probably end up with PR to fix :) Any suggestions are welcome, however :)

One thing I'd like to learn is what is "secondaryParam"?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions