Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated DTOs shouldn't hide base class properties #1568

Open
Vivelin opened this issue Aug 30, 2018 · 2 comments
Open

Generated DTOs shouldn't hide base class properties #1568

Vivelin opened this issue Aug 30, 2018 · 2 comments

Comments

@Vivelin
Copy link

Vivelin commented Aug 30, 2018

I have a Swagger document that contains schemas that use allOf to include the base class schema (I used Swashbuckle.AspNetCore.Polymorphism):

  "allOf": [
    {
      "$ref": "#/definitions/<BaseClass>"
    },
    {
      "type": "object",
      "properties": {

While I cannot get a proper example right now, the base class properties are included in both the base class schema and the actual schema.

While Swagger UI handles duplicate properties just fine, NSwag does not. Using Poco for generated DTOs, this results in properties that hide the inherited properties, which causes the base class properties to be null. I tried using Record instead, but the generated constructor contains duplicate parameters, causing compilation errors.

I resolved my issue by filtering out the duplicate properties while generating the Swagger document, but I think NSwag could improve on this area as well. I'm not too familiar with the intricacies of Swagger so I don't know what would be most appropriate, but I suggest simply skipping properties declared in the base class.

@RicoSuter
Copy link
Owner

I think/hope this is fixed with this PR: RicoSuter/NJsonSchema#733

@RicoSuter
Copy link
Owner

Update: Ready for retest in next nswag release (with updated NJS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants