mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-27 07:46:22 +00:00
OpenAPI spec check improvements
This commit is contained in:
@@ -51,12 +51,17 @@ def validate_openapi_request(operation_id):
|
||||
openapi_request = FlaskOpenAPIRequest(request)
|
||||
result = spec.unmarshal_request(openapi_request)
|
||||
if result.errors:
|
||||
abort(400, message=f"OpenAPI validation failed: {result.errors}")
|
||||
return f(*args, **kwargs)
|
||||
from flask import jsonify
|
||||
from werkzeug.exceptions import BadRequest
|
||||
error_details = []
|
||||
for error in result.errors:
|
||||
error_details.append(str(error))
|
||||
raise BadRequest(f"OpenAPI validation failed: {error_details}")
|
||||
except Exception as e:
|
||||
# If OpenAPI validation fails, log but don't break existing functionality
|
||||
# If OpenAPI spec loading fails, log but don't break existing functionality
|
||||
logger.critical(f"OpenAPI validation warning for {operation_id}: {e}")
|
||||
abort(500)
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
+20
-7
@@ -224,8 +224,6 @@ components:
|
||||
maxLength: 5000
|
||||
required: [operation, selector, optional_value]
|
||||
description: Browser automation steps
|
||||
required:
|
||||
- url
|
||||
|
||||
Watch:
|
||||
allOf:
|
||||
@@ -261,6 +259,16 @@ components:
|
||||
required:
|
||||
- url
|
||||
|
||||
UpdateWatch:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/WatchBase'
|
||||
- type: object
|
||||
properties:
|
||||
last_viewed:
|
||||
type: integer
|
||||
description: Unix timestamp in seconds of the last time the watch was viewed. Setting it to a value higher than `last_changed` in the "Update watch" endpoint marks the watch as viewed.
|
||||
minimum: 0
|
||||
|
||||
Tag:
|
||||
type: object
|
||||
properties:
|
||||
@@ -281,8 +289,13 @@ components:
|
||||
notification_muted:
|
||||
type: boolean
|
||||
description: Whether notifications are muted for this tag
|
||||
required:
|
||||
- title
|
||||
|
||||
CreateTag:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Tag'
|
||||
- type: object
|
||||
required:
|
||||
- title
|
||||
|
||||
NotificationUrls:
|
||||
type: object
|
||||
@@ -572,7 +585,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Watch'
|
||||
$ref: '#/components/schemas/UpdateWatch'
|
||||
responses:
|
||||
'200':
|
||||
description: Web page change monitor (watch) updated successfully
|
||||
@@ -815,7 +828,7 @@ paths:
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
data = {'title': 'Important Sites'}
|
||||
response = requests.post('http://localhost:5000/api/v1/tag',
|
||||
response = requests.post('http://localhost:5000/api/v1/tag',
|
||||
headers=headers, json=data)
|
||||
print(response.json())
|
||||
requestBody:
|
||||
@@ -823,7 +836,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
$ref: '#/components/schemas/CreateTag'
|
||||
example:
|
||||
title: "Important Sites"
|
||||
responses:
|
||||
|
||||
Reference in New Issue
Block a user