Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13817
Closed
Open
Issue created Oct 25, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[REQ] Python client will not allow request auth overrides in

Created by: dd-ashishaev

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Currently, if the openapi spec doesn't define auth for an endpoint, the users won't be able to set custom auth on individual requests via _request_auths.

This is due to this line:

https://github.com/OpenAPITools/openapi-generator/blob/3501771a2e001fb4dafeed50abcaecc69b164512/modules/openapi-generator/src/main/resources/python/api_client.handlebars#L1236-L1237

openapi-generator version

v6.2.0

OpenAPI declaration file content or url

This is an endpoint from petstore.yaml that will have this issue. The only difference with the original endpoint is that security: keys are removed.

paths:
  /pet:
    post:
      tags:
        - pet
      summary: Add a new pet to the store
      description: ''
      operationId: addPet
      responses:
        '200':
          description: successful operation
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        '405':
          description: Invalid input
      requestBody:
        $ref: '#/components/requestBodies/Pet'
    put:
      tags:
        - pet
      summary: Update an existing pet
      description: ''
      operationId: updatePet
      responses:
        '200':
          description: successful operation
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        '400':
          description: Invalid ID supplied
        '404':
          description: Pet not found
        '405':
          description: Validation exception
      requestBody:
        $ref: '#/components/requestBodies/Pet'
Generation Details

This happens when python is used as the template, irrespective of the config.

Steps to reproduce

This line looks like it would respect the custom auth settings, judging by api_client.py:

api_response = api_instance.v3_my_endpoint(endpoint_body, _request_auths=[{'in':'header', 'type': 'bearer', 'key': 'Authorization', 'value': f"Bearer {TOKEN}"}])

However, the request will still be sent without any auth settings, no exceptions thrown.

Related issues/PRs
Assignee
Assign to
Time tracking