> For the complete documentation index, see [llms.txt](https://docs.precisiontestautomation.in/scriptlessautomation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.precisiontestautomation.in/scriptlessautomation/automation-platforms/scriptlessapi-automation/api-support-generator.md).

# API Support Generator

### Overview

The API Support Generator is not a direct feature but rather a suggested practice within scriptless automation. It involves organizing and storing commonly used API calls that prepare the necessary conditions or data for a series of tests. These preparatory API calls are typically stored in a dedicated directory and can be invoked as dependent test cases in the automation workflow.

### Structure and Purpose

#### APISupportGenerator Directory

The `APISupportGenerator` directory is recommended for storing supported API call definitions. These calls are designed to set up the environment or data state required for primary test cases.

<pre><code><strong>[testdata]
</strong>│
├───[API]
│   └───[JsonRepository]
│   └───[APISupportGenerator]
│   └───[test_case_flows]
│       └───[TestDirectory]
│           └───[TestID_GroupName.csv]
</code></pre>

#### Usage as Dependent Test Cases

API calls within the `APISupportGenerator` directory can be referenced as dependent test cases. They are executed prior to the main test cases and their responses are stored for use in subsequent API calls.

### Implementation

#### Adding Supported API Calls

1. **Identify Common API Calls**: Determine the API calls that are frequently used to set up test preconditions, such as user generation or data seeding.
2. **Create API Definitions**: For each identified API call, create a definition file that includes the endpoint, method, and any necessary parameters or body content.
3. **Store in APISupportGenerator**: Save these API definition files in the `APISupportGenerator` directory within the scriptless automation framework.

#### Referencing in Test Cases

When creating a test case that requires a precondition, reference the appropriate API call from the `APISupportGenerator` as a dependent test case.

**Example**

If there is a need to generate a user before a series of test cases, the user generation API call would be stored in the `APISupportGenerator` directory. It would look something like this:

```
DEPENDANT_TEST_CASE,GenerateUser,
...
```

In the main test case CSV file, the `DEPENDANT_TEST_CASE` parameter would be set to the name of the preparatory API call, such as `GenerateUser`.

### Conclusion

The API Support Generator approach enhances scriptless automation by providing a systematic way to manage and utilize setup APIs that are integral to the testing process. By storing these APIs in a dedicated directory and using them as dependent test cases, testers can streamline the test preparation phase and ensure a consistent test environment. This strategy promotes reusability, maintainability, and efficient test execution within the scriptless automation framework.
