Attach `x-pyramid-route-name` to request type rather than path

Open
#326 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
openapi, python
Domain
api

Research direction

Start by tracing the x-pyramid-route-name handling from openapi.yaml into the request method configuration and compare it with the @view_config() examples in handler.py. Review server.py and its add_routes usage to understand the current workaround. Done means each request method can specify its own route name without requiring separate add_routes calls.

Written by the indexing model from the issue text.

Description

I have a simple code example like this:

# openapi.yaml

/path/site/user:
    get:
        operationId: getUser
        ....
    post:
        operationId: addUser
        ....
    put:
        operationId: editUser
        ....

These each link to an @view_config() decorator akin to:

# handler.py
@view_config(
    route_name='getUser',
    request_method='GET',
    ...
)
def get_user():

and so on for the other two handler functions

This structure means I cannot use x-pyramid-route-name as this variable is at the same level as the request types

Solution:
If x-pyramid-route-name can be moved within the request type field, I could have something like:

# openapi.yaml

/path/site/user:
    get:
        x-pyramid-route-name: getUser
        operationId: getUser
        ....
    post:
        x-pyramid-route-name: addUser
        operationId: addUser
        ....
    put:
        x-pyramid-route-name: editUser
        operationId: editUser
        ....

Is there currently a way to do what I am trying to do (without having to add potentially hundreds of add_routes in my server.py)?
If not, please consider this change

Dominant language
Python
Stars
84
Forks
46
Avg merge
5d 20h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Pylons/pyramid_openapi3

All issues in Pylons/pyramid_openapi3

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.