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

UnboundOperation string param swagger error #766

Open
itlizhi opened this issue Oct 22, 2024 · 0 comments
Open

UnboundOperation string param swagger error #766

itlizhi opened this issue Oct 22, 2024 · 0 comments

Comments

@itlizhi
Copy link

itlizhi commented Oct 22, 2024

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)

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

No branches or pull requests

1 participant