6.3.0 System.ArgumentException: Literal sections cannot contain the '?' character.
See original GitHub issueHi,
Recently updated from 6.2.1 to 6.3.0 and stuff started breaking. I’m running an OData controller via aspnet-api-versioning
Any endpoint within an OData controller with manually defined query parameters results in
System.ArgumentException: The literal section 'QuantityUnits?onlyValid=' is invalid. Literal sections cannot contain the '?' character. (Parameter 'routeTemplate')
Controller and endpoint:
namespace WebApi.V1.CodeLists;
[ODataRoutePrefix("QuantityUnits")]
public class QuantityUnitsController : BaseODataController {
[EnableQuery]
[ProducesResponseType(typeof(ODataListWrapper<IQueryable<QuantityUnitOutput>>), Status200OK)]
public async Task<IQueryable<QuantityUnitOutput>> Get(bool onlyValid = true) => ...
}
This works in 6.2.1. In 6.2.3 I observed that the swagger.json generation works, but the endpoint produced has a trailing {, e.g. /api/v1/odata/QuantityUnits{ which of course doesn’t really work.
Any idea where to start digging?
Full stack trace:
[14:07:26 INF] Request starting HTTP/2 GET https://localhost:44395/swagger/v1/swagger.json - -
[14:07:26 ERR] An unhandled exception has occurred while executing the request.
System.ArgumentException: The literal section 'QuantityUnits?onlyValid=' is invalid. Literal sections cannot contain the '?' character. (Parameter 'routeTemplate')
---> Microsoft.AspNetCore.Routing.Patterns.RoutePatternException: The literal section 'QuantityUnits?onlyValid=' is invalid. Literal sections cannot contain the '?' character.
at Microsoft.AspNetCore.Routing.Patterns.RoutePatternParser.Parse(String pattern)
at Microsoft.AspNetCore.Routing.Patterns.RoutePatternFactory.Parse(String pattern)
at Microsoft.AspNetCore.Routing.Template.TemplateParser.Parse(String routeTemplate)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Routing.Template.TemplateParser.Parse(String routeTemplate)
at Swashbuckle.AspNetCore.SwaggerGen.ApiDescriptionExtensions.RelativePathSansParameterConstraints(ApiDescription apiDescription)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.<>c.<GeneratePaths>b__6_0(ApiDescription apiDesc)
at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`2.GetEnumerator()
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Hellang.Middleware.ProblemDetails.ProblemDetailsMiddleware.Invoke(HttpContext context)
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How do I use query parameters in attributes?
RoutePatternException: The literal section '?amount=' is invalid. Literal sections cannot contain the '?' character. at Microsoft.
Read more >MySQL Connector/NET Release Notes
This document contains release notes for the changes in each release of MySQL Connector/NET. ... Changes in MySQL Connector/NET 6.3.0 (2010-02-16, Alpha) ....
Read more >Untitled
Redirect URI cannot contain newline characters - CodeProject Web17. ... 6.3.0 System.ArgumentException: Literal sections cannot contain ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still broken! Cannot define a route with
[Route("api/test?id={var}")]Work-around:
Swashbuckle.AspNetCore.6.4.0-preview-2078.zip