这是什么意思?500 错误:架构无效:data.$ref 应匹配格式“uri-reference”

Sto*_*yvo 2 loopbackjs loopback4

使用 lb4 生成器创建模型、存储库和控制器。

向模型添加新字段时,我的 POST 将开始失败并出现以下错误: 500 Error: schema is invalid: data.$ref should match format "uri-reference"

该错误太模糊了,我对它所要求的内容的参考为零。

比较以下情况时验证失败:

$schema = http://json-schema.org/draft-07/schema

$ref = #/components/schemas/新用户

编辑:显然,如果您向控制器添加标题选项,它不知道如何处理自己

小智 5

只需从@requestBody中删除标题即可。请尝试以下操作:

@requestBody({
      content: {
        'application/json': {
          schema: getModelSchemaRef(Population, {
            //title: "Add"
            exclude: ['id']
          })
        }
      }
Run Code Online (Sandbox Code Playgroud)