[英]missing header "content-type" on POST request swagger node.js
Sending a POST request with an body in Swagger , nothing arrives in request... I think the problem is because it doesn't have the header " content-type "发送带有Swagger正文的POST请求,请求中没有任何内容...我认为问题是因为它没有 header “内容类型”
Testing the same request in postman arrives normally(why has the header).在postman中测试相同的请求正常到达(为什么有标头)。
stopped sending the header when I added authorization in swaggerOptions, specifically " openapi ", " schemes " and " security "当我在 swaggerOptions 中添加授权时,停止发送 header,特别是“ openapi ”、“ scheme ”和“ security ”
swaggerOptions.json swaggerOptions.json
const swaggerOptions = {
definition: {
openapi: '3.0.0',
info: {
version: "1.0.0",
title: "Diniz API",
description: "Rest API Diniz",
servers: ['http://localhost:5000']
},
components: {
securitySchemes: {
bearerAuth: {
type: 'apiKey',
name: 'Authorization',
scheme: 'bearer',
in: 'header',
},
}
},
security: [{
bearerAuth: [],
}],
},
apis: ['routes/*.js']
}
In your /signup
annotations, replace the parameters
section with the following requestBody
section:在您的
/signup
注释中,将parameters
部分替换为以下requestBody
部分:
* ...
* summary: Create new account
*
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - name
* - email
* - ... # add the rest of the required properties
* properties:
* name:
* type: string
* ... # add the rest of the properties
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.