This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Close #231
mpotomin
suggested changes
Feb 4, 2020
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.
Looks good and test run as expected! A minor readability suggestion:
src/scripts/import-open-api.ts
Outdated
Comment on lines
197
to
208
} else { | ||
if (res.content && res.content["application/json"]) { | ||
const schema = res.content["application/json"].schema!; | ||
return resolveValue(schema); | ||
} else if (res.content && res.content["application/octet-stream"]) { | ||
const schema = res.content["application/octet-stream"].schema!; | ||
return resolveValue(schema); | ||
if (res.content) { | ||
for (let contentType of Object.keys(res.content)) { | ||
if (contentType.startsWith("application/json") || contentType.startsWith("application/octet-stream")) { | ||
const schema = res.content[contentType].schema!; | ||
return resolveValue(schema); | ||
} | ||
} | ||
return "void"; | ||
} else { | ||
return "void"; | ||
} |
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.
Since we are touching this part of the code, let's improve the readability a little bit by decreasing the amount of levels of code indentation. I suggest:
export const getResReqTypes = (
responsesOrRequests: Array<[string, ResponseObject | ReferenceObject | RequestBodyObject]>,
) =>
uniq(
responsesOrRequests.map(([_, res]) => {
if (!res) {
return "void";
}
if (isReference(res)) {
return getRef(res.$ref);
}
if (res.content) {
for (let contentType of Object.keys(res.content)) {
if (contentType.startsWith("application/json") || contentType.startsWith("application/octet-stream")) {
const schema = res.content[contentType].schema!;
return resolveValue(schema);
}
}
return "void";
}
return "void";
}),
).join(" | ");
mpotomin
approved these changes
Feb 4, 2020
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.
Test are ✅
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
#231
Why
We didn't deal with more advanced content type, this should be way more flexible.