Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:52:35 +08:00
commit a469bf5db5
16 changed files with 1216 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# Assets
Bundled resources for api-response-validator skill
- [ ] validation_report_template.html: HTML template for generating validation reports.
- [ ] error_codes.json: JSON file containing error codes and descriptions.

View File

@@ -0,0 +1,32 @@
{
"skill": {
"name": "skill-name",
"version": "1.0.0",
"enabled": true,
"settings": {
"verbose": false,
"autoActivate": true,
"toolRestrictions": true
}
},
"triggers": {
"keywords": [
"example-trigger-1",
"example-trigger-2"
],
"patterns": []
},
"tools": {
"allowed": [
"Read",
"Grep",
"Bash"
],
"restricted": []
},
"metadata": {
"author": "Plugin Author",
"category": "general",
"tags": []
}
}

View File

@@ -0,0 +1,83 @@
{
"_comment": "Error codes and descriptions for the API Response Validator plugin.",
"error_codes": [
{
"code": "SCHEMA_VALIDATION_FAILED",
"description": "The API response failed validation against the provided JSON Schema.",
"details": {
"_comment": "Example details structure. 'errors' will contain schema validation errors.",
"errors": [
{
"dataPath": ".data.id",
"schemaPath": "#/properties/id/type",
"keyword": "type",
"message": "should be string"
}
]
},
"severity": "ERROR",
"resolution": "Review the API response and the JSON Schema to identify and correct any discrepancies. Ensure data types and required fields match the schema definition."
},
{
"code": "OPENAPI_VALIDATION_FAILED",
"description": "The API response failed validation against the OpenAPI specification.",
"details": {
"_comment": "Example details structure. 'errors' will contain OpenAPI validation errors.",
"errors": [
{
"message": "Response body does not conform to schema for 200 response."
}
],
"operationId": "getUserById",
"path": "/users/{userId}",
"method": "GET"
},
"severity": "ERROR",
"resolution": "Review the API response and the OpenAPI specification to identify and correct any discrepancies. Check for missing or incorrect data types, required fields, and response codes."
},
{
"code": "CONTRACT_VALIDATION_FAILED",
"description": "The API response failed validation against the custom contract rules.",
"details": {
"_comment": "Example details structure. 'failed_rules' contains information about the failed custom rules.",
"failed_rules": [
{
"rule_name": "response_time_limit",
"message": "Response time exceeded the allowed limit of 500ms. Actual time: 750ms",
"actual_value": 750,
"expected_value": 500
}
]
},
"severity": "WARNING",
"resolution": "Review the API response and the custom contract rules to identify and correct any discrepancies. Adjust the rules or the API implementation as needed."
},
{
"code": "MISSING_CONTENT_TYPE",
"description": "The API response is missing the 'Content-Type' header.",
"details": null,
"severity": "WARNING",
"resolution": "Ensure the API response includes the 'Content-Type' header to properly identify the response format."
},
{
"code": "INVALID_JSON",
"description": "The API response body is not valid JSON.",
"details": {
"_comment": "Details might include the parsing error message.",
"error_message": "Unexpected token '}' at position 10."
},
"severity": "ERROR",
"resolution": "Ensure the API response returns a valid JSON payload. Check for syntax errors and proper formatting."
},
{
"code": "UNEXPECTED_STATUS_CODE",
"description": "The API returned an unexpected HTTP status code.",
"details": {
"expected_status_code": 200,
"actual_status_code": 500
},
"severity": "WARNING",
"resolution": "Verify the expected HTTP status code against the actual status code returned by the API. Investigate the API logs for potential errors."
}
]
}

View File

@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Claude Skill Configuration",
"type": "object",
"required": ["name", "description"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z0-9-]+$",
"maxLength": 64,
"description": "Skill identifier (lowercase, hyphens only)"
},
"description": {
"type": "string",
"maxLength": 1024,
"description": "What the skill does and when to use it"
},
"allowed-tools": {
"type": "string",
"description": "Comma-separated list of allowed tools"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$",
"description": "Semantic version (x.y.z)"
}
}
}

View File

@@ -0,0 +1,27 @@
{
"testCases": [
{
"name": "Basic activation test",
"input": "trigger phrase example",
"expected": {
"activated": true,
"toolsUsed": ["Read", "Grep"],
"success": true
}
},
{
"name": "Complex workflow test",
"input": "multi-step trigger example",
"expected": {
"activated": true,
"steps": 3,
"toolsUsed": ["Read", "Write", "Bash"],
"success": true
}
}
],
"fixtures": {
"sampleInput": "example data",
"expectedOutput": "processed result"
}
}

View File

@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Validation Report</title>
<style>
/* Inline CSS for styling */
body {
font-family: sans-serif;
line-height: 1.6;
margin: 20px;
background-color: #f8f9fa; /* Light gray background */
color: #343a40; /* Dark gray text */
}
h1 {
color: #007bff; /* Primary color for headings */
border-bottom: 2px solid #007bff;
padding-bottom: 5px;
margin-bottom: 20px;
}
h2 {
color: #28a745; /* Success color for subheadings */
margin-top: 20px;
}
h3 {
color: #dc3545; /* Danger color for sub-subheadings */
margin-top: 15px;
}
.report-section {
margin-bottom: 20px;
padding: 15px;
border: 1px solid #ced4da; /* Light gray border */
border-radius: 5px;
background-color: #fff; /* White background */
}
.validation-summary {
margin-bottom: 20px;
padding: 15px;
border: 1px solid #ced4da; /* Light gray border */
border-radius: 5px;
background-color: #fff; /* White background */
}
.validation-summary p {
margin-bottom: 5px;
}
.success {
color: #28a745; /* Success color */
}
.failure {
color: #dc3545; /* Danger color */
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
border: 1px solid #dee2e6; /* Lighter gray border for table cells */
padding: 8px;
text-align: left;
}
th {
background-color: #e9ecef; /* Light gray background for table headers */
}
pre {
background-color: #f0f0f0; /* Light gray background for code blocks */
padding: 10px;
overflow-x: auto;
}
/* Responsive design */
@media (max-width: 768px) {
body {
margin: 10px;
}
table {
font-size: 0.8em;
}
}
</style>
</head>
<body>
<h1>API Validation Report</h1>
<div class="validation-summary">
<p><strong>Total Requests:</strong> {{total_requests}}</p>
<p class="success"><strong>Successful Validations:</strong> {{successful_validations}}</p>
<p class="failure"><strong>Failed Validations:</strong> {{failed_validations}}</p>
</div>
<div class="report-section">
<h2>Validation Results</h2>
{{validation_results}}
</div>
<div class="report-section">
<h2>Detailed Errors</h2>
{{detailed_errors}}
</div>
<div class="report-section">
<h2>Summary</h2>
<p>This report summarizes the API validation results. Please review the details for any failed validations.</p>
<p>Report generated at: {{report_generation_time}}</p>
</div>
</body>
</html>