优化header提前调用,dependent,swagger
This commit is contained in:
parent
c6021fc495
commit
8c01d03c61
|
@ -0,0 +1,614 @@
|
|||
---
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: home-iot-api
|
||||
description: The API for the EatBacon IOT project
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: https://virtserver.swaggerhub.com/A70677002/test/1.0.0
|
||||
description: SwaggerHub API Auto Mocking
|
||||
paths:
|
||||
/devices:
|
||||
get:
|
||||
tags:
|
||||
- Device
|
||||
description: returns all registered devices
|
||||
operationId: getDevices
|
||||
parameters:
|
||||
- name: skip
|
||||
in: query
|
||||
description: number of records to skip
|
||||
required: false
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
- name: limit
|
||||
in: query
|
||||
description: max number of records to return
|
||||
required: false
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: All the devices
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
format: uri
|
||||
example: http://10.0.0.225:8080
|
||||
post:
|
||||
tags:
|
||||
- Device
|
||||
operationId: register
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DeviceRegistrationInfo'
|
||||
responses:
|
||||
"200":
|
||||
description: successfully registered device
|
||||
/lighting/dimmers/{deviceId}/{value}:
|
||||
post:
|
||||
tags:
|
||||
- Z-Wave
|
||||
operationId: setDimmer
|
||||
parameters:
|
||||
- name: deviceId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: value
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
maximum: 100
|
||||
minimum: 0
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
x-swagger-router-controller: ZWave
|
||||
/lighting/dimmers/{deviceId}/{value}/timer/{timeunit}:
|
||||
post:
|
||||
tags:
|
||||
- Z-Wave
|
||||
description: sets a dimmer to a specific value on a timer
|
||||
operationId: setDimmerTimer
|
||||
parameters:
|
||||
- name: deviceId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: value
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
- name: timeunit
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
- name: units
|
||||
in: query
|
||||
required: false
|
||||
style: form
|
||||
explode: true
|
||||
schema:
|
||||
type: string
|
||||
default: milliseconds
|
||||
enum:
|
||||
- seconds
|
||||
- minutes
|
||||
- milliseconds
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
x-swagger-router-controller: ZWave
|
||||
/lighting/switches/{deviceId}:
|
||||
get:
|
||||
tags:
|
||||
- Z-Wave
|
||||
operationId: getSwitchState
|
||||
parameters:
|
||||
- name: deviceId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DeviceState'
|
||||
x-swagger-router-controller: ZWave
|
||||
/lighting/switches/{deviceId}/{value}:
|
||||
post:
|
||||
tags:
|
||||
- Z-Wave
|
||||
operationId: setSwitch
|
||||
parameters:
|
||||
- name: deviceId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: value
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- "true"
|
||||
- "false"
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
x-swagger-router-controller: ZWave
|
||||
/lighting/switches/{deviceId}/{value}/timer/{minutes}:
|
||||
post:
|
||||
tags:
|
||||
- Z-Wave
|
||||
description: sets a switch to a specific value on a timer
|
||||
operationId: setSwitchTimer
|
||||
parameters:
|
||||
- name: deviceId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: value
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- "true"
|
||||
- "false"
|
||||
- name: minutes
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
x-swagger-router-controller: ZWave
|
||||
/lightingSummary:
|
||||
get:
|
||||
tags:
|
||||
- Z-Wave
|
||||
operationId: getLightingSummary
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LightingSummary'
|
||||
x-swagger-router-controller: ZWave
|
||||
/temperature:
|
||||
get:
|
||||
tags:
|
||||
- Environment
|
||||
operationId: temperatureSummary
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TemperatureSummary'
|
||||
x-swagger-router-controller: Environment
|
||||
/temperature/forecast/{days}:
|
||||
get:
|
||||
tags:
|
||||
- Environment
|
||||
operationId: getForecast
|
||||
parameters:
|
||||
- name: days
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: the forecast
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ForecastResponse'
|
||||
x-swagger-router-controller: Environment
|
||||
/temperature/{zoneId}:
|
||||
get:
|
||||
tags:
|
||||
- Environment
|
||||
operationId: getZoneTemperature
|
||||
parameters:
|
||||
- name: zoneId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: Zone temperature
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TemperatueZoneStatus'
|
||||
x-swagger-router-controller: Environment
|
||||
/temperature/{zoneId}/heater:
|
||||
get:
|
||||
tags:
|
||||
- Environment
|
||||
description: gets the state of the heater
|
||||
operationId: getHeaterState
|
||||
parameters:
|
||||
- name: zoneId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: heater state
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/HeaterState'
|
||||
x-swagger-router-controller: Environment
|
||||
/temperature/{zoneId}/heater/{state}:
|
||||
post:
|
||||
tags:
|
||||
- Environment
|
||||
description: turns the heater on or off
|
||||
operationId: setHeaterState
|
||||
parameters:
|
||||
- name: zoneId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
- name: state
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- "false"
|
||||
- "true"
|
||||
responses:
|
||||
"200":
|
||||
description: Status of the operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
x-swagger-router-controller: Environment
|
||||
/zones:
|
||||
get:
|
||||
tags:
|
||||
- Zones
|
||||
operationId: getZones
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-swagger-router-controller: Zones
|
||||
/zones/{zoneId}/quiet:
|
||||
get:
|
||||
tags:
|
||||
- Zones
|
||||
operationId: quietZone
|
||||
parameters:
|
||||
- name: zoneId
|
||||
in: path
|
||||
required: true
|
||||
style: simple
|
||||
explode: false
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- basement
|
||||
- first-floor
|
||||
- second-floor
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
x-swagger-router-controller: Zones
|
||||
components:
|
||||
schemas:
|
||||
LightingSummary:
|
||||
type: object
|
||||
properties:
|
||||
zones:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/LightingZone'
|
||||
zoneStatus:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/LightingZoneStatus'
|
||||
description: ok
|
||||
LightingZone:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
deviceId:
|
||||
type: integer
|
||||
format: int32
|
||||
deviceType:
|
||||
type: string
|
||||
enum:
|
||||
- dimmer
|
||||
- switch
|
||||
zone:
|
||||
type: string
|
||||
LightingZoneStatus:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
lastUpdate:
|
||||
type: string
|
||||
format: date-time
|
||||
level:
|
||||
type: integer
|
||||
format: int32
|
||||
description: the status of the lighting zone.
|
||||
TemperatureSummary:
|
||||
type: object
|
||||
properties:
|
||||
zones:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TemperatureZone'
|
||||
zoneStatus:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TemperatueZoneStatus'
|
||||
description: ok
|
||||
TemperatureZone:
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
description: the unique identifier for the zone
|
||||
format: int32
|
||||
name:
|
||||
type: string
|
||||
inputPosition:
|
||||
type: integer
|
||||
format: int32
|
||||
outputPosition:
|
||||
type: integer
|
||||
format: int32
|
||||
zone:
|
||||
type: string
|
||||
description: a single temperature zone
|
||||
TemperatueZoneStatus:
|
||||
required:
|
||||
- id
|
||||
- timestamp
|
||||
- value
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: the unique identifier for the zone
|
||||
name:
|
||||
type: string
|
||||
description: the name of the zone
|
||||
value:
|
||||
type: number
|
||||
description: the temperature in the zone
|
||||
format: double
|
||||
units:
|
||||
type: string
|
||||
description: the temperature units
|
||||
default: fahrenheit
|
||||
enum:
|
||||
- celsius
|
||||
- fahrenheit
|
||||
timestamp:
|
||||
type: string
|
||||
description: the timestamp when the temperature was measured
|
||||
format: date-time
|
||||
description: status of a single zone
|
||||
ApiResponse:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
example: everything is ok
|
||||
HeaterState:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
state:
|
||||
type: string
|
||||
DeviceState:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
lastUpdate:
|
||||
type: string
|
||||
format: date-time
|
||||
level:
|
||||
type: integer
|
||||
format: int32
|
||||
ForecastResponse:
|
||||
type: object
|
||||
properties:
|
||||
city:
|
||||
$ref: '#/components/schemas/City'
|
||||
values:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Forecast'
|
||||
Forecast:
|
||||
type: object
|
||||
properties:
|
||||
date:
|
||||
type: string
|
||||
format: date-time
|
||||
pressure:
|
||||
type: number
|
||||
format: double
|
||||
humidity:
|
||||
type: integer
|
||||
format: int32
|
||||
windSpeed:
|
||||
type: number
|
||||
format: double
|
||||
clouds:
|
||||
type: integer
|
||||
format: int32
|
||||
temperature:
|
||||
$ref: '#/components/schemas/ForecastTemperature'
|
||||
weather:
|
||||
$ref: '#/components/schemas/WeatherForecast'
|
||||
City:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
lat:
|
||||
type: number
|
||||
format: double
|
||||
lon:
|
||||
type: number
|
||||
format: double
|
||||
country:
|
||||
type: string
|
||||
ForecastTemperature:
|
||||
type: object
|
||||
properties:
|
||||
low:
|
||||
type: number
|
||||
format: double
|
||||
high:
|
||||
type: number
|
||||
format: double
|
||||
morning:
|
||||
type: number
|
||||
format: double
|
||||
day:
|
||||
type: number
|
||||
format: double
|
||||
evening:
|
||||
type: number
|
||||
format: double
|
||||
night:
|
||||
type: number
|
||||
format: double
|
||||
WeatherForecast:
|
||||
type: object
|
||||
properties:
|
||||
summary:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
icon:
|
||||
type: string
|
||||
DeviceRegistrationInfo:
|
||||
type: object
|
||||
properties:
|
||||
uri:
|
||||
type: string
|
||||
format: uri
|
||||
example: http://10.0.0.220:8080
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
example: 0729a580-2240-11e6-9eb5-0002a5d5c51b
|
|
@ -0,0 +1,777 @@
|
|||
{
|
||||
"openapi" : "3.0.0",
|
||||
"servers" : [ {
|
||||
"description" : "SwaggerHub API Auto Mocking",
|
||||
"url" : "https://virtserver.swaggerhub.com/A70677002/test/1.0.0"
|
||||
} ],
|
||||
"info" : {
|
||||
"version" : "1.0.0",
|
||||
"title" : "home-iot-api",
|
||||
"description" : "The API for the EatBacon IOT project"
|
||||
},
|
||||
"paths" : {
|
||||
"/devices" : {
|
||||
"get" : {
|
||||
"tags" : [ "Device" ],
|
||||
"description" : "returns all registered devices",
|
||||
"operationId" : "getDevices",
|
||||
"parameters" : [ {
|
||||
"in" : "query",
|
||||
"name" : "skip",
|
||||
"description" : "number of records to skip",
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
}, {
|
||||
"in" : "query",
|
||||
"name" : "limit",
|
||||
"description" : "max number of records to return",
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "All the devices",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string",
|
||||
"format" : "uri",
|
||||
"example" : "http://10.0.0.225:8080"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post" : {
|
||||
"tags" : [ "Device" ],
|
||||
"operationId" : "register",
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successfully registered device"
|
||||
}
|
||||
},
|
||||
"requestBody" : {
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/DeviceRegistrationInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/lighting/dimmers/{deviceId}/{value}" : {
|
||||
"post" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"operationId" : "setDimmer",
|
||||
"parameters" : [ {
|
||||
"name" : "deviceId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}, {
|
||||
"name" : "value",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"minimum" : 0,
|
||||
"maximum" : 100
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "response",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/dimmers/{deviceId}/{value}/timer/{timeunit}" : {
|
||||
"post" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"description" : "sets a dimmer to a specific value on a timer",
|
||||
"operationId" : "setDimmerTimer",
|
||||
"parameters" : [ {
|
||||
"name" : "deviceId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}, {
|
||||
"name" : "value",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
}, {
|
||||
"name" : "timeunit",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
}, {
|
||||
"name" : "units",
|
||||
"in" : "query",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"type" : "string",
|
||||
"enum" : [ "seconds", "minutes", "milliseconds" ],
|
||||
"default" : "milliseconds"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "response",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"operationId" : "getSwitchState",
|
||||
"parameters" : [ {
|
||||
"name" : "deviceId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "response",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/DeviceState"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}/{value}" : {
|
||||
"post" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"operationId" : "setSwitch",
|
||||
"parameters" : [ {
|
||||
"name" : "deviceId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}, {
|
||||
"name" : "value",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string",
|
||||
"enum" : [ true, false ]
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "response",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}/{value}/timer/{minutes}" : {
|
||||
"post" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"description" : "sets a switch to a specific value on a timer",
|
||||
"operationId" : "setSwitchTimer",
|
||||
"parameters" : [ {
|
||||
"name" : "deviceId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}, {
|
||||
"name" : "value",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string",
|
||||
"enum" : [ true, false ]
|
||||
}
|
||||
}, {
|
||||
"name" : "minutes",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "response",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/lightingSummary" : {
|
||||
"get" : {
|
||||
"tags" : [ "Z-Wave" ],
|
||||
"operationId" : "getLightingSummary",
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "ok",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/LightingSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "ZWave"
|
||||
}
|
||||
},
|
||||
"/temperature" : {
|
||||
"get" : {
|
||||
"tags" : [ "Environment" ],
|
||||
"operationId" : "temperatureSummary",
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "ok",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/TemperatureSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/forecast/{days}" : {
|
||||
"get" : {
|
||||
"tags" : [ "Environment" ],
|
||||
"operationId" : "getForecast",
|
||||
"parameters" : [ {
|
||||
"name" : "days",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "the forecast",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ForecastResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "Environment" ],
|
||||
"operationId" : "getZoneTemperature",
|
||||
"parameters" : [ {
|
||||
"name" : "zoneId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "Zone temperature",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/TemperatueZoneStatus"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}/heater" : {
|
||||
"get" : {
|
||||
"tags" : [ "Environment" ],
|
||||
"description" : "gets the state of the heater",
|
||||
"operationId" : "getHeaterState",
|
||||
"parameters" : [ {
|
||||
"name" : "zoneId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "heater state",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/HeaterState"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}/heater/{state}" : {
|
||||
"post" : {
|
||||
"tags" : [ "Environment" ],
|
||||
"description" : "turns the heater on or off",
|
||||
"operationId" : "setHeaterState",
|
||||
"parameters" : [ {
|
||||
"name" : "zoneId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}, {
|
||||
"name" : "state",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string",
|
||||
"enum" : [ false, true ]
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "Status of the operation",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"$ref" : "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Environment"
|
||||
}
|
||||
},
|
||||
"/zones" : {
|
||||
"get" : {
|
||||
"tags" : [ "Zones" ],
|
||||
"operationId" : "getZones",
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "ok",
|
||||
"content" : {
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Zones"
|
||||
}
|
||||
},
|
||||
"/zones/{zoneId}/quiet" : {
|
||||
"get" : {
|
||||
"tags" : [ "Zones" ],
|
||||
"operationId" : "quietZone",
|
||||
"parameters" : [ {
|
||||
"name" : "zoneId",
|
||||
"in" : "path",
|
||||
"required" : true,
|
||||
"schema" : {
|
||||
"type" : "string",
|
||||
"enum" : [ "basement", "first-floor", "second-floor" ]
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "ok"
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller" : "Zones"
|
||||
}
|
||||
}
|
||||
},
|
||||
"components" : {
|
||||
"schemas" : {
|
||||
"LightingSummary" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"zones" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/LightingZone"
|
||||
}
|
||||
},
|
||||
"zoneStatus" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/LightingZoneStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description" : "ok"
|
||||
},
|
||||
"LightingZone" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"deviceId" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"deviceType" : {
|
||||
"type" : "string",
|
||||
"enum" : [ "dimmer", "switch" ]
|
||||
},
|
||||
"zone" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LightingZoneStatus" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lastUpdate" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time"
|
||||
},
|
||||
"level" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
},
|
||||
"description" : "the status of the lighting zone."
|
||||
},
|
||||
"TemperatureSummary" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"zones" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/TemperatureZone"
|
||||
}
|
||||
},
|
||||
"zoneStatus" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/TemperatueZoneStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description" : "ok"
|
||||
},
|
||||
"TemperatureZone" : {
|
||||
"type" : "object",
|
||||
"required" : [ "id", "name" ],
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"description" : "the unique identifier for the zone"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"inputPosition" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"outputPosition" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"zone" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"description" : "a single temperature zone"
|
||||
},
|
||||
"TemperatueZoneStatus" : {
|
||||
"type" : "object",
|
||||
"required" : [ "id", "timestamp", "value" ],
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"description" : "the unique identifier for the zone"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string",
|
||||
"description" : "the name of the zone"
|
||||
},
|
||||
"value" : {
|
||||
"type" : "number",
|
||||
"format" : "double",
|
||||
"description" : "the temperature in the zone"
|
||||
},
|
||||
"units" : {
|
||||
"type" : "string",
|
||||
"description" : "the temperature units",
|
||||
"enum" : [ "celsius", "fahrenheit" ],
|
||||
"default" : "fahrenheit"
|
||||
},
|
||||
"timestamp" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time",
|
||||
"description" : "the timestamp when the temperature was measured"
|
||||
}
|
||||
},
|
||||
"description" : "status of a single zone"
|
||||
},
|
||||
"ApiResponse" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"code" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"message" : {
|
||||
"type" : "string",
|
||||
"example" : "everything is ok"
|
||||
}
|
||||
}
|
||||
},
|
||||
"HeaterState" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"state" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeviceState" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lastUpdate" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time"
|
||||
},
|
||||
"level" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForecastResponse" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"city" : {
|
||||
"$ref" : "#/components/schemas/City"
|
||||
},
|
||||
"values" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/Forecast"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Forecast" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"date" : {
|
||||
"type" : "string",
|
||||
"format" : "date-time"
|
||||
},
|
||||
"pressure" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"humidity" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"windSpeed" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"clouds" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32"
|
||||
},
|
||||
"temperature" : {
|
||||
"$ref" : "#/components/schemas/ForecastTemperature"
|
||||
},
|
||||
"weather" : {
|
||||
"$ref" : "#/components/schemas/WeatherForecast"
|
||||
}
|
||||
}
|
||||
},
|
||||
"City" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lat" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"lon" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"country" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForecastTemperature" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"low" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"high" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"morning" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"day" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"evening" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
},
|
||||
"night" : {
|
||||
"type" : "number",
|
||||
"format" : "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
"WeatherForecast" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"summary" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"description" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"icon" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeviceRegistrationInfo" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"uri" : {
|
||||
"type" : "string",
|
||||
"format" : "uri",
|
||||
"example" : "http://10.0.0.220:8080"
|
||||
},
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"format" : "uuid",
|
||||
"example" : "0729a580-2240-11e6-9eb5-0002a5d5c51b"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,912 @@
|
|||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "home-iot-api",
|
||||
"description": "The API for the EatBacon IOT project",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://virtserver.swaggerhub.com/A70677002/test/1.0.0",
|
||||
"description": "SwaggerHub API Auto Mocking"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/devices": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"description": "returns all registered devices",
|
||||
"operationId": "getDevices",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "skip",
|
||||
"in": "query",
|
||||
"description": "number of records to skip",
|
||||
"required": false,
|
||||
"style": "form",
|
||||
"explode": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"description": "max number of records to return",
|
||||
"required": false,
|
||||
"style": "form",
|
||||
"explode": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "All the devices",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"example": "http://10.0.0.225:8080"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"operationId": "register",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/DeviceRegistrationInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successfully registered device"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/lighting/dimmers/{deviceId}/{value}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"operationId": "setDimmer",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"maximum": 100,
|
||||
"minimum": 0,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/dimmers/{deviceId}/{value}/timer/{timeunit}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"description": "sets a dimmer to a specific value on a timer",
|
||||
"operationId": "setDimmerTimer",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timeunit",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "units",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"style": "form",
|
||||
"explode": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "milliseconds",
|
||||
"enum": [
|
||||
"seconds",
|
||||
"minutes",
|
||||
"milliseconds"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"operationId": "getSwitchState",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/DeviceState"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}/{value}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"operationId": "setSwitch",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"true",
|
||||
"false"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/lighting/switches/{deviceId}/{value}/timer/{minutes}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"description": "sets a switch to a specific value on a timer",
|
||||
"operationId": "setSwitchTimer",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"true",
|
||||
"false"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "minutes",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/lightingSummary": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Z-Wave"
|
||||
],
|
||||
"operationId": "getLightingSummary",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LightingSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "ZWave"
|
||||
}
|
||||
},
|
||||
"/temperature": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Environment"
|
||||
],
|
||||
"operationId": "temperatureSummary",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TemperatureSummary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/forecast/{days}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Environment"
|
||||
],
|
||||
"operationId": "getForecast",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "days",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "the forecast",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ForecastResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Environment"
|
||||
],
|
||||
"operationId": "getZoneTemperature",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "zoneId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Zone temperature",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TemperatueZoneStatus"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}/heater": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Environment"
|
||||
],
|
||||
"description": "gets the state of the heater",
|
||||
"operationId": "getHeaterState",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "zoneId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "heater state",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HeaterState"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Environment"
|
||||
}
|
||||
},
|
||||
"/temperature/{zoneId}/heater/{state}": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Environment"
|
||||
],
|
||||
"description": "turns the heater on or off",
|
||||
"operationId": "setHeaterState",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "zoneId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "state",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"false",
|
||||
"true"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Status of the operation",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ApiResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Environment"
|
||||
}
|
||||
},
|
||||
"/zones": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Zones"
|
||||
],
|
||||
"operationId": "getZones",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Zones"
|
||||
}
|
||||
},
|
||||
"/zones/{zoneId}/quiet": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Zones"
|
||||
],
|
||||
"operationId": "quietZone",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "zoneId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"style": "simple",
|
||||
"explode": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"basement",
|
||||
"first-floor",
|
||||
"second-floor"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ok"
|
||||
}
|
||||
},
|
||||
"x-swagger-router-controller": "Zones"
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"LightingSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"zones": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/LightingZone"
|
||||
}
|
||||
},
|
||||
"zoneStatus": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/LightingZoneStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "ok"
|
||||
},
|
||||
"LightingZone": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"deviceType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"dimmer",
|
||||
"switch"
|
||||
]
|
||||
},
|
||||
"zone": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LightingZoneStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastUpdate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"level": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
},
|
||||
"description": "the status of the lighting zone."
|
||||
},
|
||||
"TemperatureSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"zones": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/TemperatureZone"
|
||||
}
|
||||
},
|
||||
"zoneStatus": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/TemperatueZoneStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "ok"
|
||||
},
|
||||
"TemperatureZone": {
|
||||
"required": [
|
||||
"id",
|
||||
"name"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "the unique identifier for the zone",
|
||||
"format": "int32"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"inputPosition": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"outputPosition": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"zone": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "a single temperature zone"
|
||||
},
|
||||
"TemperatueZoneStatus": {
|
||||
"required": [
|
||||
"id",
|
||||
"timestamp",
|
||||
"value"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "the unique identifier for the zone"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "the name of the zone"
|
||||
},
|
||||
"value": {
|
||||
"type": "number",
|
||||
"description": "the temperature in the zone",
|
||||
"format": "double"
|
||||
},
|
||||
"units": {
|
||||
"type": "string",
|
||||
"description": "the temperature units",
|
||||
"default": "fahrenheit",
|
||||
"enum": [
|
||||
"celsius",
|
||||
"fahrenheit"
|
||||
]
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"description": "the timestamp when the temperature was measured",
|
||||
"format": "date-time"
|
||||
}
|
||||
},
|
||||
"description": "status of a single zone"
|
||||
},
|
||||
"ApiResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"example": "everything is ok"
|
||||
}
|
||||
}
|
||||
},
|
||||
"HeaterState": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeviceState": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastUpdate": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"level": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForecastResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"$ref": "#/components/schemas/City"
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Forecast"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Forecast": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"date": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"pressure": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"humidity": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"windSpeed": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"clouds": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"temperature": {
|
||||
"$ref": "#/components/schemas/ForecastTemperature"
|
||||
},
|
||||
"weather": {
|
||||
"$ref": "#/components/schemas/WeatherForecast"
|
||||
}
|
||||
}
|
||||
},
|
||||
"City": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"lat": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"lon": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"country": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForecastTemperature": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"low": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"high": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"morning": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"day": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"evening": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"night": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
"WeatherForecast": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"summary": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeviceRegistrationInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"uri": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"example": "http://10.0.0.220:8080"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"example": "0729a580-2240-11e6-9eb5-0002a5d5c51b"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -912,14 +912,13 @@ get请求我们 requestType 写的是 params ,这样发送请求时,我们
|
|||
*******************************************************
|
||||
|
||||
以上便是整个框架的使用说明,这个框架属于个人业余时间开发,大家如果在使用中遇到什么问题,或者有相关建议,可以随时反馈给我,
|
||||
_框架内容会随着大家的反馈,持续更新!邮箱地址:1602343211@qq.com
|
||||
_框架内容会随着大家的反馈,持续更新!邮箱地址:70677002@qq.com
|
||||
|
||||
如果觉得框架有帮助到你,麻烦收藏一下哦~~谢谢。:)
|
||||
|
||||
## 版本更新记录
|
||||
* V2.0.0(2022-04-07)
|
||||
[重构] 新增多业务逻辑依赖处理,统一改成yaml文件中维护用例,无需编写代码,基于V1.0版本进行重构
|
||||
* [查看更多记录点此查看](https://gitee.com/yu_xiao_qi/pytest-auto-api2/wikis/Home)
|
||||
|
||||
## 赞赏
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
case_common:
|
||||
allureEpic: JekunAuto小程序接口
|
||||
allureFeature: 登录模块
|
||||
allureStory: 用户信息接口
|
||||
allureStory: 用户信息
|
||||
|
||||
user_info_01:
|
||||
host: ${{host()}}
|
||||
url: /v1/user-logins?fields=mobile,accessId,accessKey,userId&thirdPartySource=JEKUNAUTO
|
||||
method: POST
|
||||
detail: 登录获取user_info
|
||||
detail: 登录接口
|
||||
headers:
|
||||
# 这里cookie的值,写的是存入缓存的名称
|
||||
# 请求的数据,是 params 还是 json、或者file、data
|
||||
|
@ -57,11 +57,11 @@ user_info_02:
|
|||
headers:
|
||||
Connection: 'keep-alive'
|
||||
areaCode: '440105'
|
||||
Entity-Date: ${{{get_GMT()}}}
|
||||
Authorization: ${{{get_Authorization(v1/users/)}}}
|
||||
Entity-Date: ${get_GMT()}
|
||||
Authorization: ${get_Authorization(v1/users/)}
|
||||
content-type: 'application/json'
|
||||
User-Agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1 wechatdevtools/1.06.2208010 MicroMessenger/8.0.5 webview/'
|
||||
accessKey: ${{{get_accessKey()}}}
|
||||
accessKey: ${get_accessKey()}
|
||||
cityCode: '440100'
|
||||
Entity-Length: '0'
|
||||
Accept: '*/*'
|
||||
|
@ -96,3 +96,50 @@ user_info_02:
|
|||
status_code: 200
|
||||
|
||||
sql:
|
||||
|
||||
|
||||
user_info_order_stauts_01:
|
||||
host: ${{host()}}
|
||||
url: /v1/order/order/my-order-status-config
|
||||
method: GET
|
||||
detail: 订单角标
|
||||
headers:
|
||||
Connection: 'keep-alive'
|
||||
areaCode: '440105'
|
||||
Entity-Date: ${get_GMT()}
|
||||
Authorization: ${get_Authorization(v1/order/order/my-order-status-config)}
|
||||
content-type: 'application/json'
|
||||
User-Agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1 wechatdevtools/1.06.2208010 MicroMessenger/8.0.5 webview/'
|
||||
accessKey: ${get_accessKey()}
|
||||
cityCode: '440100'
|
||||
Entity-Length: '0'
|
||||
Accept: '*/*'
|
||||
Sec-Fetch-Site: 'cross-site'
|
||||
Sec-Fetch-Mode: 'cors'
|
||||
Sec-Fetch-Dest: 'empty'
|
||||
Cookie: '_csrf-frontend=4a51c35ee2fbcec594206a4a3d3acff5e16f505e6640d083fe573cdb67f8d099a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22lOhNgJ_F7YEqCMAZ7poRxVh_c3ALOQTp%22%3B%7D; advanced-frontend=v984ed6kd1cd0ldob9tke47kf3'
|
||||
# 这里cookie的值,写的是存入缓存的名称
|
||||
# 请求的数据,是 params 还是 json、或者file、data
|
||||
requestType: params
|
||||
# 是否执行,空或者 true 都会执行
|
||||
is_run:
|
||||
data:
|
||||
fields: "*"
|
||||
thirdPartySource: JEKUNAUTO
|
||||
id: $cache{id}
|
||||
clientSource: 0
|
||||
dependence_case: False
|
||||
# 依赖的数据
|
||||
dependence_case_data:
|
||||
- case_id: user_info_01
|
||||
dependent_data:
|
||||
- dependent_type: response
|
||||
jsonpath : $.data[userId]]
|
||||
replace_key: $.data.id
|
||||
|
||||
assert:
|
||||
# 断言接口状态码
|
||||
status_code: 200
|
||||
|
||||
sql:
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2023-02-13 15:22:18
|
||||
# @Time : 2023-02-14 17:16:25
|
||||
|
||||
|
||||
import allure
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2023-02-14 17:16:25
|
||||
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from utils.read_files_tools.get_yaml_data_analysis import GetTestCase
|
||||
|
@ -9,7 +12,7 @@ from utils.read_files_tools.regular_control import regular
|
|||
from utils.requests_tool.teardown_control import TearDownHandler
|
||||
|
||||
|
||||
case_id = ['user_info_01', 'user_info_02']
|
||||
case_id = ['user_info_01', 'user_info_02', 'user_info_order_stauts_01']
|
||||
TestData = GetTestCase.case_data(case_id)
|
||||
re_data = regular(str(TestData))
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class Context:
|
|||
clientTime = get_GMT()
|
||||
# url =url.split('?')[0]
|
||||
# url = re.search('v.*', url).group()+userId
|
||||
url = url + userId
|
||||
# url = re.findall('(/v.*?)', str)[0]
|
||||
if url == "v1/users/":
|
||||
url = url + userId
|
||||
string= 'GET' + '\\n' + url + '\\n' + '0' + '\\n' + clientTime
|
||||
# 哈希加密处理
|
||||
message = string.encode()
|
||||
|
@ -72,8 +72,7 @@ class Context:
|
|||
:return: 随机数
|
||||
"""
|
||||
_data = random.randint(int(args[0]), int(args[1]))
|
||||
moblie = CacheHandler.get_cache('login_cookie')
|
||||
return _data,moblie
|
||||
return _data
|
||||
|
||||
def get_phone(self) -> int:
|
||||
"""
|
||||
|
@ -244,7 +243,7 @@ def regular(target,regular=r'\${{(\w.*?)}}'):
|
|||
regular_int_pattern = r'\'\${{(.*?)}}\''
|
||||
target = re.sub(regular_int_pattern, str(value_data), target, 1)
|
||||
else:
|
||||
target = re.sub(r'\'\${{{(.*?)}}}\'', str(value_data), target, 1)
|
||||
target = re.sub(r'\'\${(.*?)}\'', str(value_data), target, 1)
|
||||
else:
|
||||
func_name = key.split("(")[0]
|
||||
value_name = key.split("(")[1][:-1]
|
||||
|
|
|
@ -19,7 +19,8 @@ class SwaggerForYaml:
|
|||
:return:
|
||||
"""
|
||||
try:
|
||||
with open('./file/test_OpenAPI.json', "r", encoding='utf-8') as f:
|
||||
# with open('./file/test_OpenAPI.json', "r", encoding='utf-8') as f:
|
||||
with open(r"F:\JACK\My_project\Gitee\pytest-jequnauto\Files\A70677002-test-1.0.0-swagger.json", "r", encoding='utf-8') as f:
|
||||
row_data = json.load(f)
|
||||
return row_data
|
||||
except FileNotFoundError:
|
||||
|
|
|
@ -12,7 +12,7 @@ from utils.other_tools.models import TestCase, DependentCaseData, DependentData
|
|||
from utils.other_tools.exceptions import ValueNotFoundError
|
||||
from utils.cache_process.cache_control import CacheHandler
|
||||
from utils import config
|
||||
|
||||
from utils.logging_tool.log_control import ERROR
|
||||
|
||||
class DependentCase:
|
||||
""" 处理依赖相关的业务 """
|
||||
|
@ -183,7 +183,9 @@ class DependentCase:
|
|||
else:
|
||||
re_data = regular(str(self.get_cache(_case_id)))
|
||||
re_data = ast.literal_eval(cache_regular(str(re_data)))
|
||||
# 调用依赖请求
|
||||
res = RequestControl(re_data).http_request()
|
||||
ERROR.logger.error("依赖后调用{}".format(res.response_data))
|
||||
if dependence_case_data.dependent_data is not None:
|
||||
dependent_data = dependence_case_data.dependent_data
|
||||
for i in dependent_data:
|
||||
|
@ -256,4 +258,6 @@ class DependentCase:
|
|||
_new_data = jsonpath_replace(change_data=_change_data, key_name='yaml_case')
|
||||
# 最终提取到的数据,转换成 __yaml_case.data
|
||||
_new_data += ' = ' + str(value)
|
||||
# _new_data + ' = ' + str(value)
|
||||
exec(_new_data)
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@ class RequestControl:
|
|||
|
||||
def __init__(self, yaml_case):
|
||||
# 处理headers头需要调用函数生成加密字段
|
||||
yaml_case = regular(str(yaml_case), regular=r'\${{{(.*?)}}}')
|
||||
self.yamldata = yaml_case
|
||||
yaml_case = regular(str(yaml_case), regular=r'\${(.*?)}')
|
||||
self.__yaml_case = TestCase(**eval(yaml_case))
|
||||
|
||||
def file_data_exit(
|
||||
self,
|
||||
file_data) -> None:
|
||||
|
@ -414,7 +416,7 @@ class RequestControl:
|
|||
# 处理多业务逻辑
|
||||
if dependent_switch is True:
|
||||
DependentCase(self.__yaml_case).get_dependent_data()
|
||||
|
||||
# self.init1()
|
||||
res = requests_type_mapping.get(self.__yaml_case.requestType)(
|
||||
headers=self.__yaml_case.headers,
|
||||
method=self.__yaml_case.method,
|
||||
|
@ -443,6 +445,6 @@ class RequestControl:
|
|||
request_data=self.__yaml_case.data,
|
||||
response_data=res
|
||||
).set_caches_main()
|
||||
|
||||
ERROR.logger.error("依赖前{}".format(_res_data.response_data))
|
||||
return _res_data
|
||||
|
||||
|
|
Loading…
Reference in New Issue