The AddComponent API currently returns a boolean that indicates if the addition of the component to the document registry succeeded.
It would be nice if the API returned a reference to the item that was just constructed. In an M.A.OpenAPI transformer, I currently need to write:
options.AddOperationTransformer((operation,context,cancellationToken)=>{varschemaService=context.ApplicationServices.GetRequiredKeyedService<IOpenApiSchemaService>(context.DocumentName);if(context.Description.RelativePath=="error"){varerrorSchema=schemaService.GetOrCreateSchema(typeof(ProblemDetails));context.Document.AddComponent("Error",errorSchema);operation.Responses["500"]=newOpenApiResponse{Description="Error",Content={["application/problem+json"]=newOpenApiMediaType{Schema=newOpenApiSchemaReference("Error",context.Document),},},};}returnTask.CompletedTask;});but would like to write:
options.AddOperationTransformer((operation,context,cancellationToken)=>{varschemaService=context.ApplicationServices.GetRequiredKeyedService<IOpenApiSchemaService>(context.DocumentName);if(context.Description.RelativePath=="error"){varerrorSchema=schemaService.GetOrCreateSchema(typeof(ProblemDetails));varinsertedSchema=context.Document.AddComponent("Error",errorSchema);operation.Responses["500"]=newOpenApiResponse{Description="Error",Content={["application/problem+json"]=newOpenApiMediaType{Schema=insertedSchema,},},};}returnTask.CompletedTask;});cc: Vincent Biret (@baywet) I couldn't see if an API that did this existed already and figured I'd add the proposal.
The
AddComponentAPI currently returns a boolean that indicates if the addition of the component to the document registry succeeded.It would be nice if the API returned a reference to the item that was just constructed. In an M.A.OpenAPI transformer, I currently need to write:
but would like to write:
cc: Vincent Biret (@baywet) I couldn't see if an API that did this existed already and figured I'd add the proposal.