Code Monkey home page Code Monkey logo

Comments (10)

SrSoto avatar SrSoto commented on May 30, 2024 1

Happenning the same here but using Swagger UI, so the problem may not be specific to test_client but to general API routing.

What's more, maybe issue #1823 may help by fixing starlette version

from connexion.

cybertiger avatar cybertiger commented on May 30, 2024 1

This is because Connexion lazily initializes the routing when the first ASGI call is received.

Workaround:

            # Workaround for race condition in connexion initialization
            # pylint: disable=protected-access
            connexion_app.middleware.app, connexion_app.middleware.middleware_stack = \
                connexion_app.middleware._build_middleware_stack()

Excuse the comment, (it also causes a race condition in startup if you're using werkzeug with threads, and a wsgi-asgi converter).

Correct solution is probably to convert your unit tests to use the provided startlette TestClient, but that involves some work as the API is significantly different. connexion_app.test_client()

from connexion.

RobbeSneyders avatar RobbeSneyders commented on May 30, 2024 1

The issue is being discussed on the starlette repo here.

from connexion.

RobbeSneyders avatar RobbeSneyders commented on May 30, 2024 1

3.0.4 has been released containing this fix.

from connexion.

RobbeSneyders avatar RobbeSneyders commented on May 30, 2024 1

Are you still using the Flask test client? Because that is not expected to work anymore. You should use the Connexion test client.

from connexion.

neumann-nico avatar neumann-nico commented on May 30, 2024

Happenning the same here but using Swagger UI, so the problem may not be specific to test_client but to general API routing.

What's more, maybe issue #1823 may help by fixing starlette version

Thanks for your reply!
I tried multiple versions of starlette 0.27, 0.32.0.post1 and 0.33 but it did not help.

from connexion.

RobbeSneyders avatar RobbeSneyders commented on May 30, 2024

Thanks for the reports everyone. I just submitted #1828 to set an upperbound to our Starlette dependency. We'll release it as soon as possible and will investigate the underlying issue afterwards.

from connexion.

RobbeSneyders avatar RobbeSneyders commented on May 30, 2024

Closing in favor of #1824

from connexion.

neumann-nico avatar neumann-nico commented on May 30, 2024

@RobbeSneyders Thanks for the quick update!
Unfortunately it also does not work with connexion 3.0.4 and starlette < 0.33.
In #1824 there is a different error which seems to be fixed with the pinned starlette version.

Same error as in the first post:
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

from connexion.

neumann-nico avatar neumann-nico commented on May 30, 2024

Are you still using the Flask test client? Because that is not expected to work anymore. You should use the Connexion test client.

Yes I tried the Flask test client. Alright thanks, I just switched to the connexion test client and got it working with POST/PUT request. For anyone interested:

Before (Flask test client):

response = app.put(
    "/myroute",
    content_type="application/json",
    data=json.dumps(body),
    query_string={"param": param},
)

After (Connexion test client):

response = app.put(
    "/myroute",
    headers={"Content-Type": "application/json"},
    data=json.dumps(body),
    params={"param": param},
)

There are also some changes needed with checking the response, but I will figure it out :)

from connexion.

Related Issues (20)

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.

  • 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.

  • 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.

  • D3 photo D3

    Data-Driven Documents codes.