Skip to content

Parameters to be passed in headers are ignored during API generation #195

Description

@Mrteller

The question is if this behaviour is intended or not.

Suppose we have a piece of some swagger.json. At some It contains parameter "AccessKey" which should be passed in header according to the specification.

{
  "openapi": "3.0.1",
  "info": {
    "title": "Client info API",
    "description": "CRM loyalty",
    "termsOfService": "https://example.com",
    "contact": {
      "name": "Some Contact",
      "url": "https://example.com",
      "email": "info@example.com"
    },
    "version": "v3"
  },
  "paths": {
    "/api/v3/clients/accesstoken": {
      "post": {
        "tags": [
          "ClientsV3"
        ],
        "summary": "Creates client token",
        "description": "Token to be used to obtain a concrete client info",
        "parameters": [
          {
            "name": "AccessKey",
            "in": "header",
            "description": "API access key",
            "schema": {
              "type": "string",
              "description": "API access key",
              "nullable": true
            }
          }
        ],
        "requestBody": {
        ...

Everything generates fine except for header param. As a walk-around it is possible to use custom configuration for APIClient.

        let config = URLSessionConfiguration.default
        config.httpAdditionalHeaders = ["AccessKey" : accessKey] 
        api = APIClient(configuration: APIClient.Configuration(baseURL: baseURL, sessionConfiguration: config))

This is totally fine in some cases. But if looks like in general those parameters should be reflected somehow in generated API. At least optionally.

Used API Version 0.2.0.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions