-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Streamline management of user-selected produces and consumes values (WIP)
#4137
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
350595f
Remove produces/consumes setter from OperationContainer
shockey 2940e18
Store consumes/produces information in `meta` key
shockey 99e3735
Migrate produces value state usage to `meta` key
shockey 3be737a
use meta consumes data for isXml check
shockey 2950e0f
Fix failing tests
shockey 58eda41
normalize action name casing
shockey 862a811
restore correct produces fallback value logic
shockey 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -82,27 +82,9 @@ export default class OperationContainer extends PureComponent { | |
| } | ||
|
|
||
| componentWillReceiveProps(nextProps) { | ||
| const defaultContentType = "application/json" | ||
| let { specActions, path, method, op } = nextProps | ||
| let operation = op.get("operation") | ||
| let producesValue = operation.get("produces_value") | ||
| let produces = operation.get("produces") | ||
| let consumes = operation.get("consumes") | ||
| let consumesValue = operation.get("consumes_value") | ||
|
|
||
| if(nextProps.response !== this.props.response) { | ||
| this.setState({ executeInProgress: false }) | ||
| } | ||
|
|
||
| if (producesValue === undefined) { | ||
| producesValue = produces && produces.size ? produces.first() : defaultContentType | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve this logic |
||
| specActions.changeProducesValue([path, method], producesValue) | ||
| } | ||
|
|
||
| if (consumesValue === undefined) { | ||
| consumesValue = consumes && consumes.size ? consumes.first() : defaultContentType | ||
| specActions.changeConsumesValue([path, method], consumesValue) | ||
| } | ||
| } | ||
|
|
||
| toggleShown =() => { | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import { | |
| SET_REQUEST, | ||
| SET_MUTATED_REQUEST, | ||
| UPDATE_RESOLVED, | ||
| UPDATE_OPERATION_VALUE, | ||
| UPDATE_OPERATION_META_VALUE, | ||
| CLEAR_RESPONSE, | ||
| CLEAR_REQUEST, | ||
| CLEAR_VALIDATE_PARAMS, | ||
|
|
@@ -52,8 +52,8 @@ export default { | |
| }, | ||
|
|
||
| [VALIDATE_PARAMS]: ( state, { payload: { pathMethod, isOAS3 } } ) => { | ||
| let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] ) | ||
| let isXml = /xml/i.test(operation.get("consumes_value")) | ||
| let meta = state.getIn( [ "meta", "paths", ...pathMethod ] ) | ||
| let isXml = /xml/i.test(meta.get("consumes_value")) | ||
|
|
||
| return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => { | ||
| return parameters.withMutations( parameters => { | ||
|
|
@@ -107,12 +107,17 @@ export default { | |
| return state.setIn( [ "mutatedRequests", path, method ], fromJSOrdered(req)) | ||
| }, | ||
|
|
||
| [UPDATE_OPERATION_VALUE]: (state, { payload: { path, value, key } }) => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be documented as an internal API change in release notes. |
||
| [UPDATE_OPERATION_META_VALUE]: (state, { payload: { path, value, key } }) => { | ||
| // path is a pathMethod tuple... can't change the name now. | ||
| let operationPath = ["resolved", "paths", ...path] | ||
| let metaPath = ["meta", "paths", ...path] | ||
|
|
||
| if(!state.getIn(operationPath)) { | ||
| // do nothing if the operation does not exist | ||
| return state | ||
| } | ||
| return state.setIn([...operationPath, key], fromJS(value)) | ||
|
|
||
| return state.setIn([...metaPath, key], fromJS(value)) | ||
| }, | ||
|
|
||
| [CLEAR_RESPONSE]: (state, { payload: { path, method } } ) =>{ | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Need to be sure to preserve this default
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.
haha