Skip to content
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

Add PowerShell snippets tab #1273

Merged
merged 11 commits into from
Jan 13, 2022
Merged
2 changes: 1 addition & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ module.exports = function (webpackEnv) {
maxChunks: 1
}),
new MonacoWebpackPlugin({
languages: ['json', 'javascript', 'java', 'objective-c', 'csharp', 'html']
languages: ['json', 'javascript', 'java', 'objective-c', 'csharp', 'html', 'powershell', 'go']
}),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin(
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions src/app/services/actions/snippet-action-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export function getSnippet(language: string): Function {
}
if (language !== 'csharp') {
snippetsUrl += `?lang=${language}`;
if (language === 'go') {
snippetsUrl += '&generation=openapi';
}
}
const openApiSnippets: string[] = ['go', 'powershell'];
if (openApiSnippets.includes(language)) {
snippetsUrl += '&generation=openapi';
}

dispatch(getSnippetPending());
Expand All @@ -52,12 +53,17 @@ export function getSnippet(language: string): Function {
const headers = {
'Content-Type': 'application/http'
};
// eslint-disable-next-line max-len

const requestBody =
sampleQuery.sampleBody &&
Object.keys(sampleQuery.sampleBody).length !== 0 && // check if empty object
sampleQuery.sampleBody.trim() !== ''
? JSON.stringify(sampleQuery.sampleBody)
: '';

const body = `${sampleQuery.selectedVerb} /${queryVersion}/${
requestUrl + search
} HTTP/1.1\r\nHost: graph.microsoft.com\r\nContent-Type: application/json\r\n\r\n${JSON.stringify(
sampleQuery.sampleBody
)}`;
} HTTP/1.1\r\nHost: graph.microsoft.com\r\nContent-Type: application/json\r\n\r\n${requestBody}`;
const options: IRequestOptions = { method, headers, body };
const obj: any = {};

Expand Down
3 changes: 2 additions & 1 deletion src/app/views/query-response/snippets/Snippets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function GetSnippets() {
'JavaScript',
'Java',
'Objective-C',
'Go'
'Go',
'PowerShell'
];

return <Pivot>{renderSnippets(supportedLanguages)}</Pivot>;
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"resolveJsonModule": true,
"noEmit": true,
"jsx": "react-jsx"

},
"include": [
"src",
Expand Down