Skip to content

Commit

Permalink
Update API endpoint for fetching PowerShell snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Millicent Achieng committed Nov 24, 2021
1 parent 00e9fe8 commit 337d1b2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/app/services/actions/snippet-action-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import { parseSampleUrl } from '../../utils/sample-url-generation';
import {
GET_SNIPPET_ERROR,
GET_SNIPPET_PENDING,
GET_SNIPPET_SUCCESS
GET_SNIPPET_SUCCESS,
} from '../redux-constants';

export function getSnippetSuccess(response: string): IAction {
return {
type: GET_SNIPPET_SUCCESS,
response
response,
};
}

export function getSnippetError(response: object): IAction {
return {
type: GET_SNIPPET_ERROR,
response
response,
};
}

export function getSnippetPending(): any {
return {
type: GET_SNIPPET_PENDING
type: GET_SNIPPET_PENDING,
};
}

Expand All @@ -41,16 +41,17 @@ 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());

const method = 'POST';
const headers = {
'Content-Type': 'application/http'
'Content-Type': 'application/http',
};
// eslint-disable-next-line max-len
const body = `${sampleQuery.selectedVerb} /${queryVersion}/${
Expand Down

0 comments on commit 337d1b2

Please sign in to comment.