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

Fixes #2716: XML response example for Arrays #2896

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Daissy538
Copy link

Pull Request

The issue or feature being addressed

This is a fix for issue #2716.
There was no XML example for array response types.

Details on the issue fix or feature implementation

I added extra XML contacts as suggested by Swagger UI
This is needed for Swagger UI to build up the XML array example.

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.89%. Comparing base (d793865) to head (5225318).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2896      +/-   ##
==========================================
+ Coverage   89.87%   89.89%   +0.01%     
==========================================
  Files          72       72              
  Lines        2706     2711       +5     
  Branches      428      428              
==========================================
+ Hits         2432     2437       +5     
  Misses        274      274              
Flag Coverage Δ
Linux 89.89% <100.00%> (+0.01%) ⬆️
Windows 89.89% <100.00%> (+0.01%) ⬆️
macOS ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -169,6 +169,19 @@ public void GenerateSchema_GeneratesReferencedDictionarySchema_IfDictionaryTypeI
Assert.Equal(expectedItemsFormat, schema.Items.Format);
}

[Theory]
[InlineData(typeof(List<BadHttpRequestException>), typeof(BadHttpRequestException))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you also add test cases for IList<T> and ICollection<T> please?

{
var schema = Subject().GenerateSchema(type, new SchemaRepository());

Assert.True(schema.Xml.Wrapped);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you also assert schema.Xml is not null?

@@ -321,7 +321,12 @@ private OpenApiSchema CreateArraySchema(DataContract dataContract, SchemaReposit
{
Type = "array",
Items = GenerateSchema(dataContract.ArrayItemType, schemaRepository),
UniqueItems = hasUniqueItems ? (bool?)true : null
UniqueItems = hasUniqueItems ? (bool?)true : null,
Xml = new OpenApiXml()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having familiarised myself with the original issue, I think while these might be reasonable defaults to assume, they might not match how the response is actually returned to the user.

I think we're missing a way for the user to customise these or we should infer them from attributes on the type.

It's been a while since I did some XML serialization, but there should be some attributes that can be used to influence how objects are serialised (say to use camelCase not PascalCase) and we should respect those if the user's model uses them.

Similarly there should be a way to wrap the elements, or not.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I'm going to investigate it 🤓.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants