## 事象 [[OpenAPI Specification]]の[[YAML]]ファイル内に以下のようなパラメータがあるとき。 ```yaml components: parameters: hoge: name: hoga required: true in: path schema: type: string example: "hogeeeeeeeeeee" ``` 以下の`hoge`が取得できない。 ```go func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { hoge := request.PathParameters["hoge"] // 中略... } ``` ## 原因 ### その1 `request.PathParameters`で指定するキーは`parameters`のキーではなく、その配下の`name`だから。 ```yaml components: parameters: hoge: # <--- コレジャナイ name: hoga # <--- コッチ ``` ### その2 他にも、**nameの値が==[[ケバブケース]]だと認識しない==** といったものがある。 ## 対策 ### その1 `name`をキーに指定する。 ```go func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { hoga := request.PathParameters["hoga"] // 中略... } ``` ### その2 `name`の値を[[ケバブケース]]ではなく[[キャメルケース]]にする。 --- **💽Change log** - #2021/12/21 作成