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

NSwag 14 - Swagger.json Tuple includes internal and private properties #4717

Open
jochenjonc opened this issue Jan 19, 2024 · 1 comment
Open

Comments

@jochenjonc
Copy link
Contributor

When trying to upgrade to NSwag 14 (on a dotnet 7 project) I noticed that the swagger.json and thus all code generated based on that specification includes internal and private properties on classes that are being used.

I have noticed that other people have reported similar things but as a solution added [JsonIgnore] to these properties. See #4681 and some comments on #4524.

But for some types that isn't a solution, for instance for a Tuple that is part of dotnet.

NSwag 13 generated the following for a Tuple:

  "TupleOfStringAndString": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "item1": {
        "type": "string"
      },
      "item2": {
        "type": "string"
      }
    }
  },

NSwag 14 includes 2 private properties:

"TupleOfStringAndString": {
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "item1": {
      "type": "string",
      "nullable": true
    },
    "item2": {
      "type": "string",
      "nullable": true
    },
    "system.Runtime.CompilerServices.ITuple.Length": {
      "type": "integer",
      "format": "int32"
    },
    "system.Runtime.CompilerServices.ITuple.Item": {
      "nullable": true
    }
  }
},

Is there any idea on how to fix this? What has changed between NSwag 13 and 14 that changes this behavior? If someone can point me in some direction I could have a look myself.

@simeyla
Copy link

simeyla commented Feb 13, 2024

It seems that property1 below will be added to the API but property2 will not.

 // Why does this get added to the API? It is private!
 private string Property1 { get; }

 // This does not get added to the API
 private string Property2 { get; set; }

I believe this could be the same 'bug' that causes RicoSuter/NJsonSchema#1661 and #4572

I clearly have no ability to add [JsonIgnore] to the Exception property serializationWatsonBuckets !!!

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

No branches or pull requests

2 participants