Swagger knowledge points record

First, the need to build .NET CORE API project

Two, startup class needs to be added as follows:

 

            Swagger #region
            app.UseSwagger ();
            app.UseSwaggerUI (c =>
            {
                before // is written dead
                //c.SwaggerEndpoint("/swagger/v1/swagger.json "," ApiHelp V1 ");
                // c .RoutePrefix = ""; // path configuration, to blank, directly under the root domain (localhost: 8001) to access the file, note localhost: 8001 / swagger is not accessible, and to remove launchSettings.json the launchUrl

                @ The reverse traversal shows the version name
                typeof (ApiVersions) .GetEnumNames (). OrderByDescending (E => E) .ToList (). the ForEach (version =>
                {
                    c.SwaggerEndpoint ($ "/ Swagger / {version} /swagger.json" , $ "} {apiName {Version}");
                });
            });
            #endregion

1, there are several points to note here is the need for custom classes and references nuget of:

ApiVersions (custom version of the class) is mainly used for version management

ApiName (custom project name of the class)

 

 

Guess you like

Origin www.cnblogs.com/waxyy/p/11822087.html