-
Notifications
You must be signed in to change notification settings - Fork 279
Closed
Description
Describe the bug
OpenApiOperation copy constructor: public OpenApiOperation(OpenApiOperation operation) changes a null in the RequestBody into an object instance.
To Reproduce
var operation = new OpenApiOperation();
//operation.RequestBody = null is the default
var copiedOperation = new OpenApiOperation(operation);copiedOperation.RequestBody is an new OpenApiRequestBody.
Expected behavior
copiedOperation.RequestBody should also be null, as on the source object.
OpenAPI.NET/src/Microsoft.OpenApi/Models/OpenApiOperation.cs
Lines 117 to 132 in db02b95
| public OpenApiOperation(OpenApiOperation operation) | |
| { | |
| Tags = new List<OpenApiTag>(operation?.Tags); | |
| Summary = operation?.Summary ?? Summary; | |
| Description = operation?.Description ?? Description; | |
| ExternalDocs = operation?.ExternalDocs != null ? new(operation?.ExternalDocs) : null; | |
| OperationId = operation?.OperationId ?? OperationId; | |
| Parameters = operation?.Parameters != null ? new List<OpenApiParameter>(operation.Parameters) : null; | |
| RequestBody = new(operation?.RequestBody); | |
| Responses = operation?.Responses != null ? new(operation?.Responses) : null; | |
| Callbacks = operation?.Callbacks != null ? new Dictionary<string, OpenApiCallback>(operation.Callbacks) : null; | |
| Deprecated = operation?.Deprecated ?? Deprecated; | |
| Security = operation?.Security != null ? new List<OpenApiSecurityRequirement>(operation.Security) : null; | |
| Servers = operation?.Servers != null ? new List<OpenApiServer>(operation.Servers) : null; | |
| Extensions = operation?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(operation.Extensions) : null; | |
| } |
I could provide a PR to fix this.
p-m-j
Metadata
Metadata
Assignees
Labels
No labels