Add module-specific OpenAPI documents - #5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d698e77a7b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $"Configuration section '{moduleSection.Path}' is required."); | ||
| } | ||
|
|
||
| var name = GetRequiredValue(moduleSection, nameof(HttpModule.Name)); |
There was a problem hiding this comment.
Reject document names that cannot form route segments
When a configured Name contains / (for example, sales/v1), it passes the whitespace-only validation and is registered as an OpenAPI document, but MapOpenApi exposes only the single-segment route /openapi/{documentName}.json. Consequently, /openapi/sales/v1.json cannot resolve that document, leaving both direct access and its Scalar source unusable; validate module names as safe route-segment values before registration.
Useful? React with 👍 / 👎.
What changed
NameandTitlefromHttpModulesconfiguration keyed by the assembly simple name.HttpModuleandHttpModuleRegistryinternal underModularity: the module is resolved endpoint metadata, while the registry validates and indexes it by assembly.modules.Select(static module => module.Name)./openapi/v1.jsonbehavior when no module assemblies are registered.Asp.Versioning.HttpandAsp.Versioning.OpenApito10.0.1,Microsoft.AspNetCore.OpenApito10.0.10, and both Scalar packages to2.16.17.2.0-previewto stable2.0and updated the README package reference to2.0.0.Why
Applications composed from multiple presentation modules need focused OpenAPI documents without coupling document grouping to API versions. Assemblies remain type-safe code references, while document identifiers and UI titles can now vary by environment without recompilation.
Usage
{ "HttpModules": { "PANiXiDA.TacticalHeroes.Identity.Presentation": { "Name": "identity", "Title": "Identity API" }, "PANiXiDA.TacticalHeroes.Compendium.Presentation": { "Name": "compendium", "Title": "Compendium API" } } }Each
HttpModuleskey must equalAssembly.GetName().Name.NameandTitleare required for every registered assembly.Local verification
Result: Release build succeeded with no warnings, all 70 tests passed, Cobertura coverage is 100% for lines (555/555) and branches (151/151), package creation succeeded, and no vulnerable or prerelease dependencies were reported.
Compatibility
HttpModulessection.HttpModuleoverload is replaced byAddHttp(IConfiguration, params Assembly[]);HttpModuleis now internal.2.0-previewline to stable2.0.AddHttp(configuration)and combinedv1behavior remain unchanged.