GCP API网关:无法使用路径参数

编程入门 行业动态 更新时间:2024-10-28 14:23:09
本文介绍了GCP API网关:无法使用路径参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在努力将路径参数从我的网关传递到实际终结点。

以下是我的Open API YAML:

swagger: '2.0' info: description: | Blah blah version: 0.0.1 title: SSAuth contact: email: blah@gmail schemes: - https produces: - application/json paths: /v0/auth/users/echo: get: summary: check the health of api operationId: healthCheck consumes: - application/json produces: - application/json responses: 200: description: OK x-google-backend: address: path-to-my-cloud-run-service/v0/auth/users/echo security: - api_key: [] /v0/auth/users/type/{type}: post: summary: Add a new user to the user operationId: addUser consumes: - application/json produces: - application/json parameters: - name: type in: path description: provider type of the user required: true type: string responses: 400: description: Invalid input 200: description: OK x-google-backend: address: path-to-my-cloud-run-service/v0/auth/users/type/`type` security: - api_key: [] securityDefinitions: api_key: type: apiKey name: X-API-Key in: header

当我得到第一条路径时,它起作用了。但在第二个路径中,有一个路径参数,我找不到将其传递给我的Cloud Run URL的pars的方法。在日志中,我看到的是path-to-my-cloud-run-service/v0/auth/users/type/%60type%60?type=email而不是path-to-my-cloud-run-service/v0/auth/users/type/email,这会导致我的服务因类型无效而被拒绝。

我需要在YAML中进行哪些更改才能使其正常工作?

我遇到的另一个问题是,如果我在正文中放入一个json,那么GET请求得到400个错误请求,即使我指定它使用应用程序/json。

推荐答案

挖掘后找到解决方案here。

这是Path_Transaltion,以下是正在运行的YAML:

swagger: '2.0' info: description: | Blahblah version: 0.0.1 title: Title contact: email: blah@gmail schemes: - https produces: - application/json paths: /v0/auth/users/echo: get: summary: check the health of api operationId: healthCheck consumes: - application/json produces: - application/json responses: 200: description: OK x-google-backend: address: path-to-my-service path_translation: APPEND_PATH_TO_ADDRESS security: - api_key: [] /v0/auth/users/type/{type}: post: summary: Add a new user to the user operationId: addUser consumes: - application/json produces: - application/json parameters: - name: type in: path description: provider type of the user required: true type: string responses: 400: description: Invalid input 200: description: OK x-google-backend: address: path-to-my-service path_translation: APPEND_PATH_TO_ADDRESS security: - api_key: [] securityDefinitions: api_key: type: apiKey name: X-API-Key in: header

更多推荐

GCP API网关:无法使用路径参数

本文发布于:2023-10-10 11:21:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1478521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网关   路径   参数   GCP   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!