Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Add python experimental openapiv3 sample and fix PEP8 formatting issues #4992

Merged

Conversation

sebastien-rosset
Copy link
Contributor

@sebastien-rosset sebastien-rosset commented Jan 13, 2020

  1. Add openapiv3 samples for Python experimental.
  2. Fix PEP8 python formatting issues (line too long) which was observed when generating python-experimental against the openapiv3 test spec.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@sebastien-rosset
Copy link
Contributor Author

@sebastien-rosset
Copy link
Contributor Author

@sebastien-rosset this looks good, thanks for creating it!
Can you add

What is the reason for the first line of the Makefile to be?

#!/bin/bash

@spacether
Copy link
Contributor

spacether commented Jan 13, 2020

What is the reason for the first line of the Makefile to be?

#!/bin/bash

It tells which shell interpreter to invoke per http://www.linuxandubuntu.com/home/comments-in-bash-learn-bash-part-3

@sebastien-rosset
Copy link
Contributor Author

@sebastien-rosset
Copy link
Contributor Author

What is the reason for the first line of the Makefile to be?

#!/bin/bash

It tells which shell interpreter to invoke per http://www.linuxandubuntu.com/home/comments-in-bash-learn-bash-part-3

But it's not a bash script, it's a makefile. In fact the shebang is ignored because there is an extra space.
https://stackoverflow.com/questions/7123241/makefile-as-an-executable-script-with-shebang

@spacether
Copy link
Contributor

spacether commented Jan 13, 2020

But it's not a bash script, it's a makefile. In fact the shebang is ignored because there is an extra space.

Good point. If you delete it does it still work?

@sebastien-rosset
Copy link
Contributor Author

But it's not a bash script, it's a makefile. In fact the shebang is ignored because there is an extra space.

Good point. If you delete it does it still work?

I will remove it and check.

@sebastien-rosset
Copy link
Contributor Author

It looks like a couple other files are missing, I am adding them:

bash ./test_python2_and_3.sh
bash: ./test_python2_and_3.sh: No such file or directory

@sebastien-rosset
Copy link
Contributor Author

Getting formatting issues:

petstore_api/api/fake_api.py:622:100: E501 line too long (115 > 99 characters)
            kwargs['file_schema_test_class_file_schema_test_class'] = file_schema_test_class_file_schema_test_class
                                                                                                   ^
petstore_api/api/fake_api.py:654:100: E501 line too long (115 > 99 characters)
                    'file_schema_test_class_file_schema_test_class': (file_schema_test_class.FileSchemaTestClass,),
                                                                                                   ^
petstore_api/models/enum_test.py:46:100: E501 line too long (106 > 99 characters)
    outer_enum_integer_default_value = sys.modules['petstore_api.models.outer_enum_integer_default_value']
                                                                                                   ^
Makefile:19: recipe for target 'test-all' failed

I will update the python template to fix.

@sebastien-rosset
Copy link
Contributor Author

I also had to add # noqa: E501 in a couple lines in the python api.template because the generated line is too long in openapi3.

@sebastien-rosset
Copy link
Contributor Author

As a side note, what is the plan to move python-experimental and go-experimental from "experimental" status? Is this going to replace the "python" and "go" generators? Or will there be two separate generators?

@spacether
Copy link
Contributor

spacether commented Jan 15, 2020

As a side note, what is the plan to move python-experimental and go-experimental from "experimental" status? Is this going to replace the "python" and "go" generators? Or will there be two separate generators?

That is a great question. I don't know. My suggestion is to ask on Slack because the maintainers are the most responsive there. If any actions come out of it, then maybe making a feature request to capture it would be a traceable way to track it.

My hope is that in the future this can replace the python generator or we can port a bunch of these features into it. We are allowed to make breaking changes on these experimental generators which means we can make progress quickly and aggressively refactor but I don't know what our plan is going forward.

Copy link
Contributor

@spacether spacether left a comment

Choose a reason for hiding this comment

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

This looks good, the CircleCi failure is an unrelated Maven issue

@sebastien-rosset
Copy link
Contributor Author

sebastien-rosset commented Jan 16, 2020

This looks good, the CircleCi failure is an unrelated Maven issue

thanks. I saw the Maven issue you have raised.

@sebastien-rosset
Copy link
Contributor Author

sebastien-rosset commented Jan 16, 2020

Are all maven issues resolved?

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve org.codehaus.groovy:groovy-all:2.5.7.
  Required by:
      org.openapitools:groovy:1.0.0
   > Could not GET 'http://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/2.5.7/groovy-all-2.5.7.pom'. Received status code 501 from server: HTTPS Required
> Could not resolve io.github.http-builder-ng:http-builder-ng-core:1.0.3.
  Required by:
      org.openapitools:groovy:1.0.0
   > Could not GET 'http://repo1.maven.org/maven2/io/github/http-builder-ng/http-builder-ng-core/1.0.3/http-builder-ng-core-1.0.3.pom'. Received status code 501 from server: HTTPS Required

I see the following error in this build, but I have synced from master. There are still many instances of "http://maven" in master.

grep -r "http://" . |grep maven

@spacether
Copy link
Contributor

My PR was an attempt at a maven fix. But I don't know Maven so they may still be unresolved.

@spacether
Copy link
Contributor

If you close and reopen the pr it will kick off ci again. No need for dummy commits

@sebastien-rosset
Copy link
Contributor Author

If you close and reopen the pr it will kick off ci again. No need for dummy commits

thanks. One thing I don't understand is I committed a change this morning, after syncing from master (which has the maven fix). But it still failed with "http" connection to maven.

Add python-experimental-openapiv3-sample

Add missing files for the Python samples

Add python-experimental-petstore.bat for openapi v3

Add python-experimental samples openapi v3

Add python-experimental samples openapi v3

Add python-experimental samples openapi v3. Address review comments

add missing files for test purpose

fix python formatting issues

fix python formatting issues

fix python formatting issues

Fix unit tests

fix python formatting issues

fix python formatting issues

fix python formatting issues

fix 'line too long' pep8 error

address PR comments for pep8 'line too long' problem

regenerate samples

execute samples scripts

dummy commit to retrigger circleci

Revert dummy commit, it didn't help.
@sebastien-rosset sebastien-rosset force-pushed the python-experimental-openapiv3-sample branch from 0d399dc to b381972 Compare January 17, 2020 00:51
@sebastien-rosset sebastien-rosset changed the title [Python] Add python experimental openapiv3 sample [Python] Add python experimental openapiv3 sample and fix PEP8 formatting issues Jan 17, 2020
@spacether
Copy link
Contributor

I am looking forward to approving this, just waiting on the CI tests to pass.

@sebastien-rosset
Copy link
Contributor Author

I am looking forward to approving this, just waiting on the CI tests to pass.

Build is successful now. There were unrelated issues with circleCI, Jim and I fixed the issues.

Copy link
Contributor

@spacether spacether left a comment

Choose a reason for hiding this comment

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

This looks good

@sebastien-rosset
Copy link
Contributor Author

Thank you!

@wing328 wing328 added this to the 4.2.3 milestone Jan 31, 2020
@sebastien-rosset sebastien-rosset deleted the python-experimental-openapiv3-sample branch May 23, 2020 19:23
@sebastien-rosset sebastien-rosset restored the python-experimental-openapiv3-sample branch May 23, 2020 19:23
@sebastien-rosset sebastien-rosset deleted the python-experimental-openapiv3-sample branch May 23, 2020 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants