Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Add python AWS Signature v4 support #64

Closed
jblakeney wants to merge 11 commits into openapi-json-schema-tools:2_0_0 from jblakeney:python_awsv4_support
Closed

Add python AWS Signature v4 support #64

jblakeney wants to merge 11 commits into openapi-json-schema-tools:2_0_0 from jblakeney:python_awsv4_support

Conversation

@jblakeney
Copy link

@jblakeney jblakeney commented Oct 27, 2022
edited
Loading

Work to implement feature in issue #56

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:
    ./mvnw 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.

spacether and others added 8 commits October 26, 2022 18:13
* Restructures endpoint data, modules written for responses
* Endpoint docs improved, not done yet
* Updates header_params
* Updates path_parameters
* Updates cookie_params, updates x_params to say key + input type
* Samples updated
* Fixes DefaultCodegenTests
* Java and template updates for separate request body module
* Samples updated
* Samples regenerated
* Adds parameter template and code to write it
* Writes module for each parameter
* Removes prependFormOrBodyParameters
* Sample regenrated
* Samples regenerated
* Fixes readme example
* simplifies setting items and additional_properties var names
* Regenerates sample with fixed schema names
* Samples regenerated
* Fixes java docstirng typo
* Fixes JavaModelTest tests
* Fixes tests in JavaModelEnumTest
* FIxes tests in JavaClientCodegenTest
* FIxes tests in DefaultGeneratorTest
* FIxes tests in DefaultCodegenTest
* Adds HeaderParameterWithoutName to api_client
* Sample regenerated, responses are now modules
* Moves request body schemas to the root indentation level of the response modules
* Adds code to generate response header modules
* Updates fromParameter
* Sample updated, fixed bug where form param was not seen as body
* Samples regenerated
* Fixes java tests
* python client modelPackage updated
* Fixes links in model_doc template
* Samples updated and python client path methods updated
* Models sucessfully moved into components/schema in one sample
* Replaces model import with components.schema
* Fixes readme imports
* Fixes model doc links from endpoint docs
* Samples regenerated
* Fixes manual test model imports
* Samples regenerated, added init for test components
* Removes model models folders
* Removes lingering AbstractStep files, fixes its test
* Removes lingering bad model test
move aws_sigv4 and http_signing modules into a signing submodule
add sample with aws sigv4 signing
Add pydocs for AWSSignatureV4Configuration module
Add manual tests for aws sigv4
@jblakeney jblakeney marked this pull request as ready for review October 27, 2022 19:26
Copy link
Contributor

spacether commented Oct 28, 2022
edited
Loading

Why are CI tests not running on this PR?
Update: CI was not set up to run on forked PRs. I fixed it.

Copy link
Contributor

Closing and re opening to kick off ci

@@ -0,0 +1,7 @@
generatorName: python
outputDir: samples/openapi3/client/petstore/python_aws_sigv4
Copy link
Contributor

@spacether spacether Oct 28, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about renaming the spec file something like signing_spec.yaml?
How about outputting the sample into the features directory?
How about changing the package name to something like signing_spec_api?
With these changes I can reuse your sample spec to test the other signing module.
This sample is not related to petstore.

jblakeney reacted with thumbs up emoji
supportingFiles.add(new SupportingFile("signing_http_signing." + templateExtension, packagePath() + File.separatorChar + "signing", "http_signing.py"));
}
if (ProcessUtils.hasAwsSignatureV4Methods(authMethods)) {
supportingFiles.add(new SupportingFile("signging_aws_sigv4." + templateExtension, packagePath() + File.separatorChar + "signing", "aws_sigv4.py"));
Copy link
Contributor

@spacether spacether Oct 28, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about also adding an init file to the signing folder?
I think that that is needed to get accurate coverage reports.

Copy link
Author

@jblakeney jblakeney Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added the template, but forget to add it as a supporting file! Good catch!


{{#if hasAwsSignatureV4Methods}}
if self.aws_sigv4_info:
headers.extend(self.aws_sigv4_info.get_aws_signature_v4_headers(method, url, body))
Copy link
Contributor

@spacether spacether Oct 28, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be route specific.
How about moving this code into api_client update_params_for_auth
And moving the invocation of that call after the used_headers.update?
https://github.com/openapi-json-schema-tools/openapi-json-schema-generator/blob/master/modules/openapi-json-schema-generator/src/main/resources/python/api_client.handlebars#L1063

Copy link
Author

@jblakeney jblakeney Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry was taking a break all weekend so just getting back to this!

I like the idea of it being per route, however there is a comment above where used_headers.update is calling saying it should be called after any auth settings. Does that not apply anymore?

Copy link
Contributor

@spacether spacether Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Also I am on vacation so forgive some delayed responses from me here. It kind of doesn't apply. I wrote it. The default headers must come first. Update has to happen after, and those are spec defined headers. For your signing and the other security scheme they must come last because they depend upon the payload in general, right?
For the other security schemes, the Autherization header is disallowed as an explicit header input. So it is probably fine to update all security info last.

@spacether spacether force-pushed the 2_0_0 branch 2 times, most recently from b63d721 to d50d4a3 Compare November 6, 2022 09:51
Copy link
Contributor

@jblakeney friendly ping. Do you still want this? I haven't seen any updates in a week.

Copy link
Author

@jblakeney friendly ping. Do you still want this? I haven't seen any updates in a week.

Hey, yes sorry I do plan to finish this. Its been a crazy work week. Ill aim to get the suggestions fixed up this week! Sorry for the delay!

Copy link
Contributor

No worries. I was just curious. Rebases on the 2_0_0 branch can be painful. If it is too much of a hassle, I find the easiest way to do it is to:

  • squash the feature commits in your branch into 1 commit, copy it into a new branch
  • locally delete your original branch
  • make a new version of your original branch from the latest 2_0_0
  • get cherry-pick your commit
  • rebuild and regen samples
  • force push your branch

Copy link
Author

No worries. I was just curious. Rebases on the 2_0_0 branch can be painful. If it is too much of a hassle, I find the easiest way to do it is to:

  • squash the feature commits in your branch into 1 commit, copy it into a new branch
  • locally delete your original branch
  • make a new version of your original branch from the latest 2_0_0
  • get cherry-pick your commit
  • rebuild and regen samples
  • force push your branch

Awesome ill give that a try, im usually pretty good at doing merge conflicts but we shall see! Ill give that an attempt tomorrow and ill let you know if I run into any issues.

@spacether spacether force-pushed the 2_0_0 branch 4 times, most recently from 4cb663e to f5903a8 Compare November 11, 2022 18:57
@spacether spacether force-pushed the 2_0_0 branch 2 times, most recently from 9c07ef5 to 529de3b Compare November 15, 2022 01:31
Copy link
Author

Sorry for the delay, just wanted to update you here. I got the conflcits resolved on a new branch, gonna make my changes and then ill get it merged into this branch and push it. Aiming to hopefully have that done by this weekend.

Copy link
Author

Sorry again, im gonna close with for now. We do still need this but due to work deadlines before Christmas I havent had a chance to dedicate time to fix this up and properly test it. Ill re-open a PR once im ready to go. Sorry again!

spacether reacted with thumbs up emoji

Copy link
Contributor

No worries. When you have time you can add it later

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer

@spacether spacether spacether left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /