-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Run an API spec, no boilerplate needed #284
Conversation
👍 for having NOTE: I haven't reviewed the whole PR yet... |
sys.path.insert(1, path.abspath(base_path or '.')) | ||
|
||
resolver = None | ||
if stub: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a future improvement we could implement a resolver that mocks a response based on the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is definitely interesting. There are some open source tools that do that, but bringing together the possibility to have partially mocked API's, that can morph in a fully implemented one, is a new approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm looking to do is use my resolving swagger parser prance to generate test cases for an API. That's coming from realizing that swagger-tester isn't quite what I'd like it to be.
Some of that code might well be useful for generating the mocked response. One way or another it's going through the spec and generating stuff.
Just a thought. But I can't guarantee I'll be able to spend time on that.
clickclick only supports python3, so we can't use it while we still support python 2.7. |
@jmcs That is 😒. I will try to make https://github.com/zalando/python-clickclick work with Python 2.7. Shouldn't be difficult. |
Clickclick supports Python 2.7 now in hjacobs/python-clickclick#9 |
1 similar comment
@@ -5,3 +5,4 @@ requests>=2.9.1 | |||
six>=1.7 | |||
strict-rfc3339>=0.6 | |||
swagger_spec_validator>=2.0.2 | |||
clickclick>=1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can now require clickclick>=1.2
for Python 2.7 support
@rafaelcaricio we also need to add documentation for this CLI feature 😄 |
resolver_error = 501 | ||
|
||
app = App(__name__, | ||
swagger_json=hide_spec is False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not hide_spec
|
||
app = App(__name__, | ||
swagger_json=hide_spec is False, | ||
swagger_ui=hide_console_ui is False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not hide_console_ui
👍 |
@rafaelcaricio how do you run the CLI from the workdir? Can we add a |
@hjacobs Added both. |
Coverage down... 😞 |
We should configure INFO logging by default to at least see the HTTP port... |
|
||
- BASE_MODULE_PATH (optional): filesystem path where the API endpoints handlers are going to be imported from. | ||
""" | ||
logging_level = logging.ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use INFO
by default.
Or alternatively: ues WARN
by default and make it more verbose with -v
(INFO) and -vv
(DEBUG).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of changing levels by adding -v or -vv. Will do that.
Please use
|
@hjacobs I've added support for different log levels. Please check. |
is_flag=True, default=False) | ||
@click.option('--debug', '-d', help='Show debugging information.', | ||
is_flag=True, default=False) | ||
@click.option('--verbose', '-v', help='Show logging information.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicer way of doing that: http://click.pocoo.org/5/options/#counting
@hjacobs done. |
👍 |
Currently creating or developing an API with Connexion means that you need to Copy&Paste® a little boilerplate (small, but still) code.
Plus would be nice to configure some logging, more Copy&Paste®.
Then would be nice to have a command line to run the project. Let me Copy&Paste® this little CLI tool boilerplate code structure.
Alternatively, we could provide this minimal set of common practices of creating apps using Connexion bundled already within the installation of Connexion itself. To create a Microservice using Connexion, developers would only need to worry about the OpenAPI specification and the actual business logic/Python code. Then run the server using:
or
Other use case is when during the development we want to run the server with partially implemented endpoints. Just run it:
Endpoints not implemented yet will return an error message saying that the operation is not yet implemented.
Those changes will make Connexion sail smoothly and providing fast satisfactory results will definitely improve the success of Connexion.
_Important to notice_
This is not a breaking change and all other functionality continues to work the same.
Changes proposed in this pull request:
StubResolver
to provide a easy way to stub not implemented or not found operations;connexion
).I hope you will like it! ❤️