openapi-json-schema-generator icon indicating copy to clipboard operation
openapi-json-schema-generator copied to clipboard

Python generator: Add OAuth2_Password security feature.

Open tito97sp opened this issue 1 year ago • 4 comments

This PR is part of #403

Not ready to merge.

Missing endpoint tests.

Note: this continues work started in https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/pull/155

PR checklist

  • [ ] Read the contribution guidelines.
  • [ ] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • [ ] Run the following to build the project and update samples:
    mvn clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/python*. For Windows users, please run the script in Git BASH.

tito97sp avatar Mar 10 '24 20:03 tito97sp

Error detected on scope_names definition for OAuth2PasswordBearer flow:

Traceback (most recent call last):
  File "/home/tito97sp/development/oauth2password/client/client_app_get_auth.py", line 42, in <module>
    api_response = api_instance.read_users_me_users_me__get()
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/paths/users_me/get/operation.py", line 90, in _read_users_me_users_me__get
    raw_response = self.api_client.call_api(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/api_client.py", line 1036, in call_api
    self.update_params_for_auth(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/api_client.py", line 1157, in update_params_for_auth
    security_scheme_instance.apply_auth(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/security_schemes.py", line 373, in apply_auth
    raise exceptions.ApiValueError('scope_names are not defined and are required, define them')
oauth2password.exceptions.ApiValueError: scope_names are not defined and are required, define them

API used for testing: oauth2password.json

Further work required.

@spacether how can I add this API for the endpoint tests??

tito97sp avatar Mar 10 '24 22:03 tito97sp

Error detected on scope_names definition for OAuth2PasswordBearer flow:

Traceback (most recent call last):
  File "/home/tito97sp/development/oauth2password/client/client_app_get_auth.py", line 42, in <module>
    api_response = api_instance.read_users_me_users_me__get()
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/paths/users_me/get/operation.py", line 90, in _read_users_me_users_me__get
    raw_response = self.api_client.call_api(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/api_client.py", line 1036, in call_api
    self.update_params_for_auth(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/api_client.py", line 1157, in update_params_for_auth
    security_scheme_instance.apply_auth(
  File "/home/tito97sp/.local/share/Trash/files/python/src/oauth2password/security_schemes.py", line 373, in apply_auth
    raise exceptions.ApiValueError('scope_names are not defined and are required, define them')
oauth2password.exceptions.ApiValueError: scope_names are not defined and are required, define them

API used for testing: oauth2password.json

Further work required.

@spacether how can I add this API for the endpoint tests??

Can you edit this file: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/blob/master/src/test/resources/3_0/security.yaml so include your oauth2 security and add it to a rout in that spec?

  • Then please regenerate the samples per the PR instructions (please do not delete them, they are useful)
mvn clean package 
./bin/generate-samples.sh

spacether avatar Mar 11 '24 20:03 spacether

@JoftheV how are you involved in this project? Pull reviews need to be feature complete and have all tests passing before they are approved and merged to master. This PR is not yet feature complete and tests are not yet passing. Are you a user who wants this feature? If so a comment saying that would be more helpful than an approval of the PR. I also just updated PR review privledges to limit it to read and higher members of this project.

spacether avatar Mar 17 '24 17:03 spacether

Hi @spacether. I have added manual tests for oauth password in my last commit https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/pull/404/commits/e46ba81b8c63ac1ad3091ea39bb5c77ad0e47773 but still not working properly the tests. I ask for some support here to refine this tests.

Could your team help me here?

Test definition: test_get.py](https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/pull/404/files/e46ba81b8c63ac1ad3091ea39bb5c77ad0e47773..92f013820df14846a2523e4858b3b0ffef7cf945#diff-69e9a5a27a59e261e79cc7cbec71aa0f2a6c3b616438879bd145424678c44e20)

tito97sp avatar Mar 27 '24 14:03 tito97sp

Closing this due to inactivity. If someone wants to reopen it later, rebase it, and fix the needed tests, then I am open to having that merged.

spacether avatar May 13 '24 21:05 spacether