# petstore3-client E2E results

This directory contains the **hand-written AUnit test class** (`src/zcl_ps3_client_tests.clas.abap`) deployed alongside the generated v2 client artifacts (`zif_petstore3_types`, `zif_petstore3`, `zcx_petstore3_error`, `zcl_petstore3` + its `locals_def` / `locals_imp` includes) to prove that the code generated by `@abapify/openai-codegen` is **usable on a live SAP BTP Steampunk (cloud ABAP) system**.

## What the v2 generator produces

Per OpenAPI spec, the generator writes 11 abapGit files:

```
src/zif_petstore3_types.intf.{abap,xml}   Layer 1: all schemas as TYPES
src/zif_petstore3.intf.{abap,xml}         Layer 2: operations as METHODS
src/zcx_petstore3_error.clas.{abap,xml}   Exception (status/description/body/headers)
src/zcl_petstore3.clas.{abap,xml}         Layer 3: minimal implementation
src/zcl_petstore3.clas.locals_def.abap    lcl_http + lcl_response + json + lcl_json_parser
src/zcl_petstore3.clas.locals_imp.abap    their implementations (kernel wrappers)
package.devc.xml
```

`zif_petstore3_types` holds all schema `TYPES` with round-trip markers like `"! @openapi-schema Pet`. `zif_petstore3` declares one typed method per operation (`"! @openapi-operation getPetById`). `zcl_petstore3`'s implementation is strictly a mapping layer: each method does `client->fetch(...)` + `CASE response->status( ) ... json=>parse(...)->to(REF #(target)) ... RAISE EXCEPTION NEW zcx_petstore3_error(...)` — no private helpers. All transport/codepage/JSON logic lives inside the bundled local classes, which wrap `cl_web_http_client_manager`, `cl_http_destination_provider`, `cl_http_utility`, `/ui2/cl_json`, `cl_abap_conv_codepage`. Zero Z-dependencies.

## What the hand-written test class proves

`ZCL_PS3_CLIENT_TESTS` references from outside the generated client:

- `NEW zcl_petstore3( destination = 'PETSTORE' )` — constructor signature.
- `DATA pet TYPE zif_petstore3_types=>pet.` — `Pet` schema type is reachable because it lives in the public types interface (not hidden in the implementation class private section).
- `DATA order TYPE zif_petstore3_types=>order.` — same for `Order`.
- Primitive mapping: `order-id = 42` typed as `int8`, `order-complete = abap_true` typed as `abap_bool`.

Because the test class activates without errors against the live kernel, every symbol it touches has resolved against the Steampunk class whitelist.

## Deploying to a Steampunk tenant

`S_ABPLNGVS` authorization on BTP is granted **per package**. Deploying with `--package $TMP` often fails with:

```
HTTP 403: Forbidden - You are not authorized to make changes (authorization object S_ABPLNGVS)
```

Use a package your own user owns (e.g. `ZPEPL`, `Z<user>_*`). The generator itself is system-agnostic; this is purely a deploy-time parameter.

## How to reproduce

```bash
# 1) Authenticate to your Steampunk system.
bunx adt auth login

# 2) Regenerate (outputs to generated/abapgit + generated/gcts).
cd samples/petstore3-client
bun run generate

# 3) Deploy the generated artefacts into a user-writable package.
bunx adt deploy \
  --source generated/abapgit --package ZPEPL \
  --activate --unlock

# 4) Deploy the AUnit test class.
bunx adt deploy \
  --source e2e/abapgit --package ZPEPL \
  --activate --unlock

# 5) (Optional) Run the AUnit tests.
bunx adt aunit -c ZCL_PS3_CLIENT_TESTS
```
