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

[Bug] Can't use Parameter as an object anymore ? #53

Closed
koug44 opened this issue Jan 20, 2022 · 2 comments
Closed

[Bug] Can't use Parameter as an object anymore ? #53

koug44 opened this issue Jan 20, 2022 · 2 comments

Comments

@koug44
Copy link

koug44 commented Jan 20, 2022

Describe the bug
In my Sanic application, I declare all my parameters once as they are used accross many endpoints. With last sanic-ext, I have this error:
AttributeError: module 'sanic_ext.extensions.openapi.openapi' has no attribute 'Parameter'. Did you mean: 'parameter'?

To Reproduce
Simple code to reproduce

from sanic import Sanic
from sanic.response import text
from sanic_ext import openapi

app = Sanic("MyHelloWorldApp")
my_parameter = openapi.Parameter()


@app.get("/test1")
@openapi.parameter(my_parameter)
async def test1(request):
    return text("test1")


@app.get("/test2")
@openapi.parameter(my_parameter)
async def test2(request):
    return text("test2")

Additional context
If this is expected behaviour, please fix the doc also as this page states

@openapi.parameter(parameter=Parameter("foobar", deprecated=True))

Edit: broken change was introduced w/ 22.1.0

@sjsadowski
Copy link
Contributor

Isn't a parameter name required? I'm pretty sure it can't be anonymous.

@ahopkins
Copy link
Member

ahopkins commented Jan 24, 2022

Isn't a parameter name required? I'm pretty sure it can't be anonymous.

Yes, name is required

Traceback (most recent call last):
  File "/tmp/p.py", line 6, in <module>
    my_parameter = openapi.definitions.Parameter()
TypeError: Parameter.__init__() missing 1 required positional argument: 'name'

Simple code to reproduce

I think it is a matter of import paths:

my_parameter = openapi.definitions.Parameter("foo")

You can still use the object if you want.

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

No branches or pull requests

3 participants