OpenAPITools / OpenAPITools/openapi-generator
[BUG] [python-flask] oauth has default values of scopes 'read:pets', 'write:pets' and uid
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [X ] Have you provided a full/minimal spec to reproduce the issue?
- [X ] Have you validated the input using an OpenAPI validator (example)?
- [ x] What's the version of OpenAPI Generator used?
- [ x] Have you search for related issues/PRs?
- [ x] What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
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/security_controller_.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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by regenerating the Python Flask server with the provided OpenAPI declaration and npx openapi-generator generate -i openapi.yaml -g python-flask. Inspect controllers/security_controller_.py, focusing on the generated OAuth security handling. Done means the generated code no longer emits the hard-coded read:pets, write:pets, or user_id defaults when the specification does not define them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100