Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

This foreach loop [implicitly filters its target sequence](1) - consider filtering the sequence explicitly using '.Where(...)'.
@commonsensesoftware commonsensesoftware merged commit 42607c5 into main Mar 26, 2024
@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