Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for copy constructors to Microsoft.OpenApi.Models objects #832

Closed
captainsafia opened this issue Apr 18, 2022 · 0 comments · Fixed by #853
Closed

Add support for copy constructors to Microsoft.OpenApi.Models objects #832

captainsafia opened this issue Apr 18, 2022 · 0 comments · Fixed by #853
Assignees
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days type:enhancement Enhancement request targeting an existing experience
Milestone

Comments

@captainsafia
Copy link
Member

As outlined in dotnet/aspnetcore#40676 and implemented in dotnet/aspnetcore#41238, we're introducing support for a new Microsoft.AspNetCore.OpenApi package that acts as a link between Microsoft.OpenApi and route handler endpoints.

This package exposes a WithOpenApi extension method that users can invoke on their endpoints to mutate the OpenApiOperation that we generate by default from the handler's MethodInfo with their own annotation. For example,

app.MapGet("/foo", () => {})
.WithOpenApi(generatedOperation => {
  generatedOperation.OperationId = "MadeByMe";
  return generatedOperation;
});

One of the things we thought would be compelling was support for a copy constructor for OpenApiOperation so that users can invoke the following and have their modification automatically merged into the generated operation.

app.MapGet("/foo", () => {})
.WithOpenApi(generatedOperation => new(generatedOperation) {
  OperationId = "MadeByMe"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p1 High priority but not blocking. Causes major but not critical loss of functionality SLA <=7days type:enhancement Enhancement request targeting an existing experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants