OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.56k stars 6.52k forks source link

[BUG] [python-flask] oauth has default values of scopes 'read:pets', 'write:pets' and uid #2254

Open wrighting opened 5 years ago

wrighting commented 5 years ago

Bug Report Checklist

Description

The python flask generated code always uses default scopes and uid for oauth security

openapi-generator version

@openapitools/openapi-generator-cli@cli-4.0.0-beta2

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: ""
  version: 1.0.0
  title: 
  termsOfService: http://swagger.io/terms/
  contact:
    email:
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
security:
  - OAuthSecurity:
security:
  - OAuthSecurity:
    - editor
paths:
  '/test':
    get:
      description:
      responses:
        '200':
          description:
          content:
            application/json:
              schema:
                type: string

servers:
  - url: http://localhost/v1
components:
  securitySchemes:
    OAuthSecurity:
      type: oauth2
      x-tokenInfoUrl: https:///oauth2.0/profile
      flows:
        authorizationCode:
          authorizationUrl: https:///oauth2.0/authorize
          tokenUrl: https:///oauth2.0/accessToken
          scopes:
            editor: Access all areas
Command line used for generation

npx openapi-generator generate -i openapi.yaml -g python-flask

Steps to reproduce

In controllers/securitycontroller.py

return {'scopes': ['read:pets', 'write:pets'], 'uid': 'user_id'}
Related issues/PRs
Suggest a fix

There should not be a default scopes, uid value even if it's not properly configured (I couldn't see where to define uid in the openapi spec)

auto-labeler[bot] commented 5 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

wrighting commented 5 years ago

I've found that if I remove x-tokenInfoFunc from the generated openapi.yaml then it will work as expected