swagger-api/swagger-codegen

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

開放

#3,435 建立於 2016年7月21日

 (16 則留言) (0 個反應) (0 位負責人)HTML (5,474 個分叉)batch import
Client: PythonIssue: Invalid spechelp wanted

倉庫指標

星標
 (12,701 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南