0

One of my company's applications import packages that contain models that become responses from our API

using Newtonsoft.Json;
public class Foo 
{
    [JsonProperty("bar"]
    public string Bar { get; set;} 
}

We have for our own models migrated to System.Text.Json, which uses [JsonPropertyName("foobaz")]

Swagger picks up the correct formatting for our own models automatically, but not for the imported packages.

If we add AddSwaggerGenNewtonsoftSupport in program.cs, it picks it up for the imported models, but not for our models.

Is there any way to tell swagger to handle both?

dbc
  • 104,963
  • 20
  • 228
  • 340
Florin
  • 1
  • 1

1 Answers1

1

use both attributes

    [JsonProperty("bar"]
    [JsonPropertyName("foobaz")]
    public string Bar { get; set;} 
Serge
  • 40,935
  • 4
  • 18
  • 45