Skip to content

auto generated swift client problem - headers missing #1345

Closed

Description

@inska

Hi,

I created an auto generated swift client with swagger-codegen, and successfully imported into my xcode project. However, it seems that there's no logic for sending custom headers unlike other sdks.

Seems Ok with Python and Ruby SDK to call server with valid custom headers, but only swift SDK seems missing to sending headers.

Does passing custom headers with auto generated swift client is possible?

Best,
Inseok

Activity

  1. added this to the Future milestone on Oct 7, 2015
  2. wing328 commented on Oct 7, 2015

    @wing328
    Contributor

    @inska can you tell us a bit more about the custom header? Is that required for all HTTP requests? Is that for authentication?

  3. inska commented on Oct 8, 2015

    @inska
    Author

    Right. I mean about api_key. I'll use custom header for API Key. Other clients supports api_key_prefix to store api_keys, and clients sending that headers with.

    Thanks!

  4. wing328 commented on Oct 8, 2015

    @wing328
    Contributor

    @inska Likely that has not been implemented in the Swift client and we would appreciate the contribution from you and the community to add that.

  5. tomekc commented on Oct 21, 2015

    @tomekc
    Contributor

    You can work this around actually:
    When calling DefaultApi.yourMethod, the return value is RequestBuilder.
    In RequestBuilder you can call

    rb.addHeader(name: "Authorization", value: "Bearer \(config.accessToken)")

    I am doing this way and it works for me, however, solution for globally defined custom header would be great. Currently you can only add Basic HTTP Auth header, which - IMHO is IMHO quite useless - I can't imagine any service authenticating that way.

  6. tomekc commented on Oct 28, 2015

    @tomekc
    Contributor

    I updated Swift template so you can add custom headers to dictionary defined in {{name}}API class.
    I works for me (my app's backend need custom authentication header) so I think I will submit a PR.

  7. tomekc commented on Nov 2, 2015

    @tomekc
    Contributor

    Created PR #1492 - a generic solution to add any header to all requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions