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

Feature/support swagger #206

Merged
merged 13 commits into from
Oct 26, 2021

Conversation

ran-ka
Copy link
Contributor

@ran-ka ran-ka commented Oct 23, 2021

Description

Fix support for Swagger UI

Goal

Use Swagger and interact with Faust APIs

Bugs

There were two issues that prevented the existing code from working with Swagger

  1. Handler wrapping (_wrap_into_asyncdef)
  2. Use of * when adding routes

Solution

  1. Pass docs to the wrapper handler
  2. Detect which actual methods are in use, and only create routes for them

Demo

I added the swagger docs to the existing internal Faust endpoint

image

Testing

Tested with library: aiohttp_swagger

from aiohttp_swagger import *
class App(faust.App):
    def on_webserver_init(self, web):
        setup_swagger(
            web.web_app,
            title="Faust test app",
            description = "A simple faust app for internal testing",
            swagger_url="/docs",
            api_version="1.0.3",
            ui_version=2,
        )       

Issues

HEAD endpoint: appears in Swagger, I can remove it, but didn't want to break the existing code
aiohttp-swagger3: Has a different interface, so for now I decided not to support it, but if this is of interest to someone, happy to have a chat

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2021

Codecov Report

Merging #206 (a00fc48) into master (7600f45) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #206   +/-   ##
=======================================
  Coverage   94.46%   94.47%           
=======================================
  Files         100      100           
  Lines       10643    10652    +9     
  Branches     1199     1202    +3     
=======================================
+ Hits        10054    10063    +9     
  Misses        524      524           
  Partials       65       65           
Impacted Files Coverage Δ
faust/web/drivers/aiohttp.py 96.96% <100.00%> (+0.04%) ⬆️
faust/web/views.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7600f45...a00fc48. Read the comment docs.

@patkivikram patkivikram merged commit 5ad8222 into faust-streaming:master Oct 26, 2021
@patkivikram
Copy link
Collaborator

@ran-ka this should work with any endpoint extending View correct?

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