Skip to content

feat: add document metadata options and improve HubDocs configuration#5

Merged
mberrishdev merged 1 commit into
mainfrom
feature/add-options
Apr 19, 2026
Merged

feat: add document metadata options and improve HubDocs configuration#5
mberrishdev merged 1 commit into
mainfrom
feature/add-options

Conversation

@mberrishdev
Copy link
Copy Markdown
Owner

@mberrishdev mberrishdev commented Apr 19, 2026

Note

Medium Risk
Changes the shape of GET /hubdocs/hubdocs.json from a hubs array to a structured document with protocol-style channels/components, which may be a breaking change for any consumers parsing the old JSON. Also touches JSON-schema generation and UI rendering for the new metadata block.

Overview
HubDocs now supports Swagger-like document metadata and returns a richer protocol document. AddHubDocs gains an overload accepting Action<HubDocsDocumentOptions> so callers can set title/version/description/links/contact/license, and hubdocs.json now returns a top-level document containing hubdocs metadata plus hubs, channels, and components (messages/schemas) instead of returning hubs alone.

The embedded UI (hubdocs.html) is updated to read the new document shape, render the metadata header section, and remain backward-compatible by falling back if the response is still an array. Samples/docs are updated to demonstrate the new options, a unit test validates BuildHubDocsDocument, and the package version is bumped to 0.0.9.

Reviewed by Cursor Bugbot for commit 98d15e6. Bugbot is set up for automated code reviews on this repo. Configure here.

@mberrishdev mberrishdev merged commit f4fb285 into main Apr 19, 2026
3 checks passed
@mberrishdev mberrishdev deleted the feature/add-options branch April 19, 2026 18:31
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 98d15e6. Configure here.

.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HTML escape function missing double-quote escaping

Medium Severity

The esc function escapes &, <, and > but does not escape double quotes ("). Values processed by esc are then interpolated directly inside double-quoted HTML attributes (e.g., href="${esc(meta.projectUrl)}"). A value containing " can break out of the attribute context and inject arbitrary HTML attributes, including event handlers, resulting in a potential XSS vector.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98d15e6. Configure here.

Comment thread src/HubDocs/Extensions.cs
var properties = new Dictionary<string, object?>();
foreach (var property in schema.Properties ?? [])
{
properties[property.Name] = BuildJsonSchemaForType(property.Type, [], property.Example, property.IsNullable);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Schema property references lost due to empty known schemas

Medium Severity

ConvertHubSchemaToProtocolSchema passes an empty collection [] as the knownSchemas argument to BuildJsonSchemaForType. This means schema properties whose types match other known schemas will never generate a $ref reference — they'll fall through to MapPrimitiveJsonSchema and be incorrectly mapped as "type": "string". The method-level code correctly passes schemas.Keys, so this is inconsistent.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98d15e6. Configure here.

</div>

<div id="api-links" class="mt-4 text-sm text-gray-300 space-y-1"></div>
</section>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

API info section misplaced inside horizontal flex container

Medium Severity

The api-info <section> is placed inside the <div class="flex items-center gap-4"> that contains the SVG icon and "HubDocs" title. When unhidden, this large block (with its own title, version badge, description, and links) renders inline horizontally alongside the logo, breaking the header layout. It likely belongs outside this flex container.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98d15e6. Configure here.

Comment thread src/HubDocs/Extensions.cs
listSchema["nullable"] = true;

return listSchema;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type schema missing Task wrapper unwrapping

Medium Severity

BuildJsonSchemaForType handles List<T> unwrapping (mapping it to an array schema) but has no equivalent handling for Task<T>. Since FormatMethodReturnType produces strings like "Task<MessageDto>" for async hub methods, the generic fallback at line 651 extracts "Task" as the schema name, fails to match any known schema, and MapPrimitiveJsonSchema maps the entire string to {"type": "string"}. Any hub method returning Task<int>, Task<MyDto>, etc. will have its return type incorrectly represented in the protocol document.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 98d15e6. Configure here.

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.

1 participant