swagger-api/swagger-codegen

[Python]Client library does not generate auth_settings with multiple definitions

Open

#3,435 创建于 2016年7月21日

在 GitHub 查看
 (16 评论) (0 反应) (0 负责人)HTML (12,701 star) (5,474 fork)batch import
Client: PythonIssue: Invalid spechelp wanted

描述

Description

I am using swagger-codegen to generate a python client library based on a spec with multiple security definitions. The generated library is both not generating all the security definitions, and doesn't even attempt to use the one that was generated.

Security definitions in configuration.py. Note the lack of "knurld_auth" OAuth definition:

    def auth_settings(self):
        """
        Gets Auth Settings dict for api client.

        :return: The Auth Settings information dict.
        """
        return {
            'developer_id':
                {
                    'type': 'api_key',
                    'in': 'header',
                    'key': 'Developer-id: Bearer:',
                    'value': self.get_api_key_with_prefix('Developer-id: Bearer:')
                },

        }

Contents of all methods in api_client.py indicate no security definition being used:

# Authentication setting
        auth_settings = []
Swagger-codegen version

2.0

Swagger declaration file content or url

https://gist.github.com/ianseyer/f3610a13702aaee9dd4b2d804222512f

The relevant part:

  "securityDefinitions": {
    "developer_id": {
      "type": "apiKey",
      "name": "Developer-id: Bearer:",
      "in": "header"
    },
    "knurld_auth": {
      "type": "oauth2",
      "authorizationUrl": "https://api.knurld.io/oauth/client_credential/accesstoken?grant_type=client_credentials",
      "tokenUrl": "https://api.knurld.io/oauth/client_credential/accesstoken?grant_type=client_credentials",
      "flow": "application"
    }
  }
Command line used for generation

swagger-codegen generate -i swagger.compiled.json -o python/ -l python

Steps to reproduce

Download swagger spec, generate, browse the source.

Suggest a Fix

Check for proper definitions within swagger-codegen. No errors or warnings were thrown.

贡献者指南