Skip to content

UnboundOperation string param swagger error #766

@itlizhi

Description

@itlizhi

Short summary (3-5 sentences) describing the issue.

Assemblies affected

V1.1.1

Reproduce steps

Clone project Modify Microsoft.Restier.Samples.Northwind.AspNetCore GetFirstCategory add (string code)

    [UnboundOperation]
    public Category GetFirstCategory(string code)
    {
        var claimsPrincipal = ClaimsPrincipal.Current;
        Console.WriteLine($"ClaimsPrincipal Logged In: {claimsPrincipal.Identity.IsAuthenticated}");
        return DbContext.Categories.FirstOrDefault();
    }

open swagger throw error

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.EdmPrimitiveTypeReference' to type 'Microsoft.OData.Edm.IEdmStringTypeReference'.
at Microsoft.OpenApi.OData.Generator.OpenApiEdmTypeSchemaGenerator.CreateSchema(ODataContext context, IEdmPrimitiveTypeReference primitiveType)
at Microsoft.OpenApi.OData.Generator.OpenApiEdmTypeSchemaGenerator.CreateEdmTypeSchema(ODataContext context, IEdmTypeReference edmTypeReference)
at Microsoft.OpenApi.OData.Generator.OpenApiParameterGenerator.CreateParameters(ODataContext context, IEdmFunction function, IDictionary`2 parameterNameMapping)
at Microsoft.OpenApi.OData.Generator.OpenApiParameterGenerator.CreateParameters(ODataContext context, IEdmFunctionImport functionImport)
at Microsoft.OpenApi.OData.Operation.EdmFunctionImportOperationHandler.SetParameters(OpenApiOperation operation)
at Microsoft.OpenApi.OData.Operation.OperationHandler.CreateOperation(ODataContext context, ODataPath path)
at Microsoft.OpenApi.OData.PathItem.PathItemHandler.AddOperation(OpenApiPathItem item, OperationType operationType)
at Microsoft.OpenApi.OData.PathItem.OperationImportPathItemHandler.SetOperations(OpenApiPathItem item)
at Microsoft.OpenApi.OData.PathItem.PathItemHandler.CreatePathItem(ODataContext context, ODataPath path)
at Microsoft.OpenApi.OData.Generator.OpenApiPathItemGenerator.CreatePathItems(ODataContext context)
at Microsoft.OpenApi.OData.Generator.OpenApiPathsGenerator.CreatePaths(ODataContext context)
at Microsoft.OpenApi.OData.Generator.OpenApiDocumentGenerator.CreateDocument(ODataContext context)
at Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi(IEdmModel model, OpenApiConvertSettings settings)
at Microsoft.Restier.AspNetCore.Swagger.RestierSwaggerProvider.GetSwagger(String documentName, String host, String basePath) in D:\github\dotnet_start\RESTier\src\Microsoft.Restier.AspNetCore.Swagger\RestierSwaggerProvider.cs:line 73
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.Restier.AspNetCore.Middleware.RestierClaimsPrincipalMiddleware.InvokeAsync(HttpContext httpContext, IHttpContextAccessor contextAccessor) in D:\github\dotnet_start\RESTier\src\Microsoft.Restier.AspNetCore\Middleware\RestierClaimsPrincipalMiddleware.cs:line 51
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.Restier.AspNetCore.Middleware.ODataBatchHttpContextFixerMiddleware.InvokeAsync(HttpContext httpContext, IHttpContextAccessor contextAccessor) in D:\github\dotnet_start\RESTier\src\Microsoft.Restier.AspNetCore\Middleware\ODataBatchHttpContextFixerMiddleware.cs:line 49
at Microsoft.AspNet.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions