ContributionsMost RecentMost LikesSolutionsSwagger generating invalid OpenApi3 json I am trying to get our swagger schemas cleaned up so we can import them into an api management suite. My problem is swagger is generating invalid schemas. Take this definition [HttpGet] [ProducesResponseType(typeof(ListModel<CapacityConfigModel>), 200)] public async Task<IActionResult> Get([FromQuery] CapacityQueryModel CapacityQueryModel) This is valid because it works all over the place. My problem is when swagger gets to this in the swagger.json file, it generates json keys like this "Myapp.Models.ListModel`1[[Myapp.Models.CapacityConfigModel, Myapp, Version=2023.5.16.1345, Culture=neutral, PublicKeyToken=null]]": as the key definition, which creates references that look like this "responses": { "200": { "description": "Success", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Myapp.Models.ListModel`1[[Myapp.Models.CapacityConfigModel, CapacityConfigModel, Version=2023.5.16.1345, Culture=neutral, PublicKeyToken=null]]" } } } } } And my openAPI import and the swagger editor saying its wrong. It fails due to that key doesn't pass the regex test. The only thing thats seems to be common with all of them is the ListModel class, and i don't see anything wrong with it. public class ListModel<T> { /// <summary> /// Gets the model type. This always returns <see cref="ModelType.List" />.. /// </summary> public ModelType Model { get; } = ModelType.List; /// <summary> /// Gets or sets a continuation token that can be used to query the next page of results. /// </summary> public string ContinuationToken { get; set; } /// <summary> /// Gets or sets the actual list of results. /// </summary> public List<T> Data { get; set; } = new List<T>(); } its pretty basic. Which leads me to believe swagger doesn't like generics very much. Can anyone else see where my problem is? Using generics in response causing invalid swagger.json we are using the latest version of swashbuckle. I have this class public class ListModel<T> { public ModelType Model { get; } = ModelType.List; public string ContinuationToken { get; set; } public List<T> Data { get; set; } = new List<T>(); } We use this class all over the place in our 200 responses back to the javascript front end. We never had a problem before, everything on the application side works perfectly, has for a long time and still works. But, we are in the process of importing our services into an APIM and realized for the first time that for some reason, that class causes json key names to be invalid. Whenever we put that class into our http definition like this [HttpGet("VendorChangeTracking")] [ProducesResponseType(typeof(ListModel<VendorReportModel>), 200)] public async Task<IActionResult> GetFunStuffTracking(TrackingQueryModel trackingQueryModel) When swagger translates the ListModel<VendorReportModel> in the json to the schema, it generates a key name that looks like this "bla.bla.ListModel'1[[bla.bla.VendorReportModel, bla.CommonVendorProfileLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" which generates the error message Structural error at paths./api/v1/Foo/Bar.get.responses.200.content.application/json.schema.$ref should match format "uri-reference" format: uri-reference Jump to line 186 Semantic error at paths./api/v1/Foo/Bar.get.responses.200.content.application/json.schema.$ref $ref values must be RFC3986-compliant percent-encoded URIs Jump to line 186 we tried to drop the annotation, but, if the method is defined like this [HttpGet] [ServiceFilter(typeof(TransactionRequiredAttribute))] public async Task<ActionResult<ListModel<NoteModel>>> GetAsync([FromQuery]NoteQueryModel query) The response is the same. we have been working on this for days now and got nothing. Microsoft says its not a problem with Swashbuckle, but its a problem with Swagger, which they have no support options for. I have been stumped on this for 3 weeks. What do i need to do to fix this, i can't import anything because of the invalid json.