How to check real API calls against an OpenAPI spec

Import your OpenAPI 3 or Swagger 2 spec into RequestFox; the import links it as the contract. Then record as usual: a call that breaks the spec shows SPEC MISMATCH with the reason, a call the spec does not have shows NOT IN SPEC, and Top Issues counts how many operations you covered.

A call marked SPEC MISMATCH: its Details say the response body's price was a string where the spec expects a number; another call is NOT IN SPEC; spec coverage 3 of 6 operations
A call that breaks the linked spec, with the reason.

Steps

  1. Import the spec

    Import your OpenAPI 3 or Swagger 2 file, JSON or YAML. Every operation becomes a request you can send, and the spec is linked as the contract.

  2. Record the flow you test

    Press Start and use the app. Calls to the spec's API are checked as they arrive; calls to other sites, such as analytics or fonts, are never judged.

  3. Read the marks

    SPEC MISMATCH gives one line of reason, for example "response body $.price: expected number, got string". NOT IN SPEC marks a call the spec does not document. Details lists every problem.

  4. See what you have not covered

    Top Issues shows "Spec coverage: 3 of 6 operations seen"; a click lists the operations not called yet.

  5. Change or turn off the contract

    Settings → Pass/fail checks → Contract.

What is checked

Path, method and status must be in the spec, and the parameters, request body, content type, required response headers and response body must match it. Anything RequestFox cannot check is shown as "not checked", never as a pass.

The same check in CI

Export the session as JSON (or use a HAR file) and run the command-line tool against the spec. It prints a line per call, the coverage, and exits with 1 on a mismatch:

node requestfox-ci.mjs conform --spec openapi.yaml --session session.json --reporter junit --out results.xml

--min-coverage 80 also fails below that share of operations seen. How to get the command-line tool.

Next