-
Notifications
You must be signed in to change notification settings - Fork 9k
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
fix: remove special handling of non-FormData entries #6036
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
describe("Entries should be valid property name", () => { | ||
it("should render a OAS3.0 definition that uses 'entries' as a property name", () => { | ||
it("should render a OAS3.0 definition that uses 'entries' as a 'components' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas3.yaml") | ||
.get("#operations-tag-default") | ||
.should("exist") | ||
}) | ||
it("should render a OAS2.0 definition that uses 'entries' as a property name", () => { | ||
it("should render expanded Operations of OAS3.0 definition that uses 'entries' as a 'components' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas3.yaml") | ||
.get("#operations-default-test_test__get") | ||
.click() | ||
.get("#operations-default-test_test__get > div .opblock-body") | ||
.should("exist") | ||
|
||
}) | ||
it("should render expanded Models of OAS3.0 definition that uses 'entries' as a 'components' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas3.yaml") | ||
.get("#model-Testmodel > span .model-box") | ||
.click() | ||
.get("div .model-box") | ||
.should("exist") | ||
}) | ||
it("should render a OAS2.0 definition that uses 'entries' as a 'definitions' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas2.yaml") | ||
.get("#operations-default-post_pet") | ||
.should("exist") | ||
}) | ||
it("should render expanded Operations of OAS2.0 definition that uses 'entries' as a 'definitions' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas2.yaml") | ||
.get("#operations-default-post_pet") | ||
.click() | ||
.get("#operations-default-post_pet > div .opblock-body") | ||
.should("exist") | ||
|
||
}) | ||
it("should render expanded Models of OAS2.0 definition that uses 'entries' as a 'defintions' property name", () => { | ||
cy.visit("/?url=/documents/bugs/6016-oas2.yaml") | ||
.get("#model-Pet > span .model-box") | ||
.click() | ||
.get("div .model-box") | ||
.should("exist") | ||
}) | ||
}) |
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.
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.
The logic here is a little bit nonsensical for me here.
createObjWithHashedKeys
is used in only one place in codebase, and that's here on line 86.Then first thing the function does is validate it's input param again but with different predicate statement. This seems redundant and non-compatible with
isFunction(js.entries)
predicate statement checking ifentries
is a function instead checking if it's falsy. I recommend dropping following code from the function body.Another thing about
createObjWithHashedKeys
is that it's super crazy complicated. It's not apparent what is does by reading it. So I'd either put @example tag to functions existing jsdoc to document what is the expected output of this function for particular input (formdata) or create a unit tests for this function.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.
Internal validation updated to match
isFunction
for consistency. Internal validation retained for robustness.The original use of
isFunction(js.entries)
is a conditional, not a validationAdded a real example
Not done for 'createObjWithHashedKeys'. Reason: would be new feature with additional dependencies for isomorphic-form-data for testing purposes. This is also the reason for validating
fdObj.entries
rather than validatinginstanceof FormData
.However, there exists a
curlify
test that tests rendering of the result, which is basis of the added @example tag mentioned aboveThere 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.
OK everything clear except one thing.
We're trying to detect if the
js
is a FormData instance. Why are we not usinginstanceof FormData
operator but rather asserting on the shape of the possible formData instance?swagger-client
is integral part of swagger-ui and it makes sure thatFormData
symbol is always present as global symbol, both in browser and node.js so it's absolutely safe to do so without installingisomorphic-form-data
explicitly.New feature? I'd rather say it's just a dev-dependency used only for tests. But anyway @examples in jsdoc should suffice if function is tested elsewhere in integration.