-
Notifications
You must be signed in to change notification settings - Fork 11k
Fix ApiExplorer to include FromQuery(Name) prefix in parameter names #68344
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1624,11 +1624,33 @@ public void GetApiDescription_ParameterDescription_FromQueryEmployee() | |
| var description = Assert.Single(descriptions); | ||
| Assert.Single(description.ParameterDescriptions); | ||
|
|
||
| var id = Assert.Single(description.ParameterDescriptions, p => p.Name == "Name"); | ||
| var id = Assert.Single(description.ParameterDescriptions, p => p.Name == "employee.Name"); | ||
| Assert.Same(BindingSource.Query, id.Source); | ||
| Assert.Equal(typeof(string), id.Type); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GetApiDescription_ParameterDescription_FromQueryEmployee_WithCustomPropertyBindingNames() | ||
| { | ||
| // Arrange | ||
| var action = CreateActionDescriptor(nameof(AcceptsEmployeeWithCustomPropertyNames)); | ||
|
|
||
| // Act | ||
| var descriptions = GetApiDescriptions(action); | ||
|
|
||
| // Assert | ||
| var description = Assert.Single(descriptions); | ||
| Assert.Equal(2, description.ParameterDescriptions.Count); | ||
|
|
||
| var header = Assert.Single(description.ParameterDescriptions, p => p.Name == "X-MyCustomHeader"); | ||
| Assert.Same(BindingSource.Header, header.Source); | ||
| Assert.Equal(typeof(string), header.Type); | ||
|
|
||
| var route = Assert.Single(description.ParameterDescriptions, p => p.Name == "employee.employeeid"); | ||
| Assert.Same(BindingSource.Path, route.Source); | ||
| Assert.Equal(typeof(string), route.Type); | ||
|
Comment on lines
+1649
to
+1651
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here, but Path is a bit special as it relates to the placeholder in the template. Does this parameter bind correctly for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {employee.employeeid} binds; {employeeid} and {employee.employee.id} don't
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snemeckayova Thanks for confirming. So only headers are special here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's correct |
||
| } | ||
|
|
||
| [Fact] | ||
| public void GetApiDescription_ParameterDescription_ParsablePrimitiveType() | ||
| { | ||
|
|
@@ -2542,6 +2564,10 @@ private void AcceptsEmployee([FromQuery(Name = "employee")] Employee dto) | |
| { | ||
| } | ||
|
|
||
| private void AcceptsEmployeeWithCustomPropertyNames([FromQuery(Name = "employee")] EmployeeWithCustomPropertyNames dto) | ||
| { | ||
| } | ||
|
|
||
| private void AcceptsTryParsablePrimitiveType([FromQuery] Guid id) | ||
| { | ||
| } | ||
|
|
@@ -2695,6 +2721,15 @@ private class Employee | |
| public string Name { get; set; } | ||
| } | ||
|
|
||
| private class EmployeeWithCustomPropertyNames | ||
| { | ||
| [FromHeader(Name = "X-MyCustomHeader")] | ||
| public string HeaderName { get; set; } | ||
|
|
||
| [FromRoute(Name = "employeeid")] | ||
| public string EmployeeId { get; set; } | ||
| } | ||
|
|
||
| [TypeConverter(typeof(EmployeeConverter))] | ||
| private class ConvertibleEmployee | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
What happens if
Employeeclass had a property that had[FromHeader("X-MyCustomHeader")]?Are we prefixing this as well? And is it expected to be prefixed? Same question applies to
FromRouteIn addition, let's make sure we have equivalent tests for both Mvc and minimal API, including tests directed for OpenAPI
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.
If no scenario here is applicable for minimal API (e.g, an analyzer warning is produced), feel free to skip the minimal API part here.