Repository navigation
feat(cli): apic check, verify live responses against contracts - #108
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
apic check, which sends contracts' requests and compares the live responses with the documented ones. It's meant for agent loops and CI.Behaviour
validate: no-fchecks every contract,dir/checks a folder, and any other query checks one contract.--statuswhen given. The reply passes if it matches any documented response with that status.nullon either side matches. Arrays are compared against the first example element. Only types are compared, never values.requiredmust be present, in any case.--unsafeis given. A single contract is always sent.mismatch) if any contract mismatched, otherwise 4 network, 3 invalid, 1 other error, and 0 when every contract passed or was skipped. A single contract that can't be checked prints the usual error document, assenddoes.--jsonprints{"results": [{"path", "method", "result", "code", "elapsed_ms", "differences", "reason", "error"}], "passed", "mismatched", "skipped", "failed"}.validateandchecknow share target resolution throughquery_targets. The output ofvalidateis unchanged: I checked an empty folder, a missing folder, a folder with failures and a whole-project run againstmain.Tests
--status, folder run with and without--unsafe, network exit 4, and the text summary.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testall pass.Known limitation
A HEAD contract whose response has a body example always mismatches, because HEAD replies carry no body.
Docs:
COMMAND.md. The apic-web mirror is a separate PR.