Repository navigation
Update GenHTTP to 11.1 and document the API for its consumers - #124
Merged
Merged
Conversation
GenHTTP 11.1 lets webservices document themselves ([Summary], [Remarks], [Response], [RequestBody], [RequestHeader], [ResponseHeader], [Tag]). The OpenAPI document of /api/v1 is now written with them, for whoever calls the API rather than for whoever maintains it: - An introduction (Resources/Api/Introduction.md): getting started, who may do what with which key, versions, data and features, the file format, limits and where to read them, and how refusals are answered. - Tags by concept rather than by class, in groups Scalar shows in the sidebar (x-tagGroups, ApiDocumentation). - Every operation says what it does and how it behaves: what it changes and leaves alone, every way it is refused and why (with ErrorResponse), 201/202/422 where those are answered, zip and binary bodies and downloads with their content types, the admin token on the operator's endpoints. Read off the services, not guessed. - Every model and field is described; the fields' <param> comments moved into [Summary], so they are said once. - ApiDocumentationTests keep it so: an undocumented operation, parameter, answer, model or field fails the build. 11.1 no longer ships GenHTTP.Testing in GenHTTP.Full, so the tests reference it on their own - and the export no longer needs ASP.NET Core, so its Dockerfile runs on the plain runtime image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kWXmwvMJGrUr1pw9iEBy3
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.
Updates GenHTTP to 11.1 and uses its new webservice documentation attributes to document
/api/v1for whoever calls it - an agent or a developer writing a client - rather than for whoever maintains it.What a reader of
/api/v1/scalar/gets nowResources/Api/Introduction.md): getting started in three calls (checked against a running server), who may do what with which key, what versions, data and features are, the file format, the limits and where to read them, and how refusals are answered.x-tagGroups, set inApiDocumentation): Getting started, The program, What it keeps, How it is doing, Sharing it, The build agent, Operating the installation.ErrorResponsebody), the 201/202/422 answers where those are used, and zip and binary bodies and downloads with their content types andContent-Disposition. The operator's endpoints declareX-Admin-Tokenwith its 401/403. I read the services to write this: key rules, file name rules, the order a change is applied in, what a merge carries over and what it throws away, what switching data off deletes, when previews go offline, and so on.<param>comments moved into[Summary]on the parameters, so each field is described once and reaches the schema. XML comments keep only the why for maintainers.Kept complete
ApiDocumentationTestsreads the served document and fails on:/lambdas/{privateKey}that does not say how an unknown key is answeredIt also pins the answers that matter: 201 for what is created, 202 for the agent, 422 with the compiler's diagnostics, zips as zips.
CLAUDE.mdhas the rules under The API description, and the README's API section points to the description.Other effects of 11.1
GenHTTP.Fullno longer carriesGenHTTP.Testing, so the tests reference it themselves.Dockerfilenow usesdotnet/runtime:10.0instead ofaspnet. I checked by exportingdemo-crud, publishing it (theruntimeconfig.jsonnames onlyMicrosoft.NETCore.App) and running it: it applied its migration and served its page.Framework issues found (not worked around)
SchemaManagergenerates schemas withNewtonsoftJsonSchemaGeneratorSettingsand its default naming, so the document saysPublicKeywhile the API answers camelCasepublicKey(System.Text.Json,JsonFormat). Requests still work because they are read case-insensitively. A client generated from the spec would mis-read every answer, though, and Scalar's examples show the wrong names. The same root cause lists[JsonIgnore]properties that are never sent (LambdaFile.IsCompiled,IsCode,IsResource,Bytes); the test names these explicitly as known gaps. Repro: any record returned by a webservice and theopenapi.jsonofApiDescription.Create().204.OpenApiExtensions.MightBeNullreturnstruefor any class and ignores nullable annotations, soLambdaResponse Get(...)gets "204 - A response containing no body" next to its 200.NullabilityInfoContexton the return parameter would tell. The phantom only disappears where a success response is declared explicitly; I did not add declarations just to hide it.OpenApiConcernmatches"application/application/vnd.oai.openapi+json"(and+yaml), so/openapiwithAccept: application/vnd.oai.openapi+jsonanswers 400.GetBinarySchema()produces{ "format": "binary" }without"type": "string", which OpenAPI 3.0 requires next to the format.[return: Summary]. OpenAPI requires a description. I added[return: Summary]everywhere, which documents the answer anyway.ApiKeyConcernand the others) don't implementIDocumentedConcern, so the header and the 401/403 they add are declared by hand on the three operator resources.Test plan
dotnet buildwith no warnings,dotnet test: 851 passed🤖 Generated with Claude Code
https://claude.ai/code/session_015kWXmwvMJGrUr1pw9iEBy3