-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-Complete Required Request Body Parameters when Inserting Commands (
#156) * Add Required Body Parameters when Inserting Commands Signed-off-by: Snehil Shah <[email protected]> * Format Code Signed-off-by: Snehil Shah <[email protected]> * Refactor Signed-off-by: Snehil Shah <[email protected]> --------- Signed-off-by: Snehil Shah <[email protected]>
- Loading branch information
1 parent
aa9afb1
commit 436be42
Showing
3 changed files
with
25 additions
and
1 deletion.
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
12 changes: 12 additions & 0 deletions
12
src/components/CodeEditorWindow/config/CommandsDrawerUtils.js
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const resolveRequiredBodyParams = function (openapi, requestBodyContent) { | ||
const contentType = Object.keys(requestBodyContent)[0]; | ||
if ('$ref' in requestBodyContent[contentType].schema) { | ||
const refPath = requestBodyContent[contentType].schema.$ref; | ||
// parse and navigate to the ref | ||
const pathComponents = refPath.slice(2).split('/'); | ||
const schema = pathComponents.reduce((doc, pathComponent) => doc[pathComponent], openapi); | ||
return schema.required; | ||
} else { | ||
return requestBodyContent[contentType].schema.required; | ||
} | ||
}; |