APIprompt onlyIntermediate

API Contract Until Passing

This loop ensures that the API implementation aligns with the OpenAPI specification by repeatedly validating the contract using swagger-cli until all requirements are met or the maximum iteration limit is reached.

← all loops
OpenAPIAPIValidationswagger-cliContract Testing

Goal

API implementation matches OpenAPI specification

How to Run

Run this loop in a coding environment to validate your OpenAPI spec compliance through iterative corrections.

  1. 01

    Set Up Environment

    Ensure `openapi.yaml` exists in your project root and `swagger-cli` is installed globally or available in your PATH.

  2. 02

    Initiate Loop

    Use the kickoff prompt to start the loop. The agent will attempt to correct validation issues in each iteration.

  3. 03

    Monitor Iterations

    The loop runs up to 10 times. If it exits early due to success, review changes made. If it hits max iterations, manual intervention may be needed.

  4. 04

    Verify Final Output

    After exit, confirm the `openapi.yaml` passes validation independently using `swagger-cli validate openapi.yaml`.

Workflow Steps

  1. 01

    Act

    The agent attempts to fix any validation issues in the API implementation based on the current state of openapi.yaml.

  2. 02

    Run Check

    Execute `swagger-cli validate openapi.yaml` to assess conformance with OpenAPI standards.

  3. 03

    Inspect Result

    Analyze validation output for errors. If none, exit loop; otherwise, proceed to next iteration.

  4. 04

    Repeat

    If validation failed and iterations remain under 10, return to Act step with updated context.

Kickoff Prompt

Start the "API Contract Until Passing" loop.

Goal: API implementation matches OpenAPI specification
Max iterations: 10
Between iterations run: swagger-cli validate openapi.yaml
Exit when: Contract validation succeeds


Please validate the API implementation against the OpenAPI specification defined in 'openapi.yaml'. Run swagger-cli to check for compliance and fix any issues found until validation passes or 10 iterations are completed.

Self-pace this loop. After each iteration, run `swagger-cli validate openapi.yaml` and evaluate the output, and only continue if the exit condition is not met (Contract validation succeeds). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.

Guardrails

hardcoded
  • ·Do not modify the original OpenAPI specification file directly unless explicitly instructed.
  • ·Ensure all generated code adheres strictly to the OpenAPI contract.
  • ·Handle validation errors gracefully without exceeding iteration limits.
  • ·Maintain idempotent behavior across loop iterations to prevent regression.

Flow Diagram

rendering…

Related loops — API