Issue 1:
First Check

I added a very descriptive title to this issue.

I used the GitHub search to find a similar issue and didn't find it.

I searched the FastAPI documentation, with the integrated search.

I already searched in Google "How to X in FastAPI" and didn't find any information.

I already read and followed all the tutorial in the docs and didn't find an answer.

I already checked if it is not related to FastAPI but to Pydantic.

I already checked if it is not related to FastAPI but to Swagger UI.

I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

I commit to help with one of those options 👆

Example Code

This route, based on Closed Issue https://github.com/tiangolo/fastapi/issues/131#issuecomment-1177187775, works, and shows how one can alias a path parameter.

@router.get("/api/users/{id}/profile/")
def user_profile(user_id: int = Path(None, alias="id")):
return {
"id": user_id,
"username": "johndoe"
}

This route, using "user-id" instead of "id" as the alias, does not work.

@router.get("/api/users1/{user-id}/profile/")
def user_profile(user_id: int = Path(None, alias="user-id")):
return {
"id": user_id,
"username": "johndoe"
}

### Description

Both `Query()` and `Path()` have an `alias` feature. `Query()` aliases can contain hyphens, but `Path()` aliases cannot. This appears to be a bug, as the [doc](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#declare-metadata) says about Path metadata

> You can declare all the same parameters as for Query.

### Operating System

Linux

### Operating System Details

Amazon Linux 2

### FastAPI Version

0.86.0

### Python Version

3.9.13

### Additional Context

Swagger UI showing working route:
<img width="801" alt="path_alias_working" src="https://user-images.githubusercontent.com/79278744/201563302-a0539e26-af29-4785-b2f5-ec970f3233f1.png">

Swagger UI showing hyphenated alias Not Found:
<img width="803" alt="page_alias_with_hyphen_issue" src="https://user-images.githubusercontent.com/79278744/201563374-dc3f2198-ca49-42eb-974b-557f3a3a9559.png">

Issue 2:
First Check

I added a very descriptive title to this issue.

I used the GitHub search to find a similar issue and didn't find it.

I searched the FastAPI documentation, with the integrated search.

I already searched in Google "How to X in FastAPI" and didn't find any information.

I already read and followed all the tutorial in the docs and didn't find an answer.

I already checked if it is not related to FastAPI but to Pydantic.

I already checked if it is not related to FastAPI but to Swagger UI.

I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

I commit to help with one of those options 👆

Example Code

from fastapi import FastAPI, Path

app = FastAPI()

@app.get("/{my-id}/list")
def list_items(
my_id: str = Path(alias="my-id")
):
return {"aa": my_id}

Description

On hitting

curl -X 'GET' \
'http://localhost:8000/sample/list' \
-H 'accept: application/json'

I get 404 error

{
"detail": "Not Found"
}

Operating System

Windows

Operating System Details

No response

FastAPI Version

0.79.0

Python Version

3.9.10

Additional Context

This behaviour is working fine with Query param alias but not with Path param alias