question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Obsolote warnings when upgrading from v11 to v12

See original GitHub issue

Hello,

I had this piece of code:

app.UseSwaggerUi3(
   typeof(ControllerBase).GetAllAssignable()
   , (settings) =>
      {
         settings.GeneratorSettings.DefaultEnumHandling = NJsonSchema.EnumHandling.String;
	 settings.GeneratorSettings.Title = "XYZ API v1";
	 settings.GeneratorSettings.Version = "1.0";
	 settings.GeneratorSettings.DefaultPropertyNameHandling = NJsonSchema.PropertyNameHandling.CamelCase;
      }
   , new NSwag.SwaggerGeneration.SwaggerJsonSchemaGenerator(new NJsonSchema.Generation.JsonSchemaGeneratorSettings())
);

Now I am getting obsolote warning on settings.GeneratorSettings.DefaultEnumHandling and settings.GeneratorSettings.DefaultPropertyNameHandling. But the warning message makes no sense to me.

Severity Code Description Project File Line Suppression State Warning CS0618 ‘JsonSchemaGeneratorSettings.DefaultEnumHandling’ is obsolete: ‘Use SerializerSettings directly instead. In NSwag.AspNetCore the property is set automatically.’ ClientService

Please provide an example.

.Net Framework 4.7 NSwag.SwaggerGeneration.WebApi: 12.0.5.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
RicoSutercommented, Dec 10, 2018

It should look like this:

app.UseSwaggerUi3(typeof(ControllerBase).GetAllAssignable(), settings =>
    {
        settings.GeneratorSettings.Title = "XYZ API v1";
        settings.GeneratorSettings.Version = "1.0";

        settings.GeneratorSettings.SerializerSettings = new JsonSerializerSettings()
        {
            ContractResolver = new CamelCasePropertyNamesContractResolver();
            Converters = { new StringEnumConverter() }
        }
    }, 
    new NSwag.SwaggerGeneration.SwaggerJsonSchemaGenerator(new NJsonSchema.Generation.JsonSchemaGeneratorSettings())
);

or just assign the settings from ASP.NET so that the configs match…

0reactions
pravinkarthycommented, Apr 28, 2021

Hi @RicoSuter I am using .Net Framework 4.7, NSwag.Generation.WebApi v 13.10.8 to have swagger in OWIN based WebApi. I want to have Exception type as camelcased and got the actual response as camelCase but Swagger documentation is still having PascalCase only for Exception object despite having the following setting with IgnoreSerializableInterface enabled.

appBuilder.UseSwaggerUi3(typeof(Startup).Assembly, settings =>
            {
                settings.GeneratorSettings.DefaultUrlTemplate = "api/{controller}/{action}/{id}";
                settings.DocumentTitle = "Internal Service APIs"; // there is an open issue in the library for OWIN that does not set the title in generated UI. Works in .net core
                settings.GeneratorSettings.SerializerSettings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver
                    {
                        IgnoreSerializableInterface = true
                    },
                    Converters = {new StringEnumConverter()}
                };
            });

Please advise if there is any other setting to be added. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Obsolote warnings when upgrading from v11 to v12
Hello,. I had this piece of code: app.UseSwaggerUi3( typeof(ControllerBase).GetAllAssignable() , (settings) => { settings.GeneratorSettings.
Read more >
Updating from v11 to v12 | Discord.js Guide
Once you got Node up-to-date, you can install v12 by running npm install ... WARNING. clientOptions.disableEveryone was removed and replaced ...
Read more >
V12 Upgrade failure: service missing on host
I've tried to edit, then rescan servers, and encountered the warning: one or more veeam components is not up to date. Skipping host....
Read more >
[V12] System Requirements for our 2022 release - Page 3
When we upgraded to v10, we encountered a number of issues that didn't exist in 9.5. After bouncing around with Veeam support, the...
Read more >
Migration failed: Incompatible peer dependencies found - ...
I can choose to use the --force option to ignore incompatible peer dependencies and address these warnings later.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found