Skip to content

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

@ianseyer

Description

@ianseyer
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions