-
-
Notifications
You must be signed in to change notification settings - Fork 544
WIP: Adding requestBodies transform support #474
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
Conversation
Ok, at least tested all suits, I had timeout issue on my side. WIP |
Codecov Report
@@ Coverage Diff @@
## main #474 +/- ##
===========================================
- Coverage 93.81% 79.80% -14.01%
===========================================
Files 5 9 +4
Lines 291 312 +21
Branches 97 96 -1
===========================================
- Hits 273 249 -24
- Misses 16 63 +47
+ Partials 2 0 -2
Continue to review full report at Codecov.
|
@drwpow, what is needed to pass the Codecov test? I tried to open report on Codecov, but have got the error message: "Missing base report". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks for adding.
@@ -31,3 +33,38 @@ describe("requestBody", () => { | |||
).toBe(`requestBody: components["requestBodies"]["Request"];`); | |||
}); | |||
}); | |||
|
|||
describe("requestBodies", () => { | |||
const format = (source: string) => prettier.format(source, { parser: "typescript" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably remember the previous versions of the test. Here’s some extra context for why it‘s not in the unit tests now.
Prettier saves a lot of code managing indents, quotation style, etc. By just running Prettier at the end, this library can do less formatting, and only has to render valid (albeit messy) TypeScript. But recently I noticed that this library wasn’t generating syntax correctly in places, and Prettier sometimes would format incorrectly. So I wanted to write more tests without Prettier to make sure the generated code was valid TS, and Prettier wasn’t hiding any issues. But that comes with drawbacks, obviously—it’s annoying to write & test unformatted code.
Anyway, I’m fine having Prettier in some tests, and it’s fine here! But in most places it’s been intentionally left out.
UserArray: { [key: string]: any }; | ||
UserArray: { | ||
content: { | ||
"application/json": components["schemas"]["User"][]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test!
Just fixed that problem now. Sorry about that. This looks good! Thank you. |
@all-contributors please add @radist2s for code, test |
I've put up a pull request to add @radist2s! 🎉 |
According to OpenAPI 3.0
components.requestBodies
have a specific schema:Currently
components.requestBodies
is transformed as normal schema with the wrong output code:This PR fix wrong transformation, and makes ability to have a valid output code: