# Generate the API Client
source: https://developer.mastercard.com/mastercard-threat-intelligence/tutorial/api-sandbox-guide/step-5/index.md

In this step, you generate a type-safe Java client from the OpenAPI specification. The OpenAPI Generator plugin does this during the build, so you never write the client by hand.

*** ** * ** ***

### Generate on the Fly {#generate-on-the-fly}

The plugin binds to the `generate-sources` phase. This means the client is created automatically before compilation whenever you build.

To generate the client without a full build, run:

```bash
mvn generate-sources
```

To generate the client and compile in one step, run:

```bash
mvn compile
```

The generated code lands under `target/generated-sources/openapi/`. The build adds this folder to the source path, so your code can use the client directly.

*** ** * ** ***

### Understand the Generator Options {#understand-the-generator-options}

The `pom.xml` from the previous step sets these options:

|          Option          |              Value               |                                     Purpose                                      |
|--------------------------|----------------------------------|----------------------------------------------------------------------------------|
| `generatorName`          | `java`                           | Generates a Java client.                                                         |
| `library`                | `okhttp-gson`                    | Uses OkHttp for HTTP and Gson for JSON.                                          |
| `apiPackage`             | `com.example.mti.client.api`     | Package for the API classes.                                                     |
| `modelPackage`           | `com.example.mti.client.model`   | Package for the request and response models.                                     |
| `invokerPackage`         | `com.example.mti.client.invoker` | Package for the client infrastructure.                                           |
| `dateLibrary`            | `java8`                          | Uses `java.time` types for dates.                                                |
| `useJakartaEe`           | `true`                           | Uses Jakarta annotations, which suit Java 17.                                    |
| `containerDefaultToNull` | `true`                           | Defaults unset arrays and maps to `null` so the client omits them from requests. |

*** ** * ** ***

### Review the Generated Classes {#review-the-generated-classes}

The generator creates one API class for each feature, named after its tag:

* `MerchantThreatIntelligenceApi`
* `PaymentEcosystemThreatIntelligenceApi`
* `CardTestingApi`

It also creates the `ApiClient` and `ApiException` classes in the invoker package, plus a model class for each request and response.

You wire these classes together in the next step.

*** ** * ** ***

