[大家好,我由yaml创建并使用了openAPI,我创建了一个终结点,该终结点映射了2个云函数,这些函数使用路径模板路由google sdk cli进行的呼叫没有错误。现在,我通过POST https://myendpointname-3p5hncu3ha-ew.a.run.app/v1/setdndforrefcli/12588/dnd?key=[apikey]
进行调用,因为它是通过以下打开的api映射的,并回复我“路径与任何要求URI模板都不匹配”。我不知道为什么端点中的路径模板不起作用,我添加了path_translation:APPEND_PATH_TO_ADDRESS以避免Google使用CONSTANT_ADDRESS默认值,该默认值在查询字符串中附加残酷的[云功能名称]?GETid = 12588并覆盖相同名称的查询参数。有人可以告诉我如何调试端点或openAPI中的错误(端点中的绿色复选ok图标)?
# [START swagger]
swagger: '2.0'
info:
description: "Get data "
title: "Cloud Endpoint + GCF"
version: "1.0.0"
host: myendpointname-3p5hncu3ha-ew.a.run.app
# [END swagger]
basePath: "/v1"
#consumes:
# - application/json
#produces:
# - application/json
schemes:
- https
paths:
/setdndforrefcli/{id}/dnd:
post:
summary:
operationId: setdndforrefcli
parameters:
- name: id # is the id parameter in the path
in: path # is the parameter where is in query for rest or path for restful
required: true
type: integer
format: int64
minimum: 1
security:
- api_key: []
x-google-backend:
address: https://REGION-PROJECT-ID.cloudfunctions.net/mycloudfunction
path_translation: APPEND_PATH_TO_ADDRESS
protocol: h2
responses:
'200':
description: A successful response
schema:
type: string
# [START securityDef]
securityDefinitions:
# This section configures basic authentication with an API key.
api_key:
type: "apiKey"
name: "key"
in: "query"
# [END securityDef]
我有同样的错误,但是经过一些测试,我能够成功使用路径模板(/ endpoint / {id})。我解决了这个问题,如下所示:
1 .- gcloud端点服务部署openapi-functions.yaml \--project项目
这里您将获得一个新的服务配置,将在下一步中使用。
2.-chmod + x gcloud_build_image./gcloud_build_image -s SERVICE \-c NEWSERVICECONFIGURATION -p项目
非常重要的是,在每次管理服务的新部署中更改服务配置。
3.- gcloud运行部署SERVICE \--image =“ gcr.io/PROJECT/endpoints-runtime-serverless:SERVICE-NEW_SERVICE_CONFIGURATION” \--allow-未经身份验证的\-平台管理--project = PROJECT