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

Support OData Collection Parameters #1075

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

commonsensesoftware
Copy link
Collaborator

Support OData Collection Parameters

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

This PR adds support for OData collection parameters via the API Explorer for OData functions. The value format is unique to OData functions in the URL. OData actions can have collection parameters in the body as normal JSON arrays. The support only includes primitives, which includes enumerations. OData allows Complex Types, but that is not currently supported.

The issue of formatted or escaped string values cannot be solved. This is a limitation in OpenAPI. A user must input string values as 'text' or "text" unless the author provides some other extension to the Swagger UI to handle quoting of user input.

Comment on lines +497 to +506
foreach ( var parameter in function.Parameters )
{
if ( parameter.Type.IsCollection() &&
mapping.TryGetValue( parameter.Name, out name ) &&
parameters.SingleOrDefault( p => p.Name == name ) is { } param )
{
param.Source = BindingSource.Path;
break;
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.
@commonsensesoftware commonsensesoftware merged commit 42607c5 into main Mar 26, 2024
6 checks passed
@commonsensesoftware commonsensesoftware deleted the dev/css/odata-array-param branch March 26, 2024 02:23
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.

Incorrectly generated metadata for arrays in Swagger for .NET Core with OData
1 participant