-
Notifications
You must be signed in to change notification settings - Fork 25k
Open
Labels
Source - Docs.msDocs Customer feedback via GitHub IssueDocs Customer feedback via GitHub Issueai-triage-action-planAssigned when an AI generated triage and action plan report is created for an issue.Assigned when an AI generated triage and action plan report is created for an issue.aspnet-core/svcfundamentals/subsvc
Description
Description
Many properties of OpenApi.NET objects provided to the transformers are interfaces that have get-only properties. It's not clear from documentation, how should the transformer be written to modify a get-only property. It does work with casting, but that seems like rather unclean solution.
Example: I want to set an Example property of a parameters
public Task TransformAsync(OpenApiOperation operation, OpenApiOperationTransformerContext context, CancellationToken cancellationToken)
{
foreach (var parameter in operation.Parameters ?? [])
{
if (parameter.Name == "sort")
{
// parameter is a IOpenApiParameter. The Example property is get-only and can't be set. To set it, I cast it to a concrete type that has a setter.
// The IOpenApiParameterinterface can be
// * OpenApiParameter (further subclassed to OpenApiBodyParameter / OpenApiFormDataParameter)
// * or OpenApiParameterReference
((OpenApiParameter)parameter).Example = "something";
}
}
return Task.CompletedTask;
}Page URL
Content source URL
Document ID
ea5fce3c-e38f-9531-b77a-3e9a5e8e30ce
Platform Id
126b754a-260a-3efc-a261-b0d72ad0d8ce
Article author
Metadata
- ID: ea5fce3c-e38f-9531-b77a-3e9a5e8e30ce
- PlatformId: 126b754a-260a-3efc-a261-b0d72ad0d8ce
- Service: aspnet-core
- Sub-service: fundamentals
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Source - Docs.msDocs Customer feedback via GitHub IssueDocs Customer feedback via GitHub Issueai-triage-action-planAssigned when an AI generated triage and action plan report is created for an issue.Assigned when an AI generated triage and action plan report is created for an issue.aspnet-core/svcfundamentals/subsvc