refactor: standardize Bruno API requests with bruToJsonV2 format

- 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
This commit is contained in:
2026-01-28 20:13:56 -05:00
parent 935b867219
commit 8db5939892
27 changed files with 1269 additions and 182 deletions
+91 -13
View File
@@ -1,22 +1,100 @@
meta {
name: Get Library Folders,
type: http,
name: Get Library Folders
type: http
seq: 1
}
get {
url: "/api/libraries/{{ _.libraryId }}/folders"
headers: {
Authorization: "Bearer {{ _.token }}",
Content-Type: "application/json"
url: {{base_url}}/api/libraries/{{libraryId}}/folders
auth: inherit
}
headers {
Content-Type: application/json
}
tests {
test_get_library_folders_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 folder in array
data.forEach((folder, index) => {
if (!folder || typeof folder !== "object") {
throw new Error("Folder at index " + index + " is not an object");
}
if (!folder.id) {
throw new Error("Folder at index " + index + " missing required field: id");
}
if (!folder.folder_path) {
throw new Error("Folder at index " + index + " missing required field: folder_path");
}
if (!folder.library_id) {
throw new Error("Folder at index " + index + " missing required field: library_id");
}
});
return true;
}
}
tests: {
test_get_folders_success: {
status: 200,
headers: {
"content-type": "application/json"
}
}
vars:pre-request {
libraryId: "8821b703-h29b-71d4-d716-446655440003"
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Get Library Folders
Retrieves all folders associated with a specific library.
**Method:** GET
**Endpoint:** /api/libraries/{id}/folders
**Authentication:** Required (Bearer token)
**Path Parameters:**
- `id` (string, required): Library UUID
**Response:** Array of folder objects
- `id` (string): Folder UUID
- `library_id` (string): Library UUID
- `folder_path` (string): Absolute path to the folder
- `is_active` (boolean): Whether the folder is currently active for scanning
- `last_scanned` (string, optional): Timestamp of last scan
- `created_at` (string): Creation timestamp
- `updated_at` (string): Last update timestamp
**Status Codes:**
- 200: Success
- 401: Unauthorized
- 403: Forbidden (library access denied)
- 404: Library not found
- 500: Internal server error
}