# Golden CONTRACT_ANCHOR example — the COMPOSED, runnable output (not raw swagger-gen).
# Shows the reasoning a rule-based generator cannot do: data-flow (extract $.id -> reuse),
# operation ordering (create first), request bodies, and a negative (404 after delete).
# Proven green against user-service (5/5 passed).
name: user-crud-contract
baseUrl: "http://user-service:8089"
appTag: user-service
credentialTag: admin
steps:
  - name: create user
    method: POST
    path: /api/users
    body: '{"username":"anchor1","email":"anchor1@example.com","password":"anchorpass1","role":"USER"}'
    expect: [200, 201]
    extract:
      userId: $.id            # <-- composition: capture the id this call PRODUCES
  - name: get user
    method: GET
    path: /api/users/{{userId}}   # <-- composition: reuse it (not literal {id})
    expect: [200]
  - name: update user
    method: PUT
    path: /api/users/{{userId}}
    body: '{"username":"anchor1","email":"anchor1b@example.com","password":"anchorpass2","role":"USER"}'
    expect: [200]
  - name: delete user
    method: DELETE
    path: /api/users/{{userId}}
    expect: [200, 204]
  - name: get deleted (404)        # <-- composition: negative assertion proving the delete
    method: GET
    path: /api/users/{{userId}}
    expect: [404]
