-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
Implement support for anonymous models described using anyOf or oneOf… #399
Conversation
…. allOf seems OK. Remove TODO. Add tests. Credit Yusei Abe in LICENSE for the base of the code.
Codecov Report
@@ Coverage Diff @@
## master #399 +/- ##
==========================================
+ Coverage 93.39% 93.48% +0.08%
==========================================
Files 108 108
Lines 1272 1304 +32
Branches 229 245 +16
==========================================
+ Hits 1188 1219 +31
- Misses 84 85 +1
Continue to review full report at Codecov.
|
This pull request introduces 1 alert when merging 3ede3ad into 203b74e - view on LGTM.com new alerts:
|
thanks for the mention @thetrime . I think it's not necessary that the modified copyright that includes me. as a background story, at the first time of first-developing term, the backend of my team generates OpenAPI definitions in a very few pattern, Anyway, i don't recommend to merge my patch (this pull request seems to be more sophisticated then mine?). |
I suspect that the implemented logic could be extended to the ...
"ModelWithNullableReferenceProperty": {
"description": "This is a model which property is a reference and nullable",
"type": "object",
"properties": {
"nullableProp": {
"allOf": [
{
"$ref": "#/components/schemas/ModelWithString"
},
{
"$ref": "#/components/schemas/ModelThatExtends"
}
],
"nullable": true
}
}
},
... which currently is rendered as export interface ModelWithNullableReferenceProperty {
nullableProp?: any;
} but with the same logic as above this, could be rendered as export interface ModelWithNullableReferenceProperty {
nullableProp?: ModelWithString & ModelThatExtends | null;
} |
All code is imperfect :) If you don't want to be mentioned, I can certainly remove it.
Yes, I'm aware this is a bit rough, but it's better than what was available before. If someone wants to refine it even further, then that's fine by me.
Yes - I'm in exactly the same situation.
It works for my patterns too. Note that my code is even more limited than your patch - it won't handle nested oneOf properly at all |
This pull request introduces 1 alert when merging fdf1b2b into fa6fbbc - view on LGTM.com new alerts:
|
The PR #419 solves this, but with objects of arbitrary depth and is not limited to interfaces. |
Closing this in favour of #419 |
…. allOf seems OK. Remove TODO. Add tests. Credit Yusei Abe in LICENSE for the core idea of the code, found at https://github.com/diverta/kuroco-sdk/blob/8029698bc6d43b94a9190e7d1f34dad92234b3ed/src/generator/openApi/v3/parser/getModel.ts#L120
This is a bit simple than the approach taken by @yabe-diverta in that it does not handle nested anyOf and allOf (though as far as I can tell, yabe-diverta's code only handles one more level of nesting than mine, rather than arbitrary nesting). The tests all still pass, and I've added two new ones for the anyOf and oneOf cases described.