Skip to content

devproxy api show: include request body and query parameters for each endpoint - #2092

Merged
waldekmastykarz merged 10 commits into
dotnet:mainfrom
waldekmastykarz:api-show-request-body-query-params
Nov 27, 2026
Merged

waldekmastykarz merged 10 commits into
dotnet:mainfrom
waldekmastykarz:api-show-request-body-query-params

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Resolves #2065

devproxy api show now lists the input each endpoint expects, so agents don't have to guess the POST /proxy body or miss the required format query on /proxy/rootCertificate.

Text output:

  GET    /proxy                         Get proxy status
  POST   /proxy                         Update proxy status (e.g. start/stop recording)  body: {"recording": true|false}
  POST   /proxy/mockRequest             Issue a mock request
  POST   /proxy/stopProxy               Stop the proxy
  POST   /proxy/jwtToken                Create a JWT token  body: {"name": "...", "audiences": ["..."], ...} (all optional; validFor in minutes)
  GET    /proxy/rootCertificate         Get the root certificate  query: format=crt (required)
  GET    /proxy/logs                    Get proxy logs (for detached mode access)  query: lines=50&follow=true&since=5m (all optional)

JSON output (--output json) gets matching optional query and body string hints per endpoint (omitted when an endpoint takes no input).

Notes:

… endpoint

Closes dotnet#2065

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner November 5, 2026 10:43
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the endpoint input-hint changes.

No open issues 🎉

What changed in this PR

Enhances devproxy api show with endpoint input hints so users and agents can discover expected request bodies and query parameters.

Changes:

  • Adds body and query hints to text output and optional body and query fields to JSON output.
  • Centralizes endpoint metadata and text formatting.
  • Adds tests for recording, certificate, and JWT hints, plus endpoints without input.
File Description
DevProxy/​Commands/​ApiCommand.cs Defines input hints and includes them in text and JSON output.
DevProxy.Tests/​ApiCommandTests.cs Tests endpoint hints and description-only formatting.

Review effort: Balanced

waldekmastykarz added a commit to waldekmastykarz/dev-proxy that referenced this pull request Nov 5, 2026
- Rename structured query field to OpenAPI 'parameters' (with in: query)
  so it doesn't collide with the 'query' hint added in dotnet#2092
- Disallow additional properties in the POST /proxy request schema
- Document 400 for invalid query values on /proxy/logs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz waldekmastykarz added the pr-enhancement Product features, behavior fixes, and usability or compatibility improvements label Nov 21, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the API input-hint changes.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the endpoint input-hint changes.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 26, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the endpoint input-hint changes.

No open issues 🎉

Review effort: Balanced

@garrytrinder garrytrinder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test results

  • PR: #2092
  • Tested commit: 58072f04cef129e7945457d9b4c1e525ab409168
  • Environment: macOS 27.2.1, .NET SDK 10.0.103, PR source build, detached mode, random proxy/API ports, system proxy and certificate installation disabled. Local HTTP upstream and an owned, pre-created test CA; inert RetryAfterPlugin configuration.
Scenario or test command Expected Actual Result
Locked restore and dotnet build for DevProxy/DevProxy.csproj and DevProxy.Plugins/DevProxy.Plugins.csproj Build source executable and runtime plugins Both builds succeeded, zero warnings/errors PASS
CI at tested commit Automated validation passes Build, smoke, CodeQL, and tests on macOS, Ubuntu, and Windows all successful; automated tests not rerun locally PASS
api show --no-color Seven endpoints; recording/JWT body hints and certificate/log query hints All seven endpoints and all four hints present; no-input endpoint descriptions unchanged PASS
api show --output json Hints under result.data.endpoints; omit null hints One JSONL result envelope; seven endpoints; exact string hints; body/query absent on all three no-input endpoints; authentication metadata retained PASS
Detached readiness and explicit HTTP request through assigned proxy port Live authenticated API and deterministic upstream response Owned PID 48617; proxy 57467/API 57466; GET /proxy 200; proxied local request 200 with exact expected JSON PASS
API authentication No unauthenticated access Unauthenticated GET /proxy returned 401 PASS
POST /proxy with {"recording":true}, then false Both transitions accepted and observable Both POSTs returned 200; subsequent GETs confirmed each recording state PASS
GET /proxy/rootCertificate with no format, invalid format, then ?format=crt Missing/invalid format rejected; advertised query succeeds Missing/invalid format returned 400 with format errors; format=crt returned 200, certificate content type and valid PEM matching the test CA PASS
POST /proxy/jwtToken with {} and all advertised fields populated Optional defaults work; supplied fields and minutes honored Both returned JWTs; decoded name/audience/issuer/role/scope/custom claim matched; validFor:60 produced 3600-second expiry within 10 seconds PASS
POST /proxy/mockRequest without body No-input behavior preserved 204 PASS
GET /proxy/logs?lines=2&follow=false&since=5m Bounded recent logs 200 with exactly two lines PASS
GET /proxy/logs?lines=50&follow=true&since=5m Advertised follow hint streams logs 200, text/event-stream, and data: events PASS
PID-scoped shutdown and cleanup No owned instances/fixtures remain stop --pid 48617 succeeded; process exit verified; local upstream stopped; owned fixtures/logs removed; checkout clean PASS

Commands used dotnet run --no-build --project DevProxy -- --config-file <owned-config> followed by the command arguments. Runtime launch additionally used --detach --as-system-proxy false --port 0 --api-port 0 --install-cert false --no-first-run. Credentials were obtained using api token --pid <owned-PID> and were not included in this report.

Setup issues were resolved before the successful run: the clean checkout initially lacked NuGet assets and built plugin assemblies; locked restore and building the plugin project supplied them without tracked changes. The test fixture needed an enabled plugin and root-position --config-file. The harness was adjusted to parse the token command's indented JSON. An initially nonexistent isolated macOS Application Support directory caused state-path drift; the affected owned instance was stopped through its authenticated API (202), exit verified, and its log removed. Pre-creating that directory resolved subsequent PID-scoped CLI shutdown. These were setup/harness issues, not defects attributable to the PR.

Requested changes

None.

Outcome

Approve, scoped to functional testing; this does not replace code review. All planned scenarios passed on the current head, rechecked immediately before publication. Owned proxy processes, upstream services, configurations, test certificates, and generated daemon logs have been cleaned up. No PR files were changed.

Resolve conflict in ApiCommand.cs: keep structured Endpoints list and reflect optional rootCertificate format (crt|pem) from dotnet#2090.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review identified no active issues with the endpoint input-hint changes.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 26, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the endpoint input-hint changes.

No open issues 🎉

Review effort: Balanced

@garrytrinder garrytrinder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test results

  • PR: #2092
  • Tested commit: 4ec274e7502040040e929a76f628d6b50d1bc117
  • Environment: macOS 27.2.1, .NET SDK 10.0.103, refreshed PR source build. Detached instance with random ports, system proxy and certificate installation disabled, local HTTP upstream, inert RetryAfterPlugin, and an owned pre-created CA. HOME and CFFIXED_USER_HOME pointed to the fixture home with Library/Application Support created before .NET ran; state, credentials and logs were verified to remain inside the fixture.

This rerun supersedes the earlier functional approval for 58072f04cef129e7945457d9b4c1e525ab409168. In particular, the certificate query is now optional and accepts crt or pem; the previous required-format expectation no longer applies.

Scenario or test command Expected Actual Result
Locked restore and source builds of DevProxy/DevProxy.csproj and DevProxy.Plugins/DevProxy.Plugins.csproj Current executable and plugins build successfully Both builds succeeded with zero warnings/errors PASS
Automated CI for tested SHA Required automated validation succeeds Build, smoke, CodeQL, C# analysis, and tests on Windows, Ubuntu and macOS all succeeded; automated tests not rerun locally PASS
api show --no-color Seven endpoints, two body hints, two query hints Exact recording/JWT/log hints present; certificate describes PEM and format=crt or pem, optional/default crt; no-input descriptions unchanged PASS
api show --output json Matching optional string hints; preserve existing fields and omit unused keys One result.data envelope, seven endpoints, exact hints, authentication metadata retained; body and query absent on all three no-input endpoints PASS
Detached readiness plus explicitly proxied localhost request Live authenticated API and deterministic upstream response Owned PID 11003; proxy port 65249, API port 65273; authenticated GET /proxy 200; proxied request returned 200 with exact upstream JSON PASS
Unauthenticated GET /proxy Authentication still enforced 401 PASS
POST /proxy with {"recording":true}, then false Both advertised state transitions work Both POSTs returned 200 and subsequent GETs confirmed each state PASS
GET /proxy/rootCertificate with omitted query, format=crt, format=pem, empty format, and uppercase aliases Optional query defaults correctly; both advertised formats work All returned 200 with identical valid PEM, certificate content type and devProxy.crt filename; OpenSSL confirmed the owned test CA subject PASS
GET /proxy/rootCertificate?format=invalid Unsupported format rejected 400 with a format validation error naming crt and pem PASS
POST /proxy/jwtToken with {} and all advertised fields populated Defaults work; supplied fields and expiry units honored Both returned JWTs; decoded name/audience/issuer/role/scope/custom claim matched; validFor:60 yielded 3600-second expiry within 10 seconds PASS
POST /proxy/mockRequest without body No-input behavior preserved 204 PASS
GET /proxy/logs?lines=2&follow=false&since=5m Bounded recent logs 200 with exactly two lines PASS
GET /proxy/logs?lines=50&follow=true&since=5m Advertised follow query streams logs 200, text/event-stream, and data: events PASS
stop --pid 11003 and cleanup Graceful owned shutdown and clean checkout CLI stop succeeded, PID exit verified, local upstream closed, owned fixtures/certificates/logs removed, checkout clean PASS

Commands used dotnet run --no-build --project DevProxy -- --config-file <owned-config> followed by the command arguments. Runtime launch appended --detach --as-system-proxy false --port 0 --api-port 0 --install-cert false --no-first-run. API credentials were acquired PID-specifically and are omitted from this report.

Requested changes

None.

Outcome

Approve, scoped to functional testing; this does not replace code review. The head was rechecked before publication and still matches the tested SHA. No blockers, source edits, fixes, commits or merges. All owned processes and fixtures have been cleaned up.

waldekmastykarz added a commit that referenced this pull request Nov 27, 2026
…on (#2096)

* Include request and response schemas in devproxy api show --output json

Each endpoint in the JSON output now includes OpenAPI-style query
parameters, a request body JSON schema, and responses keyed by status
code. Also removes the stale /swagger reference from the help text.

Closes #2066

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Address review: rename query to parameters, tighten schemas

- Rename structured query field to OpenAPI 'parameters' (with in: query)
  so it doesn't collide with the 'query' hint added in #2092
- Disallow additional properties in the POST /proxy request schema
- Document 400 for invalid query values on /proxy/logs

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Require positive validFor in jwtToken schema

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Document 204 for POST /proxy/mockRequest in API schemas

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Mark rootCertificate format query parameter as optional

Upstream made format optional (default crt) and added pem as an alias.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve conflict in ApiCommand.cs: keep the query/body hints from this PR alongside the parameters/requestBody/responses schemas from dotnet#2096 in the JSON output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues blocking the request-body and query-parameter hint changes.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 27, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes adding endpoint input hints to text and JSON output.

No open issues 🎉

Review effort: Balanced

@garrytrinder garrytrinder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional test results

  • PR: #2092
  • Tested commit: 64f2a5f849930b6ac880443322b3938e48ee91de
  • Environment: macOS 27.2.1, .NET SDK 10.0.103, latest PR source executable and plugins. Detached mode, random proxy/API ports, no system-proxy or certificate-trust changes. Isolated fixture home (HOME and CFFIXED_USER_HOME, pre-created Application Support directory), unique pre-created test CA, inert RetryAfterPlugin, deterministic local HTTP upstream.

Fresh rerun after upstream merges, superseding the earlier functional approval for 4ec274e7502040040e929a76f628d6b50d1bc117. JSON output now includes structured schemas alongside the string hints; compatibility with those schemas was included in this run.

Scenario or test command Expected Actual Result
dotnet build DevProxy/DevProxy.csproj --no-restore and plugin project build Current executable/plugins build Both builds succeeded with zero warnings/errors PASS
Exact-head automated CI Automated validation succeeds Build, smoke, C# analysis, CodeQL and Windows/macOS/Ubuntu tests successful; automated tests not rerun locally PASS
api show --no-color Seven endpoints; correct body/query hints; unchanged no-input descriptions All seven endpoints and four exact hints present PASS
api show --output json Matching hints in one result.data envelope, unused hint keys omitted Seven endpoints; exact body/query hints; auth retained; unused body/query absent on all three no-input endpoints PASS
JSON structured-schema coexistence Added hints do not replace structured metadata All seven response schemas retained; recording/JWT body schemas and certificate/log parameter schemas intact; certificate enum/default/optional flag correct; no-input request schemas omitted; 204/202 responses retained PASS
Detached readiness and explicit request through assigned proxy port Live authenticated API and exact local upstream response Owned PID 41699, proxy 60876/API 60877; GET /proxy 200; proxied local request 200 with exact expected JSON PASS
Unauthenticated GET /proxy Authentication preserved 401 PASS
POST /proxy with {"recording":true}, then false Advertised body controls recording Both POSTs 200; subsequent GETs confirmed each state PASS
GET /proxy/rootCertificate with omitted, crt, pem, empty and uppercase formats Optional default and aliases return certificate All 200; identical valid PEM, correct content type and filename; OpenSSL confirmed owned CA subject PASS
GET /proxy/rootCertificate?format=invalid Invalid input rejected 400 with format error naming supported aliases PASS
POST /proxy/jwtToken with {} and all advertised fields populated Defaults and supplied options work; minutes honored Both returned JWTs; decoded claims matched; validFor:60 gave 3600-second expiry within 10 seconds PASS
POST /proxy/mockRequest without body Bodyless endpoint preserved 204 PASS
GET /proxy/logs?lines=2&follow=false&since=5m Bounded recent log output 200, exactly two lines PASS
GET /proxy/logs?lines=50&follow=true&since=5m Advertised query streams logs 200, text/event-stream, data: events PASS
stop --pid 41699 and cleanup Stop only owned instance; remove owned fixtures CLI stop succeeded, PID exit verified, local upstream closed, isolated logs/certificates/configs removed, checkout clean PASS

Commands used dotnet run --no-build --project DevProxy -- --config-file <owned-config> followed by command arguments. Launch included --detach --as-system-proxy false --port 0 --api-port 0 --install-cert false --no-first-run. API credentials were acquired for the owned PID and omitted from this report.

Requested changes

None.

Outcome

Approve, scoped to functional testing; this does not replace code review. All scenarios passed on the current head, rechecked immediately before publication. No blockers. Owned state/log/certificate paths were confirmed isolated; processes and fixtures are cleaned up. No source fixes, pushes or merges performed.

@waldekmastykarz
waldekmastykarz merged commit 1db22d5 into dotnet:main Nov 27, 2026
8 checks passed
@waldekmastykarz
waldekmastykarz deleted the api-show-request-body-query-params branch November 27, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-enhancement Product features, behavior fixes, and usability or compatibility improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

devproxy api show: include request body and query parameters for each endpoint

3 participants