hitspec validate
Validate.http and .hitspec files for syntax errors without executing them.
Arguments
Flags
Behavior
Thevalidate command parses each file without running it. Findings are either errors or warnings.
Errors are constructs that would give a wrong result, or that hitspec run refuses. They are reported with file:line:column and the command exits with code 2 (the same code run uses for a file that fails to load):
- An unknown assertion operator (
contians,=,===,equals), with a “did you mean” hint - An operator without a value, or extra values (
expect status 200 201) - A misspelt
expect, block type (>>>captur) ortypename, and lines inside>>>or>>>captureblocks that are not assertions or captures - Invalid
matchesregular expressions, and@authproblems - Unclosed
>>>blocks, and blocks that are not inside a request - Duplicate request names, and circular
@depends - An empty file or a request without a URL
OK line and do not change the exit code:
- An unknown
# @directive(a typo such as# @taginstead of# @tags). Custom directives start withx-(# @x-owner);@contract.*is also accepted - An invalid
@timeout,@retry,@retryDelayor@retryOnvalue # @directivelines at the top of a file that lead into no request- A
@dependson a request that does not exist in the file - A capture path containing spaces (it can never match)
- An unknown key in
hitspec.yaml(for exampletiemout), with a “did you mean” hint.validatechecks the nearesthitspec.yamlfrom the working directory upward and lists it before the test files
--strict, every warning is an error (exit code 2), including an unknown hitspec.yaml key, and validate additionally checks variables:
{{name}}must be defined in the file (@name = ...), by a>>>captureblock, in anenvironments:entry of the nearesthitspec.yaml, in a.envfile next to the file or in the working directory, or in the process environment.{{$uuid()}},{{$env(NAME)}}and other built-ins are never flagged.{{request.capture}}must name a capture that request has, and the using request should# @dependson it.
Variable checking is a static check. It cannot know which environment a later
hitspec run --env selects or what a CI job injects, so it accepts a name defined in any environment and in the current process environment. That is why it is only enabled by --strict.OK <file>. If any file has errors, the command prints each error and exits with code 2. A hitspec.yaml that cannot be parsed stops validate with exit code 3 (a configuration error) and a file:line message.
Examples
Sample Output
Use in CI/CD
hitspec list
List all requests defined in.http and .hitspec files.
Arguments
Behavior
Thelist command parses each file and prints each request with its name and tags. If a request has no @name annotation, the method and URL are used as the display name.
Examples
Sample Output
Use Cases
- Discover available tests in a project
- Verify request names before filtering with
--name - Audit tag coverage across test files
- Quick inventory of API endpoints under test