RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.69k stars 1.24k forks source link

Explicit interface property not ignored since latest version #4710

Open b-nijhuis-innovadis opened 8 months ago

b-nijhuis-innovadis commented 8 months ago

We use constructions like:

IExample.cs

namespace Example;

public interface IExample
{
    DateTime? DateOfBirth { get; }
}

Example.cs

namespace Example;

public record Example(DateTime DateOfBirth) : IExample
{
    DateTime? IExample.DateOfBirth => DateOfBirth;
}

Since the latest version, this results in the property being added to the document, which is not what we want:

"Example": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "dateOfBirth"
      ],
      "properties": {
          "dateOfBirth": {
            "type": "string",
            "format": "date-time"
          },
          "example.IExample.DateOfBirth": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
}

The property is then added to the TypeScript client. How can we disable or workaround this?

b-nijhuis-innovadis commented 8 months ago

In the meantime, I use the [JsonSchemaIgnore] attribute on each property. Still hope there is (or will be) a better solution for this.

rammba commented 7 months ago

This can be related to the #4681.