我想在openAPI3中为以下HTTP请求建模:
POST /users HTTP/1.1
Host: 10.65.1.70:3000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: */*
Accept-Language: de-AT,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://10.65.1.70/sites/config-sites/user-config.html
Content-Type: application/json
Authorization: Bearer ...
Origin: http://10.65.1.70
Content-Length: 42
Connection: keep-alive
DNT: 1
{"name":"openAPITest","password":"noPassHere"}
我目前有这个:
/users/:
post:
summary: adds user
parameters:
- name: name
required: true
in: header
schema:
type: string
- name: password
required: true
in: header
schema:
type: string
responses:
"201":
description: OK
"400":
description: Wrong Format
我所缺少的是一种正确传递登录信息的方法。
答案 0 :(得分:0)
这是我最后的做法:
paths:
/login:
post:
summary: login credentials
requestBody:
required: true
content:
application/json:
schema:
type: string
example:
{"name":"openAPITest","password":"noPassHere"}
请注意,openAPI会自动转义所提供json中的“”