尝试设置云端点。使用以下配置。
# openapi2-functions.yaml
swagger: '2.0'
info:
title: Redacted
description: Redacted
version: 1.0.0
schemes: [http, https]
produces:
- application/json
paths:
/service/{route}/{id_}:
get:
summary: <summary>
operationId: service
parameters:
- in: path
name: route
type: string
required: true
- in: path
name: id_
type: string
default: ""
required: false
x-google-backend:
address: http://<URL_HERE>/{route}/{id_}
path_translation: APPEND_PATH_TO_ADDRESS
deadline: 60.0
responses:
'200':
description: A successful response
schema:
type: string
我将 id_ 的 required 设置为 false。当我尝试部署此 YAML 文件时,出现以下错误:
"domain": "validation",
"keyword": "additionalProperties",
"message": "object instance has properties which are not allowed by the schema: [\"default\",\"type\"]",
"unwanted": ["default", "type"]
还:
"domain": "validation",
"keyword": "required",
"message": "object has missing required properties ([\"schema\"])",
"required": ["in", "name", "schema"],
"missing": ["schema"]
当我将其设置为 True 时,它部署得很好,但这不是我想要的行为。
当我实际上将架构添加到参数中时,我得到了另一个错误。
parameters:
- required: false
schema:
title: id_
name: id_
in: path
错误:
"domain": "validation",
"keyword": "additionalProperties",
"message": "object instance has properties which are not allowed by the schema: [\"schema\"]",
"unwanted": ["schema"]