NSwag
NSwag copied to clipboard
NSwag generates duplicate properties if one of them is "deprecated.
The OpenAPI specification of latest confluence API (obtained from https://developer.atlassian.com/cloud/confluence/rest/v2 and clicking on "OpenAPI" to download the OpenAPI document) contains deprecated properties.
For example, on the InlineCommentProperties
type:
-
"inline-marker-ref"
is deprecated and has been replaced by"inlineMarkerRef"
. -
"inline-original-selection"
is deprecated and has been replaced by"inlineOriginalSelection"
Sadly, NSwag generates both deprecated and non-deprecated properties with the same property name: InlineMarkerRef
in the former case and InlineOriginalSelection
in the latter.
This gives compilation errors:
1>...\ConfluenceInterfaceClient.cs(39780,23,39780,38): error CS0102: The type 'InlineCommentProperties' already contains a definition for 'InlineMarkerRef'
1>...\ConfluenceInterfaceClient.cs(39787,23,39787,46): error CS0102: The type 'InlineCommentProperties' already contains a definition for 'InlineOriginalSelection'
There is a property called ``, which I used like this:
"documentGenerator": {
"fromDocument": {
/* Obtained from https://developer.atlassian.com/cloud/confluence/rest/v2 and clicking on "OpenAPI" to download the OpenAPI document */
"url": "../openapi-v2.v3.json",
"ignoreObsoleteProperties": true,
"newLineBehavior": "Auto"
}
},
... but it doesn't have any effect. I think it's only valid when you are generating from controllers.
Any suggestions?
For illustration, this is the code NSwag generates for the aforementioned type:
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class InlineCommentProperties
{
/// <summary>
/// Property value used to reference the highlighted element in DOM.
/// </summary>
[Newtonsoft.Json.JsonProperty("inlineMarkerRef", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string InlineMarkerRef { get; set; } = default!;
/// <summary>
/// Text that is highlighted.
/// </summary>
[Newtonsoft.Json.JsonProperty("inlineOriginalSelection", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string InlineOriginalSelection { get; set; } = default!;
/// <summary>
/// Deprecated, use `inlineMarkerRef` instead.
/// </summary>
[Newtonsoft.Json.JsonProperty("inline-marker-ref", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Obsolete]
public string InlineMarkerRef { get; set; } = default!;
/// <summary>
/// Deprecated, use `inlineOriginalSelection` instead.
/// </summary>
[Newtonsoft.Json.JsonProperty("inline-original-selection", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Obsolete]
public string InlineOriginalSelection { get; set; } = default!;
private System.Collections.Generic.IDictionary<string, object>? _additionalProperties;
[Newtonsoft.Json.JsonExtensionData]
public System.Collections.Generic.IDictionary<string, object> AdditionalProperties
{
get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); }
set { _additionalProperties = value; }
}
}