Swagger: implemented standard 500 and 501 error responses

This commit is contained in:
f4exb 2017-11-18 11:03:42 +01:00
parent 2b65fb2d62
commit 9fe66f960c
2 changed files with 71 additions and 15 deletions

View File

@ -28,10 +28,14 @@ class WebAPIAdapterInterface
public: public:
virtual ~WebAPIAdapterInterface() {} virtual ~WebAPIAdapterInterface() {}
/**
* Handler of /sdrangel (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceSummary
* returns the Http status code (default 501: not implemented)
*/
virtual int instanceSummary( virtual int instanceSummary(
Swagger::SWGInstanceSummaryResponse& response __attribute__((unused)), Swagger::SWGInstanceSummaryResponse& response __attribute__((unused)),
Swagger::SWGErrorResponse& error __attribute__((unused))) Swagger::SWGErrorResponse& error __attribute__((unused)))
{ return 0; } { return 501; }
}; };

View File

@ -36,10 +36,12 @@ paths:
# a pointer to a definition # a pointer to a definition
$ref: "#/definitions/InstanceSummaryResponse" $ref: "#/definitions/InstanceSummaryResponse"
# responses may fall through to errors # responses may fall through to errors
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/devices: /sdrangel/devices:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -56,10 +58,12 @@ paths:
description: Success description: Success
schema: schema:
$ref: "#/definitions/InstanceDevicesResponse" $ref: "#/definitions/InstanceDevicesResponse"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/channels: /sdrangel/channels:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -76,10 +80,12 @@ paths:
description: Success description: Success
schema: schema:
$ref: "#/definitions/InstanceChannelsResponse" $ref: "#/definitions/InstanceChannelsResponse"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/logging: /sdrangel/logging:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -90,10 +96,12 @@ paths:
description: Success description: Success
schema: schema:
$ref: "#/definitions/LoggingInfo" $ref: "#/definitions/LoggingInfo"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
put: put:
description: Change logging parmeters for this instance description: Change logging parmeters for this instance
operationId: instanceLoggingPut operationId: instanceLoggingPut
@ -113,10 +121,12 @@ paths:
$ref: "#/definitions/LoggingInfo" $ref: "#/definitions/LoggingInfo"
"400": "400":
description: Invallid data description: Invallid data
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/audio: /sdrangel/audio:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -127,10 +137,12 @@ paths:
description: Success description: Success
schema: schema:
$ref: "#/definitions/AudioDevices" $ref: "#/definitions/AudioDevices"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
patch: patch:
description: Set audio devices description: Set audio devices
operationId: instanceAudioPatch operationId: instanceAudioPatch
@ -148,10 +160,12 @@ paths:
description: Success description: Success
schema: schema:
$ref: "#/definitions/AudioDevicesSelect" $ref: "#/definitions/AudioDevicesSelect"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/location: /sdrangel/location:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -162,10 +176,12 @@ paths:
description: On success return location description: On success return location
schema: schema:
$ref: "#/definitions/LocationInformation" $ref: "#/definitions/LocationInformation"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
put: put:
description: Set instance geolocation information description: Set instance geolocation information
operationId: instanceLocationPut operationId: instanceLocationPut
@ -185,10 +201,12 @@ paths:
$ref: "#/definitions/LocationInformation" $ref: "#/definitions/LocationInformation"
"400": "400":
description: Location invalid description: Location invalid
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/dvserial: /sdrangel/dvserial:
x-swagger-router-controller: instance x-swagger-router-controller: instance
patch: patch:
@ -205,10 +223,12 @@ paths:
description: On success return list of devices or empty list if unset description: On success return list of devices or empty list if unset
schema: schema:
$ref: "#/definitions/DVSeralDevices" $ref: "#/definitions/DVSeralDevices"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/preset: /sdrangel/preset:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -219,10 +239,12 @@ paths:
description: On success return preset list description: On success return preset list
schema: schema:
$ref: "#/definitions/Presets" $ref: "#/definitions/Presets"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
patch: patch:
description: Load a preset in a device set description: Load a preset in a device set
operationId: instancePresetPatch operationId: instancePresetPatch
@ -246,6 +268,12 @@ paths:
description: No preset or device set found description: No preset or device set found
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"500":
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
put: put:
description: Save device set settings on a preset description: Save device set settings on a preset
operationId: instancePresetPut operationId: instancePresetPut
@ -269,6 +297,12 @@ paths:
description: No preset or device set found description: No preset or device set found
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"500":
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
post: post:
description: Create a new preset from a device set settings description: Create a new preset from a device set settings
operationId: instancePresetPost operationId: instancePresetPost
@ -292,6 +326,12 @@ paths:
description: Device set not found description: Device set not found
"409": "409":
description: Preset already exists description: Preset already exists
"500":
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
delete: delete:
description: Deletes a preset description: Deletes a preset
operationId: instancePresetDelete operationId: instancePresetDelete
@ -313,6 +353,12 @@ paths:
description: Invalid frequency description: Invalid frequency
"404": "404":
description: Preset not found description: Preset not found
"500":
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/sdrangel/devicesets: /sdrangel/devicesets:
x-swagger-router-controller: instance x-swagger-router-controller: instance
get: get:
@ -323,10 +369,12 @@ paths:
description: On success return device set list description: On success return device set list
schema: schema:
$ref: "#/definitions/DeviceSetList" $ref: "#/definitions/DeviceSetList"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
post: post:
description: Add (append) a new device set description: Add (append) a new device set
operationId: instanceDeviceSetsPost operationId: instanceDeviceSetsPost
@ -341,10 +389,12 @@ paths:
description: On success return new device set description: On success return new device set
schema: schema:
$ref: "#/definitions/DeviceSet" $ref: "#/definitions/DeviceSet"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
delete: delete:
description: "Remove last device set" description: "Remove last device set"
operationId: instanceDeviceSetsDelete operationId: instanceDeviceSetsDelete
@ -355,10 +405,12 @@ paths:
$ref: "#/definitions/DeviceSetList" $ref: "#/definitions/DeviceSetList"
"404": "404":
description: "No more device sets opened in this instance" description: "No more device sets opened in this instance"
default: "500":
description: Error description: Error
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
"501":
description: Function not implemented
/swagger: /swagger:
x-swagger-pipe: swagger_raw x-swagger-pipe: swagger_raw
# complex objects have schema definitions # complex objects have schema definitions