We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a class with a base class in C# and the following schema is generated in my API:
{ "WebhookRuleActionDto":{ "allOf":[ { "$ref":"#/components/schemas/RuleActionDto" }, { "type":"object", "deprecated":true, "x-deprecatedMessage":"Has been replaced by flows.", "additionalProperties":false, "required":[ "url", "method" ], "properties":{ } } ] } }
(I have simplified it a little bit).
By default the class has no Obsolete attribute because the model only checks at the root schema:
NJsonSchema/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs
Line 178 in f68e664
I solved it with a little bit of postprocessing, but I think it should just work.
public static void AddDeprecations(OpenApiDocument document) { foreach (var (name, scheme) in document.Components.Schemas) { if (scheme.IsDeprecated) { continue; } if (scheme.AllOf != null && scheme.AllOf.Count > 0) { foreach (var allOf in scheme.AllOf) { if (!string.IsNullOrWhiteSpace(allOf.DeprecatedMessage)) { Console.WriteLine($"Add Deprecation to: {name}"); scheme.DeprecatedMessage = allOf.DeprecatedMessage; scheme.IsDeprecated = true; break; } } } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a class with a base class in C# and the following schema is generated in my API:
(I have simplified it a little bit).
By default the class has no Obsolete attribute because the model only checks at the root schema:
NJsonSchema/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs
Line 178 in f68e664
I solved it with a little bit of postprocessing, but I think it should just work.
The text was updated successfully, but these errors were encountered: