Error failed to add operation for get api v1 connections

I am getting the error below when I am running the Airflow with docker-compose in a Macos/Windows environment. > webserver_1 | [2021-04-23 07:30:27,971] {abstract.py:229} ERROR - > Failed to ...

I am getting the error below when I am running the Airflow with docker-compose in a Macos/Windows environment.

> webserver_1  | [2021-04-23 07:30:27,971] {abstract.py:229} ERROR -
> Failed to add operation for GET /api/v1/connections webserver_1  |
> Traceback (most recent call last): webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/apis/abstract.py",
> line 209, in add_paths webserver_1  |     self.add_operation(path,
> method) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/apis/abstract.py",
> line 173, in add_operation webserver_1  |    
> pass_context_arg_name=self.pass_context_arg_name webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/__init__.py",
> line 8, in make_operation webserver_1  |     return
> spec.operation_cls.from_spec(spec, *args, **kwargs) webserver_1  |  
> File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/openapi.py",
> line 138, in from_spec webserver_1  |     **kwargs webserver_1  |  
> File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/openapi.py",
> line 89, in __init__ webserver_1  |    
> pass_context_arg_name=pass_context_arg_name webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/abstract.py",
> line 96, in __init__ webserver_1  |     self._resolution =
> resolver.resolve(self) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/resolver.py", line
> 40, in resolve webserver_1  |     return
> Resolution(self.resolve_function_from_operation_id(operation_id),
> operation_id) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/resolver.py", line
> 66, in resolve_function_from_operation_id webserver_1  |     raise
> ResolverError(str(e), sys.exc_info()) webserver_1  |
> connexion.exceptions.ResolverError: <ResolverError: columns>

1

Apache Airflow version: 2.0.1

Environment:

  • OS (e.g. from /etc/os-release): Windows/Macos
  • Install tools: Docker

Я получаю сообщение об ошибке ниже, когда запускаю Airflow с docker-compose в среде Macos.

> webserver_1  | [2021-04-23 07:30:27,971] {abstract.py:229} ERROR -
> Failed to add operation for GET /api/v1/connections webserver_1  |
> Traceback (most recent call last): webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/apis/abstract.py",
> line 209, in add_paths webserver_1  |     self.add_operation(path,
> method) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/apis/abstract.py",
> line 173, in add_operation webserver_1  |    
> pass_context_arg_name=self.pass_context_arg_name webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/__init__.py",
> line 8, in make_operation webserver_1  |     return
> spec.operation_cls.from_spec(spec, *args, **kwargs) webserver_1  |  
> File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/openapi.py",
> line 138, in from_spec webserver_1  |     **kwargs webserver_1  |  
> File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/openapi.py",
> line 89, in __init__ webserver_1  |    
> pass_context_arg_name=pass_context_arg_name webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/operations/abstract.py",
> line 96, in __init__ webserver_1  |     self._resolution =
> resolver.resolve(self) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/resolver.py", line
> 40, in resolve webserver_1  |     return
> Resolution(self.resolve_function_from_operation_id(operation_id),
> operation_id) webserver_1  |   File
> "/usr/local/lib/python3.7/site-packages/connexion/resolver.py", line
> 66, in resolve_function_from_operation_id webserver_1  |     raise
> ResolverError(str(e), sys.exc_info()) webserver_1  |
> connexion.exceptions.ResolverError: <ResolverError: columns>

https://pastebin.com/hSpcthUS

База данных не создается из-за проблемы с SqlAlchemy.

1 ответ

См. этот запрос на включение. Вам нужно добавить SQLAlchemy==1.3.23 в ваш файл докера, чтобы это работало.


2

Santthosh
18 Май 2021 в 08:24

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Hi.

This is an extract of my Flask project folder structure:

<project_root>
|-> run.py
|-> server
|-> server/__init__.py
|-> server/swagger/api.yml
|-> server/apis/users.py

In server/server.py I have this:

def create_connexion_app():    
    app = connexion.FlaskApp(__name__, specification_dir='swagger/', resolver=RestyResolver('apis'))
    app.add_api('api.yaml', strict_validation=True)
    return app.app

In run.py I start the server:

app = server.create_connexion_app()
app.run()

In server/swagger/api.yml I have this:

basePath: /api
paths:
  /users:
    get:
      summary: Get all users

And finally in server/apis/users.py I have this:

def get():
   return "Hi!"

When starting the server, RustyResolver doens’t find my get function. Extract from the stacktrace:

ERROR:connexion.apis.abstract:Failed to add operation for GET /api/users
<snip>
connexion.exceptions.ResolverError: <ResolverError: Empty module name>

Does anyone see why I’m getting this error? Please let me know if additional info is needed.

Issue Description

Swagger Open API documentation gives the below error in .NET Core API etc.

“Failed to load API definition. Fetch error undefined /swagger/v1/swagger.json”

Failed to load API definition Fetch errorundefined swagger v1 swagger 1

It is also observed that Swagger API documentation/description works on ‘localhost’ i.e locally but when it runs in publish mode i.e hosted on IIS or Cloud Server, produces the error like “Failed to load API definition” with undefined/swagger/v1/swagger.json error.

Resolution

Before applying this fix, I would recommend you to validate the swagger implementation with the below article,

  • ASP.NET Core 3.1 or 5.0 – Add Swagger OpenAPI V3.0 specification documentation
  • ASP.NET Core 2.2- Add Swagger v2.0 API documentation

Please make sure you verify the below points steps,

Resolution 1

Swagger Document is defined with proper Title and Version details, as both are required parameters.

Resolution 2

Please make sure the API doesn’t contain any conflicting action. Conflicting action could be using the same routes. To be on the safer side, you can very much use the below flag to control that behavior,

c.ResolveConflictingActions(x => x.First());

Resolution 3

Please make sure all controller methods are attributed with proper HTTP attributes Example- HttpGET or HttpPost etc. Missing this attribute could cause the error.

If the issue still persists then please apply the below fix to resolve the issue.

Resolution 5

Please check if the hosting server allows CORS request processing. Also, its important swagger UI-related resources like CSS or stylesheets are accessible from your server.

Resolution 6

Please, note that Swagger JSON will be exposed at the following route as per default behavior.

"/swagger/{documentName}/swagger.json". 

If you are using a custom route or prefix, then the route MUST include the {documentName} parameter.

To fix the issue, please update the UseSwagger() as below,

app.UseSwagger(c =>
             {
                c.RouteTemplate = "<custom-name>/swagger/{documentName}/swagger.json";
             });

Example,

 c.RouteTemplate = "MyTestService/swagger/{documentName}/swagger.json";  

The above changes also need to be reflected in SwaggerUI middleware. Please update the UseSwaggerUI method will be as follows,

app.UseSwaggerUI(c =>
             {
                 c.SwaggerEndpoint("/<custom-name>/swagger/v1/swagger.json", "TestService");
             });

Example:

 app.UseSwaggerUI(c =>
             {
          c.SwaggerEndpoint("/MyTestService/swagger/v1/swagger.json", "TestService");
             }); 

Please note that in Swaggerendpoint() method ‘documentName’ value is cases sensitive.

In fact, documentName is case sensitive anywhere else if referenced.

This documentName is generally a Group Name associated with API version

Example: It won’t work for V1 but works for v1.

If using RoutePrefix in API then it can be defined as below,

Example only if using RoutePrefix,

c.RoutePrefix= "MyTestService/swagger"

Here MyTestService is my service name.

Please see below the complete implementation,

Failed to load API definition Fetch error undefined swagger v1 swagger json

Finally, Swagger runs successfully locally and in any hosting environment like IIS or Azure Cloud, etc.

Resolved Failed to load API definition Fetch errorundefined swagger v1 swagger

For any other issues, please use google chrome dev tools(FUN F12) or Edge Developer tools to verify the exact error causing the issue. Please verify Console and Network tab to validate the exact erros.

Other References:

Add swagger to ASP.NET Core API in simple 2-3 steps:

  • Swagger API Documentation in .NET Core 6 or 3.1
  • Add Swagger API documentation to .NET Core 2.2

Did I miss anything else in these resolution steps?

Did the above steps resolve your issue? Please sound off your comments below!

Happy Coding !!


Please bookmark this page and share it with your friends. Please Subscribe to the blog to get a notification on freshly published best practices and guidelines for software design and development.


Понравилась статья? Поделить с друзьями:
  • Error failed sending 1072 bytes
  • Error failed retrieving file core db
  • Error failed retrieving file archlinux
  • Error failed remote not allowed in locked state перевод
  • Error failed remote flashing is not allowed in lock state