Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Models/OpenApiOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
public IOpenApiRequestBody? RequestBody { get; set; }

/// <summary>
/// REQUIRED. The list of possible responses as they are returned from executing this operation.
/// The list of possible responses as they are returned from executing this operation.
/// </summary>
public OpenApiResponses? Responses { get; set; } = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about

writer.WriteRequiredObject(OpenApiConstants.Responses, Responses, callback);

writer.WriteRequiredObject(OpenApiConstants.Responses, Responses, (w, r) => r.SerializeAsV2(w));

Should they be using WriteOptionalObject instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ahh, here is another clue, it used to be required in v2, as well as v3, but was relaxed in 3.1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And no, we shouldn't change this. The specification requires the property to be present with a non null value. WriteRequiredObject will write an empty object if the value is null. ({})


Expand Down Expand Up @@ -226,7 +226,7 @@
/// <summary>
/// Serialize <see cref="OpenApiOperation"/> to Open Api v2.0.
/// </summary>
public virtual void SerializeAsV2(IOpenApiWriter writer)

Check warning on line 229 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 28 to the 15 allowed.

Check warning on line 229 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 28 to the 15 allowed.

Check warning on line 229 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 28 to the 15 allowed.
{
Utils.CheckArgumentNull(writer);

Expand Down Expand Up @@ -336,7 +336,7 @@

writer.WriteOptionalCollection(OpenApiConstants.Schemes, schemes, (w, s) =>
{
if (!string.IsNullOrEmpty(s) && s is not null)

Check warning on line 339 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this condition so that it does not always evaluate to 'True'.

Check warning on line 339 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this condition so that it does not always evaluate to 'True'.

Check warning on line 339 in src/Microsoft.OpenApi/Models/OpenApiOperation.cs

View workflow job for this annotation

GitHub Actions / Build

Change this condition so that it does not always evaluate to 'True'.
{
w.WriteValue(s);
}
Expand Down
Loading