Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Incorrectly generated metadata for arrays in Swagger for .NET Core with OData #999

Copy link
Copy link
Closed
@DimaMegaMan

Description

@DimaMegaMan
Issue body actions

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

It seems like in the current version issue #496 appears again
Generated request GET: https://localhost:5001/api/CountThem(Vars=%271%27,%272%27,%273%27) (Square brackets are missing)

Expected Behavior

Expected GET: https://localhost:5001/api/CountThem(Vars=[%271%27,%272%27,%273%27])

Steps To Reproduce

Repro steps using ODataOpenApiExample:

Add this code to the functions controller

    [HttpGet( "api/" + nameof( CountThem ) + "(Vars={vars})" )]
    [ProducesResponseType( typeof( int ), Status200OK )]
    public IActionResult CountThem( string[] vars ) => Ok( vars.Length );

And this line to AllConfigurations class

        builder.Function( nameof( FunctionsController.CountThem ) ).Returns<int>().CollectionParameter<string>( "vars" );

Run Swagger
Add multiple parameters line by line e.g. '1' '2' '3'
Press Execute

Exceptions (if any)

 ---> Microsoft.OData.ODataException: Type verification failed. Expected type 'Collection(Edm.String)' but received the value ''1','2','3''.
   at Microsoft.OData.ODataUriConversionUtils.VerifyAndCoerceUriPrimitiveLiteral(Object primitiveValue, String literalValue, IEdmModel model, IEdmTypeReference expectedTypeReference)
   at Microsoft.OData.ODataUriUtils.ConvertFromUriLiteral(String value, ODataVersion version, IEdmModel model, IEdmTypeReference typeReference)
   at Microsoft.AspNetCore.OData.Routing.Template.SegmentTemplateHelpers.Match(ODataTemplateTranslateContext context, IEdmFunction function, IDictionary`2 parameterMappings)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.OData.Routing.Template.SegmentTemplateHelpers.Match(ODataTemplateTranslateContext context, IEdmFunction function, IDictionary`2 parameterMappings)
   at Microsoft.AspNetCore.OData.Routing.Template.FunctionImportSegmentTemplate.TryTranslate(ODataTemplateTranslateContext context)
   at Asp.Versioning.OData.VersionedODataTemplateTranslator.Translate(ODataPathTemplate path, ODataTemplateTranslateContext context) in C:\Users\user\Source\Repos\aspnet-api-versioning\src\AspNetCore\OData\src\Asp.Versioning.OData\OData\VersionedODataTemplateTranslator.cs:line 53
   at Microsoft.AspNetCore.OData.Routing.ODataRoutingMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

.NET Version

7

Anything else?

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.