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 3 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

@martincostello martincostello May 15, 2024

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 🤓.

@mesMess
Copy link
Collaborator

mesMess commented Jul 4, 2024

Hi @Daissy538, checking in to see if this is ready for review. I'm catching up on this PR. Let me know, thank you.

@Daissy538
Copy link
Author

Hey @mesMess,
I didn't found time yet to look into the the feedback 😅. So the pr stranded a bit from my side.

@mesMess
Copy link
Collaborator

mesMess commented Jul 4, 2024

Hey @mesMess, I didn't found time yet to look into the the feedback 😅. So the pr stranded a bit from my side.

Okay no worries. When you do find some time I'm here. If you want to let me know what your general thoughts are, time permitting, maybe we can finish it together. LMK.

@Daissy538
Copy link
Author

Ey, I have a question.
I saw that there are now integrations test for different type of applications.
Is it the idea that the files with the expected output should be changed, so it includes the correct XML list support?

@martincostello
Copy link
Collaborator

If the change is intentional (i.e. it's not a bug), then yes it's ok to update those files.

Copy link
Contributor

This pull request is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further changes are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants