AutoBE
    Preparing search index...

    Prerequisite API operation dependency.

    IPrerequisite defines a dependency relationship between API operations, specifying that certain endpoints must be successfully called before the current operation can proceed. This ensures proper resource validation, state checking, and data availability in complex API workflows.

    NEVER use prerequisites for authentication or authorization checks!

    Prerequisites are ONLY for business logic dependencies such as:

    • Checking if a resource exists
    • Verifying resource state
    • Loading required data

    Do NOT create prerequisites for:

    • Login/authentication endpoints
    • Token validation
    • Permission checks
    • User authorization verification

    Authentication is handled separately via the authorizationActor field on the operation itself. Mixing authentication with business prerequisites creates confusion and incorrect test scenarios.

    Prerequisites create an execution dependency graph for API operations. They explicitly declare which APIs must succeed before attempting the current operation, preventing invalid states and ensuring data consistency.

    Each prerequisite consists of:

    1. endpoint: The API endpoint that must be called first
    2. description: Clear explanation of why this prerequisite is required
    {
    "endpoint": { "path": "/users/{userId}", "method": "get" },
    "description": "User must exist before updating their profile"
    }
    {
    "endpoint": { "path": "/posts/{postId}", "method": "get" },
    "description": "Post must exist before adding comments"
    }
    {
    "endpoint": { "path": "/orders/{orderId}/status", "method": "get" },
    "description": "Order must be in 'confirmed' state before shipping"
    }
    {
    "endpoint": {
    "path": "/inventory/{productId}/stock",
    "method": "get"
    },
    "description": "Product must have sufficient stock before creating order"
    }
    1. Clear Descriptions: Always explain WHY the prerequisite is needed
    2. Minimal Dependencies: Only include truly necessary prerequisites
    3. Logical Order: If multiple prerequisites exist, order them logically
    4. Error Context: Description should help understand failure scenarios
    5. No Authentication: Prerequisites must NEVER be authentication checks

    The Test Agent utilizes prerequisites to:

    • Set up test data in the correct sequence
    • Generate realistic test scenarios
    • Create both positive and negative test cases
    • Ensure proper cleanup in reverse dependency order
    • Keep prerequisite chains as short as possible for performance
    • Consider caching prerequisite results when safe to do so
    • Ensure prerequisite descriptions are specific, not generic
    • Validate that circular dependencies don't exist
    • Document any side effects of prerequisite calls
    • NEVER use for authentication/authorization validation
    // For an operation to add item to cart
    const addToCartOperation = {
    path: "/carts/{cartId}/items",
    method: "post",
    prerequisites: [
    {
    endpoint: { path: "/carts/{cartId}", method: "get" },
    description:
    "Shopping cart must exist and belong to current user",
    },
    {
    endpoint: { path: "/products/{productId}", method: "get" },
    description: "Product must exist and be available for purchase",
    },
    ],
    };
    interface IPrerequisite {
        description: string;
        endpoint: IEndpoint;
    }
    Index

    Properties

    description: string

    Clear description of why this prerequisite is required.

    This description should explain:

    • What validation or check this prerequisite performs
    • What state or condition must be satisfied
    • What happens if this prerequisite fails
    • Any specific data from the prerequisite used by the main operation

    The description helps developers understand the dependency relationship and aids in debugging when prerequisites fail.

    Guidelines for good descriptions:

    • Be specific about the requirement (e.g., "must be in 'active' state")
    • Explain business logic constraints (e.g., "budget must not be exceeded")
    • Explain data dependencies (e.g., "provides pricing information needed")
    • Keep it concise but complete

    MUST be written in English. Never use other languages.

    "Order must exist, belong to the current user, and be in 'pending' status";
    
    "Product inventory must be checked to ensure sufficient stock";
    
    "Parent category must exist before creating subcategory";
    
    endpoint: IEndpoint

    The API endpoint that must be called before the main operation.

    This specifies the exact HTTP method and path of the prerequisite API. The endpoint must be a valid operation defined elsewhere in the API specification. Path parameters in the prerequisite endpoint can reference the same parameters available in the main operation.

      endpoint: {
    path: "/organizations/{orgId}/projects/{projectId}",
    method: "get"
    }