OpenAPI spec check improvements

This commit is contained in:
dgtlmoon
2025-09-15 11:36:13 +02:00
parent ef7df5d044
commit 71bd3cbb6a
2 changed files with 28 additions and 10 deletions
+8 -3
View File
@@ -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
View File
@@ -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: