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

@match_info_schema results in swagger parameter entries for both "path" and "match_info" #74

Closed
waweber opened this issue Dec 17, 2019 · 4 comments

Comments

@waweber
Copy link

waweber commented Dec 17, 2019

If you set up a schema that validates a route's match_info, the Swagger output will have a generated parameter description for both the parameters in the path and the ones in the schema.

Example, with a route that must have a customer_id that is a valid UUID:

class CustomerIdSchema(Schema):
    customer_id = fields.UUID(required=True)

@docs(...)
@routes.get("/customers/{customer_id}")
@match_info_schema(CustomerIdSchema)
async def route(request):
    customer_id = request.match_info["customer_id"]
    ...

The resulting Swagger schema will have a parameters property that looks like this:

"parameters": [
          {
            "in": "match_info",
            "name": "customer_id",
            "required": true,
            "type": "string",
            "format": "uuid"
          },
          {
            "in": "path",
            "name": "customer_id",
            "required": true,
            "type": "string"
          }
        ],

It contains both the customer_id from the route path as well as from the schema. In the Swagger page it would ask you to enter both.

I think specifying match_info_schema should replace these parameters, right?

@waweber
Copy link
Author

waweber commented Dec 17, 2019

Follow up: doing
@request_schema(CustomerIdSchema, locations=["path"], put_into="path") results in expected behavior

Edit: When I say "expected behavior" I mean it shows up in the schema appropriately; this does not also result in the proper parsing behavior in aiohttp

@maximdanilchenko
Copy link
Owner

@waweber hi! #73 opened by @maksimvrs fixes it. But @maksimvrs doesn't answer for my question about this PR. So I think I will close it by myself soon.

@lafrech
Copy link

lafrech commented Jul 22, 2020

See marshmallow-code/apispec#517.

And please comment on marshmallow-code/apispec#587 if you have any insight.

maximdanilchenko added a commit that referenced this issue Jan 7, 2022
Bump apispec to the latest version (5.1.1) Closes #110, #105, #74
@maximdanilchenko
Copy link
Owner

Closed with #115

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