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

Multiple Swagger file on same connexion app #1542

Closed
AntoineDuComptoirDesPharmacies opened this issue May 19, 2022 · 1 comment · Fixed by #1736
Closed

Multiple Swagger file on same connexion app #1542

AntoineDuComptoirDesPharmacies opened this issue May 19, 2022 · 1 comment · Fixed by #1736
Labels
enhancement PR welcome We would welcome and review a PR addressing this issue

Comments

@AntoineDuComptoirDesPharmacies

Description

We would like to use connexion with Flask to serve multiple API using distinct Swagger YAML files that all use the same base path.
Example :
file1.yaml
-> contains route /api/v1/statistics
file2.yaml
-> contains route /api/v1/products

In order to do this, we are calling the add_api method with each Swagger YAML file.

Expected behaviour

Both file are parsed and every routes are served through connexion/Flask.

Actual behaviour

An error occurs because Blueprint name conflicts as they are computed using base_path which is :
file1.yaml -> /api/v1
file2.yaml -> /api/v1

Steps to reproduce

Same as 1032

Additional info:

As a workaround, we replace the add_api call by function that mimic add_api but allow to pass additional **options to the register_blueprint methods.
Instead of :

        curr_api = connexion_app.add_api(provided_api, resolver=ApiResolver('api.provide.gen." + package_name + ".controllers'),
                          pythonic_params=True)

We do :

        api = super(type(connexion_app), connexion_app).add_api(provided_api, resolver=ApiResolver('api.provide.gen." + package_name + ".controllers'),
                          pythonic_params=True)
        connexion_app.app.register_blueprint(api.blueprint, name=provided_api)

Is there any reason to not add add_api **options parameters that could be given back to register_blueprint method ?

Output of the commands:

  • python --version => Python 3.7.5
  • pip show connexion | grep "^Version\:" => Version: 2.12.0

Thanks in advance for your help.
Yours faithfully,
Antoine

@RobbeSneyders
Copy link
Member

Hi @AntoineDuComptoirDesPharmacies

The options you mention are framework specific, while we try to keep the connexion interface framework agnostic. Other frameworks support a name parameter as well though (eg starlette), so I would not be opposed to adding the name parameter to the add_api method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PR welcome We would welcome and review a PR addressing this issue
Projects
None yet
2 participants