pyramid_swagger icon indicating copy to clipboard operation
pyramid_swagger copied to clipboard

Route validation broken in hybrid app (traversal+url dispatch)

Open deubs opened this issue 8 years ago • 3 comments

I am getting error 400. "Could not find a matching Swagger operation" for valid paths. I believe that the route is not matching because is configured with traversal.

the route.path given to spec.get_op_for_request() is: /api/*traverse (as is defined in app configuration)

If I replace route.path with request.path_info it works in some cases but fails for routes that has parameters.

ie, works with: /api/method but fails with: /api/method/1

the latest could not be validated against:

swagger: '2.0'
basePath: /api
paths:
  /method:
    get:
      description: xxx
      parameters:
        - name: id
          in: path
          description: xxxx
          required: true
          type: integer
          format: int32
      responses:
        200:
          description: OK

deubs avatar Jul 13 '16 14:07 deubs

What version of pyramid are you using? And can you give a super simple endpoint definition for your pyramid app?

I can't say I'm very familiar with traversal style configuration, but I'm happy to help add context if you're interested in getting it working w/ pyramid_swagger.

striglia avatar Jul 15 '16 17:07 striglia

I'm using pyramid 1.7. Reviewing the code, I think it is not possible to make it work that way, since there not exists the patterns to match paths in swagger definition. Anyway, here is a small app with a test case. Thanks.

deubs avatar Sep 24 '16 12:09 deubs

Definitely thanks for the reproduction. I suspect it is possible (Pyramid must be able to do path resolution or it couldn't route!) but it will likely be a little different from how the normal resolution is done.

I'll leave this open in case someone else comes across the same issue.

striglia avatar Sep 27 '16 16:09 striglia