Cannot find type name in schema definitions

I started using Swashbuckle with a web API. None of my types display correctly in my Swagger interface. For each method, I see something like this (unrendered):

<span class="strong">Typename is not defined!</span> 

So, I researched and found this in my Swagger description file for many of my methods:

 {$ref: "#/definitions/Typename", vendorExtensions: {}} 

typeName exists in the list of definitions ... but at the bottom. They all have a lower case, but all $ref are uppercase.

How to fix it?

Editing Bounty: More information is available on request, I'm just not sure what else may be relevant.

 [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] public class SwaggerConfig { public static void Register() { var thisAssembly = typeof(SwaggerConfig).Assembly; GlobalConfiguration.Configuration .EnableSwagger(c => { c.SingleApiVersion("v1", "MyNamespace.Api"); c.IncludeXmlComments(Path.Combine( AppDomain.CurrentDomain.GetDataDirectoryPath(), "MyNamespace.Api.XML")); }) .EnableSwaggerUi(); } } 
+5
source share
2 answers

I realized this almost by accident. For reasons that I still don't understand, I need my type names to start with a lowercase letter when no one else seems.

 c.SchemaId(type => { var name = type.Name; name = $"{ name.Substring(0,1).ToLower() }{ name.Substring(1) }"; }); 
+1
source

Check project settings. It looks like your path may be wrong. Below are the settings I'm using.

 ...swaggerDocsConfig.IncludeXmlComments(GetXmlCommentsPath()); 

and

 /// <summary> /// This is where the generated XML meta documentation are stored. /// Editable in project settings /// </summary> private static string GetXmlCommentsPath() { return string.Format(@"{0}\bin\MrGreen.Game.Service.XML", AppDomain.CurrentDomain.BaseDirectory); } 

enter image description here

0
source

Source: https://habr.com/ru/post/1265505/


All Articles