-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -169,6 +169,19 @@ public void GenerateSchema_GeneratesReferencedDictionarySchema_IfDictionaryTypeI | |||
Assert.Equal(expectedItemsFormat, schema.Items.Format); | |||
} | |||
|
|||
[Theory] | |||
[InlineData(typeof(List<BadHttpRequestException>), typeof(BadHttpRequestException))] |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🤓.
Hi @Daissy538, checking in to see if this is ready for review. I'm catching up on this PR. Let me know, thank you. |
Hey @mesMess, |
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. |
Ey, I have a question. |
If the change is intentional (i.e. it's not a bug), then yes it's ok to update those files. |
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. |
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.