Skip to content

Commit

Permalink
Merge pull request #26 from jpmorganchase/feature/auth-templates
Browse files Browse the repository at this point in the history
Feature/auth templates
  • Loading branch information
KyleJohnst authored May 10, 2024
2 parents 100c8c7 + 1bc5e92 commit e957a39
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('parseHttpRequest', () => {
{ name: 'limit', style: HttpParamStyles.Form, schema: { default: '10' }, required: true },
{ name: 'skip', style: HttpParamStyles.Form, schema: {}, required: false },
],
headers: [{ name: 'apikey', style: HttpParamStyles.Simple, schema: { default: '123' }, required: true }],
headers: [{ name: 'apikey', style: HttpParamStyles.Simple, schema: { default: 'YOUR TOKEN' }, required: true }],
path: [{ name: 'id', style: HttpParamStyles.Simple, required: true }],
body: { contents: [{ mediaType: 'application/json', schema: { default: '{}' } }] },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const AuthTokenInput: React.FC<AuthTokenInputProps> = ({ type, name, valu
aria-label={name}
appearance="minimal"
flex={1}
placeholder={type === 'oauth2' ? 'Bearer 123' : '123'}
placeholder={type === 'oauth2' ? 'Bearer YOUR TOKEN' : 'YOUR TOKEN'}
value={value}
type="text"
required
Expand Down
2 changes: 1 addition & 1 deletion packages/elements-core/src/components/TryIt/TryIt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ export const TryIt: React.FC<TryItProps> = ({
mediaTypeContent,
bodyInput: formDataState.isFormDataBody ? getValues() : textRequestBody,
mockData,
auth: operationAuthValue,
chosenServer,
credentials: tryItCredentialsPolicy,
corsProxy,
});

let response: Response | undefined;
try {
response = await fetch(...request);
Expand Down
12 changes: 6 additions & 6 deletions packages/elements-core/src/components/TryIt/build-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,43 +191,43 @@ const runAuthRequestEhancements = (
if (auth.scheme.in === 'query') {
newQueryParams.push({
name: auth.scheme.name,
value: auth.authValue || '123',
value: auth.authValue || 'YOUR TOKEN',
});
}

if (auth.scheme.in === 'header') {
newHeaders.push({
name: auth.scheme.name,
value: auth.authValue || '123',
value: auth.authValue || 'YOUR TOKEN',
});
}
}

if (isOAuth2SecurityScheme(auth.scheme)) {
newHeaders.push({
name: 'Authorization',
value: auth.authValue || 'Bearer 123',
value: auth.authValue || 'Bearer YOUR TOKEN',
});
}

if (isBearerSecurityScheme(auth.scheme)) {
newHeaders.push({
name: 'Authorization',
value: `Bearer ${auth.authValue || '123'}`,
value: `Bearer ${auth.authValue || 'YOUR TOKEN'}`,
});
}

if (isDigestSecurityScheme(auth.scheme)) {
newHeaders.push({
name: 'Authorization',
value: auth.authValue?.replace(/\s\s+/g, ' ').trim() || '123',
value: auth.authValue?.replace(/\s\s+/g, ' ').trim() || 'YOUR TOKEN',
});
}

if (isBasicSecurityScheme(auth.scheme)) {
newHeaders.push({
name: 'Authorization',
value: `Basic ${auth.authValue || '123'}`,
value: `Basic ${auth.authValue || 'YOUR TOKEN'}`,
});
}
});
Expand Down

0 comments on commit e957a39

Please sign in to comment.