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

Add a single-file example #9

Merged
merged 1 commit into from
Apr 16, 2019
Merged

Add a single-file example #9

merged 1 commit into from
Apr 16, 2019

Conversation

zupo
Copy link
Collaborator

@zupo zupo commented Apr 14, 2019

No description provided.

@zupo zupo force-pushed the add/singlefile-example branch 4 times, most recently from f219bf1 to 276caac Compare April 14, 2019 12:22
@@ -59,6 +59,7 @@ def wrapper_view(context, request):
)
else:
# Do the view
request.openapi_validated.raise_for_errors()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the _pyramid_openapi3_validation_view_name view is not configured, we shouldn't just silently swallow validation errors and continue, but raise the appropriate validation exception.

@@ -151,7 +152,6 @@ def spec_view(request):

config.add_route(route_name, route)
config.add_view(route_name=route_name, view=spec_view)
config.add_view(route_name=route_name, view=spec_view)
Copy link
Collaborator Author

@zupo zupo Apr 14, 2019

Choose a reason for hiding this comment

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

Probably leftover of a rebase gone wrong.

@zupo zupo force-pushed the add/singlefile-example branch from 276caac to c09b4bb Compare April 14, 2019 12:40
@zupo zupo requested a review from mcdonc April 14, 2019 12:42
if __name__ == "__main__":
"""If app.py is called directly, start up the app."""
with tempfile.NamedTemporaryFile() as document:
document.write(OPENAPI_DOCUMENT)
Copy link

Choose a reason for hiding this comment

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

Swagger client examples require the path to JSON spec https://github.com/swagger-api/swagger-js#import-in-browser. I think is better to expose JSON and yaml as routes, so that it can actually be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pyramid_openapi3 takes care of publishing the YAML file:

Screenshot 2019-04-14 at 20 08 27

I double checked, and the try-me examples seem to work:

Screenshot 2019-04-14 at 20 08 48

Or am I misunderstanding what you are trying to say?

Copy link

@dz0ny dz0ny Apr 14, 2019

Choose a reason for hiding this comment

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

I was thinking if you use API outside of the API explorer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, to convert YAML into JSON and publish both?

Copy link

@dz0ny dz0ny Apr 14, 2019

Choose a reason for hiding this comment

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

Yep, so add another handler for JSON request like for yaml
https://github.com/niteoweb/pyramid_openapi3/blob/master/pyramid_openapi3/__init__.py#L133

And then the example in https://github.com/swagger-api/swagger-js#in-browser should be valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's completely out of the scope of this PR.

#10

@zupo zupo mentioned this pull request Apr 15, 2019
Copy link
Member

@mcdonc mcdonc 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 great to me, I love it!

@zupo zupo merged commit 03f66b2 into master Apr 16, 2019
@miketheman miketheman deleted the add/singlefile-example branch March 20, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants