You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include request and response schemas in devproxy api show --output json - #2096
requestBody – required + content map with a JSON schema (and an example)
responses – keyed by status code, each with description and an optional content map with a schema
Shapes follow OpenAPI 3.1 conventions so agents and tools recognize them. For example, GET /proxy/rootCertificate now documents the required format=crt query parameter and 400, and POST /proxy/stopProxy documents 202.
#2092 adds short human-readable query and body hint strings to each endpoint (text and JSON). This PR is complementary and uses different keys so both coexist in the JSON output:
Both PRs touch the JSON projection in ApiCommand.PrintApiInfo; whichever merges second needs a trivial merge there (keep all five keys). Schemas live in a separate ApiEndpointSchemas file to keep the overlap that small.
Why this option (and not serving /openapi.json)
The issue offered two options. I chose extending api show:
Works without a running proxy.api show is what agents read first, typically before Dev Proxy starts. An OpenAPI endpoint is only reachable after startup and with a token.
No new dependencies. Serving OpenAPI needs Microsoft.AspNetCore.OpenApi (Swashbuckle was removed in Update deps. Closes #1637 #1647), and the generated document would need customization anyway (status codes set via Response.StatusCode, content negotiation on /proxy/logs).
One discovery path. The existing JSON already has baseUrl and authentication; adding schemas keeps everything in one place.
Other changes
devproxy --help advertised an OpenAPI spec at <api>/swagger, which no longer exists (404). It now shows the API URL and points to devproxy api show --output json.
Updated the CI/CD skill reference to mention the JSON output.
Keeping schemas accurate
Schemas live in ApiEndpointSchemas (separate from ApiCommand to stay out of the way of #2065). Tests use reflection on ProxyController to fail when:
a controller endpoint has no schema
[FromQuery] parameters or their [Required]-ness differ from parameters
[FromBody] presence differs from requestBody
JwtOptions, ProxyInfo or the logs entry DTO gain or lose properties
Verification
dotnet test DevProxy.Tests – 46 passed
Started a detached proxy and called every endpoint; status codes and content types match the documented ones (including application/problem+json for 400s, and the PascalCase property names /proxy/logs actually returns for 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.
Closesdotnet#2066
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The discovery schemas omit the logs endpoint’s 400 query-validation response and allow status payloads containing non-null configFile values that the controller rejects.
Extends Dev Proxy’s offline API discovery with request and response schemas, helping agents and tools construct API calls without a running proxy. Text output remains unchanged.
Changes:
Adds query parameters, request bodies, and response schemas to api show --output json.
Adds reflection-based tests to detect drift between schemas and controller contracts.
Replaces the obsolete Swagger help link and documents JSON discovery.
- 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>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The lifetime schema permits negative validFor values, allowing schema-valid requests that fail during token creation because expiration precedes the not-before time.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Require positive values for validFor in the lifetime schema
DevProxy/Commands/ApiEndpointSchemas.cs:169
The lifetime schema accepts negative values, so a client can generate a schema-valid request such as {"validFor": -1} that fails during token creation: JwtCreatorOptions.Create puts ExpiresOn before NotBefore, and JwtIssuer passes those dates to CreateJwtSecurityToken, which rejects them. Please constrain validFor to a positive number so the discovery schema does not advertise these failing requests as valid.
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues remain that require changes.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
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
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.
Closes #2066
What
devproxy api show --output jsonnow includes, per endpoint:parameters– query parameters (name,in: "query",description,required, JSONschema)requestBody–required+contentmap with a JSON schema (and an example)responses– keyed by status code, each withdescriptionand an optionalcontentmap with a schemaShapes follow OpenAPI 3.1 conventions so agents and tools recognize them. For example,
GET /proxy/rootCertificatenow documents the requiredformat=crtquery parameter and400, andPOST /proxy/stopProxydocuments202.Text output is unchanged.
Overlap with #2092 (#2065)
#2092 adds short human-readable
queryandbodyhint strings to each endpoint (text and JSON). This PR is complementary and uses different keys so both coexist in the JSON output:query,bodyformat=crt (required)parameters,requestBody,responsesBoth PRs touch the JSON projection in
ApiCommand.PrintApiInfo; whichever merges second needs a trivial merge there (keep all five keys). Schemas live in a separateApiEndpointSchemasfile to keep the overlap that small.Why this option (and not serving
/openapi.json)The issue offered two options. I chose extending
api show:api showis what agents read first, typically before Dev Proxy starts. An OpenAPI endpoint is only reachable after startup and with a token.Microsoft.AspNetCore.OpenApi(Swashbuckle was removed in Update deps. Closes #1637 #1647), and the generated document would need customization anyway (status codes set viaResponse.StatusCode, content negotiation on/proxy/logs).baseUrlandauthentication; adding schemas keeps everything in one place.Other changes
devproxy --helpadvertised an OpenAPI spec at<api>/swagger, which no longer exists (404). It now shows the API URL and points todevproxy api show --output json.Keeping schemas accurate
Schemas live in
ApiEndpointSchemas(separate fromApiCommandto stay out of the way of #2065). Tests use reflection onProxyControllerto fail when:[FromQuery]parameters or their[Required]-ness differ fromparameters[FromBody]presence differs fromrequestBodyJwtOptions,ProxyInfoor the logs entry DTO gain or lose propertiesVerification
dotnet test DevProxy.Tests– 46 passedapplication/problem+jsonfor 400s, and the PascalCase property names/proxy/logsactually returns for JSON).