Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Fixes #36433

The sample class DocumentService could be confused with the internal framework type OpenApiDocumentService. Renamed to CustomDocumentService to clearly indicate it's a user-defined sample class.

Before:

public class DocumentService
{
    public DocumentService(IOpenApiDocumentProvider documentProvider) { ... }
}

builder.Services.AddScoped<DocumentService>();

After:

public class CustomDocumentService
{
    public CustomDocumentService(IOpenApiDocumentProvider documentProvider) { ... }
}

builder.Services.AddScoped<CustomDocumentService>();
Original prompt

This section details on the original issue you should resolve

<issue_title>There's no DocumentService.</issue_title>
<issue_description>### Description

There's a suggestion to register the service builder.Services.AddScoped<DocumentService>();

However, in the referenced PR, we see

services.AddKeyedSingleton<IOpenApiDocumentProvider, OpenApiDocumentService>(documentName);

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/using-openapi-documents?view=aspnetcore-10.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/openapi/using-openapi-documents.md

Document ID

472b10ab-681b-f631-040d-025ef0a02329

Platform Id

c973de58-a013-4aa0-ccef-0bd78e4749db

Article author

@captainsafia

Metadata

  • ID: 472b10ab-681b-f631-040d-025ef0a02329
  • PlatformId: c973de58-a013-4aa0-ccef-0bd78e4749db
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues</issue_description>

<agent_instructions>Review both the issue summary and all information in the disucssion in including the AI Analysis Report</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@wadepickett ## AI Analysis Report **Analyzed by:** @copilot **Report run by: WadePickett** **Date:** 2025-12-04 **Issue:** #36433 **Model:** GitHub Copilot tested with Gemini 3 Pro Preview ---

Issue Analysis: Clarify usage of custom DocumentService in sample

✅ Issue Validation

Status: Valid and actionable
Reason: Clarification needed

📋 Issue Summary

The issue reporter notes a discrepancy between the documentation's instruction to register builder.Services.AddScoped<DocumentService>(); and the framework's internal registration of IOpenApiDocumentProvider.

The confusion arises because DocumentService is a user-defined sample class defined in the immediately preceding code block, not a built-in framework service. The user likely mistook it for a framework component or the internal implementation (OpenApiDocumentService).

To prevent this confusion, the sample class should be renamed to something more descriptive (e.g., CustomDocumentService) to clearly distinguish it from framework types.

📁 Affected Files

File Path Lines Section
Main article aspnetcore/fundamentals/openapi/using-openapi-documents.md 107-128 "Support for injecting IOpenApiDocumentProvider"

📝 Proposed Changes

Documentation Updates

File: aspnetcore/fundamentals/openapi/using-openapi-documents.md
Location: Lines 107-128
Type: Content Update (Renaming sample class for clarity)

Current content:

public class DocumentService
{
    private readonly IOpenApiDocumentProvider _documentProvider;

    public DocumentService(IOpenApiDocumentProvider documentProvider)
    {
        _documentProvider = documentProvider;
    }

    public async Task<OpenApiDocument> GetApiDocumentAsync()
    {
        return await _documentProvider.GetOpenApiDocumentAsync("v1");
    }
}</body></comment_new>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/openapi/using-openapi-documents.md aspnetcore/fundamentals/openapi/using-openapi-documents

Fixes #36433 - Clarifies that the sample class is a user-defined service
to prevent confusion with internal framework types like OpenApiDocumentService.

Co-authored-by: wadepickett <[email protected]>
Copilot AI changed the title [WIP] Add DocumentService registration to services Rename DocumentService to CustomDocumentService in sample code Dec 4, 2025
Copilot AI requested a review from wadepickett December 4, 2025 21:47
Copilot finished work on behalf of wadepickett December 4, 2025 21:47
@wadepickett wadepickett marked this pull request as ready for review December 4, 2025 21:58
@wadepickett wadepickett requested a review from Copilot December 4, 2025 21:58
Copilot finished reviewing on behalf of wadepickett December 4, 2025 21:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses confusion between a user-defined sample class and the ASP.NET Core framework's internal OpenApiDocumentService type by renaming the sample class from DocumentService to CustomDocumentService. This clarifies that the sample code demonstrates a custom implementation rather than a built-in framework service.

Key changes:

  • Renamed sample class DocumentService to CustomDocumentService in code examples
  • Updated service registration to use CustomDocumentService
  • Updated ms.date metadata to reflect the current date

@wadepickett wadepickett merged commit ae1ff95 into main Dec 5, 2025
10 checks passed
@wadepickett wadepickett deleted the copilot/add-document-service-registration branch December 5, 2025 17:55
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.

There's no DocumentService.

3 participants