swagger-api / swagger-api/swagger-codegen

Python bearerAuth not generated

Open
#10,060 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

in my description i've this

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
- basicAuth: []
- bearerAuth: []

however in the auth_setting function in the configuration.py there's no bearerAuth

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

        :return: The Auth Settings information dict.
        """
        return {
            'basicAuth':
                {
                    'type': 'basic',
                    'in': 'header',
                    'key': 'Authorization',
                    'value': self.get_basic_auth_token()
                },
        }

while it should be something like

        """Gets Auth Settings dict for api client.

        :return: The Auth Settings information dict.
        """
        return {
            'basicAuth':
                {
                    'type': 'basic',
                    'in': 'header',
                    'key': 'Authorization',
                    'value': self.get_basic_auth_token()
                },
            'bearerAuth':
                {
                    'type': 'http',
                    'in': 'header',
                    'key': 'Authorization',
                    'value': self.get_api_key_with_prefix('Jwt')
                },
        }

(not sure why there's an identifier to specify)

am I missing anything?

Swagger-codegen version

3.0.17

Swagger declaration file content or url

see above

Command line used for generation

java -jar codegen/swagger-codegen-cli.jar generate -i scriba-openapi-api.yml -c python/python-config.json -DpackageVersion=2.2.0-13-g1e6a6bc -o python/api -l python

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated Python configuration.py and the OpenAPI securitySchemes example, then reproduce generation with the documented swagger-codegen command. Trace how basicAuth is emitted in auth_settings and verify that bearerAuth is also represented with the expected Authorization header when the generated client is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.