Skip to content

Commit 35df477

Browse files
cfabianskiRomanHotsiy
authored andcommitted
fix: update apiKey in to be titleize (#902)
1 parent 64453ff commit 35df477

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/components/SecuritySchemes/SecuritySchemes.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SecuritySchemesModel } from '../../services/models';
44

55
import { H2, MiddlePanel, Row, Section, ShareLink } from '../../common-elements';
66
import { OpenAPISecurityScheme } from '../../types';
7+
import { titleize } from '../../utils/helpers';
78
import { Markdown } from '../Markdown/Markdown';
89
import { StyledMarkdownBlock } from '../Markdown/styled.elements';
910

@@ -84,7 +85,7 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> {
8485
</tr>
8586
{scheme.apiKey ? (
8687
<tr>
87-
<th> {scheme.apiKey.in} parameter name:</th>
88+
<th> {titleize(scheme.apiKey.in || '')} parameter name:</th>
8889
<td> {scheme.apiKey.name} </td>
8990
</tr>
9091
) : scheme.http ? (
@@ -93,13 +94,12 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> {
9394
<th> HTTP Authorization Scheme </th>
9495
<td> {scheme.http.scheme} </td>
9596
</tr>,
96-
scheme.http.scheme === 'bearer' &&
97-
scheme.http.bearerFormat && (
98-
<tr key="bearer">
99-
<th> Bearer format </th>
100-
<td> "{scheme.http.bearerFormat}" </td>
101-
</tr>
102-
),
97+
scheme.http.scheme === 'bearer' && scheme.http.bearerFormat && (
98+
<tr key="bearer">
99+
<th> Bearer format </th>
100+
<td> "{scheme.http.bearerFormat}" </td>
101+
</tr>
102+
),
103103
]
104104
) : scheme.openId ? (
105105
<tr>

src/utils/__tests__/helpers.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import slugify from 'slugify';
2-
import { mapWithLast, appendToMdHeading, mergeObjects, safeSlugify } from '../helpers';
2+
import { appendToMdHeading, mapWithLast, mergeObjects, safeSlugify, titleize } from '../helpers';
33

44
describe('Utils', () => {
55
describe('helpers', () => {
@@ -68,5 +68,11 @@ describe('Utils', () => {
6868
expect(mergeObjects({}, obj1, obj2)).toEqual({ a: ['C'], b: ['D'] });
6969
});
7070
});
71+
72+
describe('titleize', () => {
73+
test('should return the string with the first letter capitalized', () => {
74+
expect(titleize('my title')).toEqual('My title');
75+
});
76+
});
7177
});
7278
});

src/utils/helpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ export function getBasePath(serverUrl: string): string {
166166
return new URL(serverUrl).pathname;
167167
}
168168

169+
export function titleize(text: string) {
170+
return text.charAt(0).toUpperCase() + text.slice(1);
171+
}
172+
169173
export function removeQueryString(serverUrl: string): string {
170174
const url = new URL(serverUrl);
171175
url.search = '';

0 commit comments

Comments
 (0)