Skip to content

Add jf api docs search for local OpenAPI operation discovery#3597

Open
ehl-jf wants to merge 5 commits into
masterfrom
JGC-526-openapi
Open

Add jf api docs search for local OpenAPI operation discovery#3597
ehl-jf wants to merge 5 commits into
masterfrom
JGC-526-openapi

Conversation

@ehl-jf

@ehl-jf ehl-jf commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds jf api docs search <query> as a subcommand of jf api: a local, offline lookup over the OpenAPI operation catalog embedded by JGC-525 (docs/api-spec/), so an agent (or human) can find the right endpoint — and how to call it — before guessing at jf api <path>.

  • Ranking: weighted contains-match across operationId/path/summary/tags, with a Levenshtein fuzzy fallback for typos, gated by a similarity floor (default 0.6, overridable via $JFROG_CLI_API_DOCS_SEARCH_FUZZY_MIN) to avoid coincidental false positives between unrelated words (e.g. "evidence" vs "environments").

  • Payload awareness: extends apispec.Operation to parse requestBody/components.schemas (already present in both the stub and full bundles, just previously unparsed). Matches now include parameters and request_body (flattened top-level JSON schema fields — type, required, description, default), and the jf_api one-liner embeds a minimal -d '{...}' skeleton for required body fields — a match on its own wasn't enough to actually call the endpoint.

  • Output: JSON by default (this command exists primarily for agent consumption); --format table for humans. Empty results still report spec_bundle so a caller knows a "stub" build may simply be missing the operation.

  • Dispatch: added as Subcommands on the existing api command, alongside its unchanged Action. One accepted, documented wrinkle: the bare, slash-less path docs (e.g. jf api docs) now routes to the new subcommand instead of an HTTP call; the realistic leading-slash form (jf api -X GET /docs) is unaffected, verified via a real-binary test against a mock server plus two permanent regression tests driving the actual urfave/cli dispatch logic.

  • jf api --ai-help now recommends jf api docs search before guessing at an unknown endpoint.

  • All tests have passed. New unit tests were added (general/api/docs_search_test.go, docs/api-spec/parser_test.go, docs/api-spec/requestbody_test.go, two dispatch-regression tests in general/api/cli_test.go) and pass locally; waiting on CI's platform-dependent integration tests before checking this box.

  • The pull request is targeting the master branch.

  • The code has been validated to compile successfully by running go vet ./....

  • The code has been formatted properly using go fmt ./....

ehl-jf added 4 commits July 10, 2026 04:42
Adds `jf api docs search <query>` as a subcommand of `jf api`, ranking
operations from the embedded OpenAPI spec bundle (JGC-525) by a weighted
contains/fuzzy match and printing a ready-to-run `jf api` one-liner for
each. Fully offline, no server config required. Updates `jf api
--ai-help` to recommend it before guessing at an unknown endpoint path.
Raises the fuzzy-fallback similarity floor from 0.4 to 0.6: whole-string
Levenshtein similarity between unrelated but coincidentally similar-length
words (e.g. "evidence" vs "environments", 0.42) was clearing the old bar,
flooding results with false positives instead of the correct empty-result
response. Adds JFROG_CLI_API_DOCS_SEARCH_FUZZY_MIN to override the floor
for experimentation, defaulting to 0.6.
An agent that finds an operation via `jf api docs search` still had no way
to know what payload a POST/PUT/PATCH call needs. The requestBody/
components.schemas data was already present in both the stub and full
OpenAPI bundles, just unparsed. Extends apispec.Operation with a
RequestBody (flattened top-level JSON schema properties, $ref-resolved
one hop) and surfaces both Parameters and RequestBody in search results:
JSON gains "parameters"/"request_body" fields, table view gains PARAMS/
BODY columns, and the "jf_api" one-liner now includes a minimal -d
skeleton for required body fields.
jf api docs search exists primarily for agent consumption, so JSON is
now always the default regardless of --ai-help/$JFROG_CLI_AI_HELP --
previously it only defaulted to JSON when agent-detected, table
otherwise. --format table remains available for humans who want it.
@ehl-jf ehl-jf added the new feature Automatically generated release notes label Jul 10, 2026
Use http.MethodGet instead of the literal "GET", per CI's usestdlibvars linter.
@ehl-jf ehl-jf deployed to build-gate July 10, 2026 04:36 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants