-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Swagger document generation: invalid allOf usage #1245
Comments
Ref: #1136 |
Working on this in the "improved-inheritance-nswag-1136" branch, in http://njsonschema.org https://github.com/RSuter/NJsonSchema/tree/features/improved-inheritance-nswag-1136/src |
The big problem with this "feature" is that I have to proxy all properties from the base schema to one of the allOf schemas so that you can use the schema properties transparently... |
In case if someone need to fix this issue immediately please use this temporary solution. private string FixNSwagDocument(string invalidDoc)
{
var invalidObj = JObject.Parse(invalidDoc);
var allOfTokens = invalidObj.SelectTokens("definitions..allOf");
foreach (var allOf in allOfTokens)
{
var objToConvert = allOf.Parent.Parent;
var newAllOffItem = JObject.Parse("{}");
var childs = objToConvert.Children().ToList();
foreach (var childToken in childs)
{
dynamic dChild = childToken;
if (dChild.Name != "allOf")
{
newAllOffItem.Add(childToken);
childToken.Remove();
}
}
((JArray)allOf).Add(newAllOffItem);
Console.WriteLine(objToConvert.ToString());
}
return invalidObj.ToString();
} |
@RSuter Any update on this? Can I do anything to help? |
Here is the WIP PR: RicoSuter/NJsonSchema#733 Lot's of tests still failing... |
You could create a PR against this PR with fixes and more tests |
But this is a nasty problem and we have to be extremely careful not to break other stuff and introduce regressions.. |
Update: Merged into NJS, next release will contain this fix |
Fixed in v11.20.0 |
Hi
Seems i got some bug when generating swagger document.
According to https://swagger.io/specification/#schemaObject when swagger describes properties of inherited type it should describe properties inside allOf node, but current NSwag generates all properties outside of allOf.
Such document works fine when we use NSwag CSharp code generation toolchain, but if we use swagger codegen toolchain to generate swift or kotlin or even csharp, it will not generate properties for inherited types.
Example of incorrect type generation:
Example of correct document:
The text was updated successfully, but these errors were encountered: