在Godspeed HTTP事件中定义查询参数时触发验证失败的解决方法
Godspeed框架中查询参数的正确定义格式
在Godspeed框架里定义HTTP GET事件的查询参数时,不能直接在参数项里用type: string,必须把类型约束放在schema字段下,否则会触发"must have required property 'schema'"的验证错误。
错误配置示例
http.get./greet: fn: greet_user params: - name: name in: query required: true type: string # 此处错误,类型定义需嵌套在schema内 responses: 200: content: application/json: schema: type: string
报错日志
Event validation failed for http.get./greet [ { instancePath: '/params/0', message: "must have required property 'schema'" } ]
正确配置格式
将参数的类型定义嵌套到schema对象中,符合Godspeed的参数验证规范:
http.get./greet: fn: greet_user params: - name: name in: query required: true schema: # 用schema字段包裹类型约束 type: string responses: 200: content: application/json: schema: type: string
说明
Godspeed的事件参数定义遵循类OpenAPI的结构要求,所有与参数类型、格式相关的约束都需要放在schema对象内部,而非直接作为参数项的平级字段。按此配置后,框架会正确校验name查询参数的必填性与类型,验证即可正常通过。
内容的提问来源于stack exchange,提问作者Manish Kumar
相关产品推荐
相关产品推荐

