自己随收写的一个,备忘用的,所以可能帮助不到别人;
得用notepad或者swagger按yml打开
openapi: 3.0.0
info:
title: api
description: ‘no more description’
version: 1.0.0
servers:
- url: ‘http://localhost/’
description: sth. null server url
paths:
/triplist:
get:
summary: Post a json type request to backend and get corresponding data
responses:
‘200’:
description: OK
content:
application/json:
schema:
$ref: ‘#/components/schemas/returnTriplist’
example:
[
{
“tripid”: “Tripid_1565768780784”,
“startDate” : “1789555655342025”,
“stopDate” : “1986666638203112”,
“soundUrl”:“http://…”,
“ball” : “String”
},
…
]
‘401’:
$ref: ‘#/components/responses/Unauthorized’ # <-----
‘404’:
$ref: ‘#/components/responses/NotFound’ # <-----
/candata:
post:
summary: Post a json type request to backend and get corresponding data
requestBody:
content:
application/json:
schema:
$ref: ‘#/components/schemas/candata’
example:
{
“tripid”:“Tripid_1565768780784”,
“datatype”: “ESP_FRONT_WHEEL”,
“startdate”: “1852369855342025”,
“stopdate”: “1985314625348931”
}
responses:
‘200’:
description: OK
content:
application/json:
schema:
$ref: ‘#/components/schemas/returnCandata’
example:
{
“tripid”:“Tripid_1565768780784”,
“startdate”:“1863286355342025”,
“stopdate”:“1983472355348931”,
“datatype” : “ESP_02_WheelAngle”,
“data” :
[
{
“timestamp”: “1893532812342025”,
“value”: “123”
},
{
“timestamp”: “1987231255342080”,
“value”: “2342”
},
…
]
}
‘401’:
$ref: ‘#/components/responses/Unauthorized’ # <-----
‘404’:
$ref: ‘#/components/responses/NotFound’ # <-----
/coordinatedata:
post:
summary: Post a json type request to backend and get corresponding data
requestBody:
content:
application/json:
schema:
$ref: ‘#/components/schemas/coordinatedata’
example:
{
“tripid”:“Tripid_1565768780784”,
“startdate”: “1888289255342025”,
“stopdate”: “1999289255342025”
}
responses:
‘200’:
description: OK
content:
application/json:
schema:
$ref: ‘#/components/schemas/returnCoordinatedata’
example:
{“tripid”:“Tripid_1777768780784”,
“data”:[
{
“timestamp” : “1932189255342025”,
“path” : [lon1,lat1]
},
{
“timestamp” : “2144349255342025”,
“path” : [lon2,lat2]
},
…
]
}
‘401’:
$ref: ‘#/components/responses/Unauthorized’ # <-----
‘404’:
$ref: ‘#/components/responses/NotFound’ # <-----
components:
schemas:
returnTriplist:
type: array
items:
type: object
properties:
tripid:
type: string
startDate:
type: string
stopDate:
type: string
videoUrl:
type: string
vehicle:
type: string
candata:
type: object
properties:
tripid:
type: string
datatype:
type: string
startdate:
type: string
stopdate:
type: string
returnCandata:
type: object
properties:
tripid:
type: string
startdate:
type: string
stopdate:
type: string
datatype:
type: string
data:
items:
type: object
properties:
timestamp:
type: string
value:
type: string
enum: [
{
"timestamp":"7864689255342025",
"value":"123"
},
...
]
coordinatedata:
type: object
properties:
tripid:
type: string
startdate:
type: string
stopdate:
type: string
returnCoordinatedata:
type: object
properties:
tripid:
type: string
datatype:
type: string
data:
type: array
items:
type: object
properties:
timestamp:
type: string
description: a timestamp
path:
type: array
items:
type: string
description: longitude and latitude
properties:
lon:
type: string
description: a longitude
lat:
type: string
description: a latitude
enum: [
{
"timestamp":string,
"path":[lon,lat]
},
...
]
Error:
type: object
properties:
code:
type: string
message:
type: string
required:
- code
- message
responses:
NotFound:
description: The specified resource was not found
content:
application/json:
schema:
$ref: ‘#/components/schemas/Error’
Unauthorized:
description: Unauthorized
content:
application/json:
schema:
$ref: ‘#/components/schemas/Error’