Skip to content

feat: read the API docs of the endpoint and keep them by their ETag - #113

Merged
grubmeshi merged 1 commit into
mainfrom
apidocs-etag
Nov 25, 2026
Merged

grubmeshi merged 1 commit into
mainfrom
apidocs-etag

Conversation

@grubmeshi

Copy link
Copy Markdown
Collaborator

What it does

  • meshstack api and meshstack api-docs download the API docs from /api/openapi of the endpoint, which needs no login. They keep them in the config directory under api-docs/, with one index file per endpoint, and ask again with If-None-Match. On a 304 they read the kept document.
  • If no endpoint is set, the commands use the published API docs of the latest release. With a warning, they also use them if the endpoint has no API docs, or if it cannot be reached and no API docs of it are kept. --dev and a build of no release use the docs of develop.
  • MESHSTACK_API_DOCS_URL is gone. The fake meshStack serves the docs with an ETag.
  • client/openapi reads what the served docs use: an allOf of one schema, maps (additionalProperties), oneOf and anyOf, and x-meshstack-path-key-by-version. Only 2xx responses give the media types of an operation, because an error response always carries application/json. Select narrows each operation by itself.
  • The acceptance suite reads the API docs of the meshStack it runs against, and tests a DELETE without a media type.

Review carefully

internal/apidocs/apidocs.go and store.go (fallbacks, index per endpoint, writes), client/openapi/doc.go and spec.go.

Mechanical

The test fixture client/openapi/testdata/spec.json and the expected outputs in cmd/api/api_test.go.

Place in the stack

4 of 6. Base: http-do-request. Next: generic-mesh-object-client.

🤖 Generated with Claude Code

@grubmeshi
grubmeshi added this pull request to stack #115 November 25, 2026 10:25
@meshcloud-gh-actions

meshcloud-gh-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Coverage of the acceptance run against the meshStack backend, on 3d91f7998e5429385025ac3b583c3af6026d1876.

Scope Coverage
Unit tests 78.2%
Acceptance tests 55.5%
Combined 82.3%
Uncovered functions
client/api_key.go:52: meshApiKeyClient.Create 0.0%
client/api_key.go:56: meshApiKeyClient.Read 0.0%
client/api_key.go:60: meshApiKeyClient.Update 0.0%
client/api_key.go:64: meshApiKeyClient.Delete 0.0%
client/api_key_permissions.go:20: ApiKeyPermissions.AllCodes 0.0%
client/api_key_permissions.go:33: ApiKeyPermissions.WorkspaceCodes 0.0%
client/api_key_permissions.go:263: AllApiKeyPermissions 0.0%
client/api_key_permissions.go:267: WorkspacePermissionCodes 0.0%
client/binding_status.go:18: *MeshGroupBindingStatus.WaitsForApproval 0.0%
client/binding_status.go:22: *MeshUserBindingStatus.WaitsForApproval 0.0%
client/building_block_definition.go:71: MeshBuildingBlockDefinitionApprovalPolicies.NothingRequiresApproval 0.0%
client/building_block_definition.go:82: DisabledSchedule 0.0%
client/building_block_definition.go:89: MeshBuildingBlockDefinitionSchedule.IsDisabled 0.0%
client/building_block_definition.go:93: MeshBuildingBlockDefinitionSpec.HasNeutralPolicies 0.0%
client/building_block_definition.go:97: MeshBuildingBlockDefinitionSpec.WithNeutralPolicies 0.0%
client/building_block_definition.go:166: meshBuildingBlockDefinitionClient.List 0.0%
client/building_block_definition.go:173: meshBuildingBlockDefinitionClient.Read 0.0%
client/building_block_definition.go:177: meshBuildingBlockDefinitionClient.Create 0.0%
client/building_block_definition.go:181: meshBuildingBlockDefinitionClient.Update 0.0%
client/building_block_definition.go:185: meshBuildingBlockDefinitionClient.Delete 0.0%
client/building_block_definition_version.go:103: MeshBuildingBlockType.TagInputTargets 0.0%
client/building_block_definition_version.go:247: meshBuildingBlockDefinitionVersionClient.Create 0.0%
client/building_block_definition_version.go:256: meshBuildingBlockDefinitionVersionClient.Update 0.0%
client/building_block_definition_version_implementation.go:81: MeshBuildingBlockDefinitionImplementation.InferType 0.0%
client/building_block_definition_version_implementation.go:95: MeshBuildingBlockDefinitionImplementation.MarshalJSONTo 0.0%
... and 140 more

covdata func names a method without its receiver, so an entry can belong to an implementation nothing selects rather than to a function the tests never reached. Open the file and line before reading one as a coverage gap.

api and api-docs download the API docs from /api/openapi of the endpoint, which needs no login,
and keep them in the config directory under api-docs/, with one index per endpoint. A later
command asks with If-None-Match and reads the kept document on a 304. Without an endpoint, the
commands use the published API docs; with a warning, also where the endpoint has none, or cannot
be reached and none of its docs are kept. MESHSTACK_API_DOCS_URL is gone.

client/openapi reads what the served docs use: an allOf of one schema, maps, oneOf and anyOf,
and x-meshstack-path-key-by-version. Only the 2xx responses give the media types of an
operation, because an error response carries application/json whatever the operation serves.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Base automatically changed from http-do-request to main November 25, 2026 15:20
@grubmeshi
grubmeshi merged commit 3d91f79 into main Nov 25, 2026
15 of 25 checks passed
@grubmeshi
grubmeshi deleted the apidocs-etag branch November 25, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants