我的nodejs应用程序有一个open-api.yaml文件和express-openapi-validate验证器。我正在执行一个正在运行的 POST 请求,并且 api 验证器不会返回任何错误:
curl --request POST 'http://localhost:33004/my-app/settings' --data-raw '{"serials":["1234","2355"]}' -H 'Content-Type: application/json'
Run Code Online (Sandbox Code Playgroud)
在我的 open-api.yaml 中,我有:
openapi: '3.0.0'
servers:
- url: 'http://{host}/my-app'
variables:
host:
enum:
- 'localhost'
....
...
paths:
/settings:
...
post:
tags:
- 'settings'
operationId: 'postSettings'
requestBody:
content:
application/json:
schema:
type: object
properties:
serials:
type: array
items:
type: string
...
Run Code Online (Sandbox Code Playgroud)
然后我尝试对我的应用程序进行 docker 化 - 创建一个 docker 容器,并使用 pm2-runtime 在内部运行它。但是,当我在应用程序在其中运行时向 docker 容器发送相同的请求时,我得到error while validating request: request should have required property '.headers'. 我在 open-api.yaml 文件中没有提到属性“.headers”。 …