- Convert all JSON tests to JavaScript functions for bruToJsonV2 compatibility
- Update authentication to use 'inherit' instead of manual headers
- Fix hardcoded URLs to use {{base_url}} variables
- Standardize variable syntax from {{ _.var }} to {{var}}
- Add comprehensive API documentation to all requests
- Update environment variables with missing required fields
- Apply consistent structure: meta, http method, headers, tests, vars, settings, docs
- Enhanced validation with proper error handling and field checks
94 lines
2.3 KiB
Plaintext
94 lines
2.3 KiB
Plaintext
meta {
|
|
name: Get Libraries (Admin)
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
get {
|
|
url: {{base_url}}/api/libraries
|
|
auth: inherit
|
|
}
|
|
|
|
headers {
|
|
Content-Type: application/json
|
|
}
|
|
|
|
tests {
|
|
test_get_libraries_success(status, headers, body) {
|
|
if (status !== 200) {
|
|
throw new Error("Expected status 200, got " + status);
|
|
}
|
|
|
|
const contentType = headers["content-type"];
|
|
if (!contentType || !contentType.includes("application/json")) {
|
|
throw new Error("Expected content-type to contain application/json, got " + contentType);
|
|
}
|
|
|
|
// Verify response body is valid JSON and has expected structure
|
|
let data;
|
|
try {
|
|
data = JSON.parse(body);
|
|
} catch (e) {
|
|
throw new Error("Response body is not valid JSON");
|
|
}
|
|
|
|
if (!Array.isArray(data)) {
|
|
throw new Error("Expected response body to be an array");
|
|
}
|
|
|
|
// Validate each library in array
|
|
data.forEach((library, index) => {
|
|
if (!library || typeof library !== "object") {
|
|
throw new Error("Library at index " + index + " is not an object");
|
|
}
|
|
|
|
if (!library.id) {
|
|
throw new Error("Library at index " + index + " missing required field: id");
|
|
}
|
|
|
|
if (!library.name) {
|
|
throw new Error("Library at index " + index + " missing required field: name");
|
|
}
|
|
|
|
if (!library.type) {
|
|
throw new Error("Library at index " + index + " missing required field: type");
|
|
}
|
|
});
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
settings {
|
|
encodeUrl: true
|
|
timeout: 0
|
|
}
|
|
|
|
docs {
|
|
## Get Libraries (Admin)
|
|
|
|
Retrieves all libraries in the system (admin access required).
|
|
|
|
**Method:** GET
|
|
|
|
**Endpoint:** /api/libraries
|
|
|
|
**Authentication:** Required (Bearer token, admin permissions)
|
|
|
|
**Response:** Array of library objects
|
|
- `id` (string): Library UUID
|
|
- `name` (string): Library name
|
|
- `description` (string, optional): Library description
|
|
- `type` (string): Library type (ebooks, audiobooks, videos, other)
|
|
- `is_visible` (boolean): Library visibility to users
|
|
- `media_count` (number): Number of media items in library
|
|
- `folder_count` (number): Number of folders associated
|
|
- `created_at` (string): Creation timestamp
|
|
- `updated_at` (string): Last update timestamp
|
|
|
|
**Status Codes:**
|
|
- 200: Success
|
|
- 401: Unauthorized
|
|
- 403: Forbidden (admin access required)
|
|
- 500: Internal server error
|
|
} |