Skip to content

Commit f500aca

Browse files
committed
Fixes #283 - Passwords should be obscured in parameter input boxes
1 parent 7724a0b commit f500aca

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/components/api-request.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ export default class ApiRequest extends LitElement {
206206
paramExplode = param.explode;
207207
}
208208
}
209+
210+
param.example = typeof param.example === 'undefined' ? '' : `${param.example}`;
209211
if (param.example) {
210-
if (param.example === '0' || param.example === 0) {
211-
inputVal = '0';
212-
} else {
213-
inputVal = paramSchema.type === 'array' ? [param.example] : param.example;
214-
}
212+
inputVal = paramSchema.type === 'array' ? [param.example] : `${param.example}`;
213+
} else if (paramSchema.example) {
214+
inputVal = paramSchema.type === 'array' ? [paramSchema.example] : paramSchema.example;
215215
} else if (param.examples && Object.values(param.examples).length > 0) {
216216
const firstExample = Object.values(param.examples)[0].value || '';
217217
inputVal = paramSchema.type === 'array' ? [firstExample] : firstExample;
@@ -261,7 +261,7 @@ export default class ApiRequest extends LitElement {
261261
style = "resize:vertical; width:100%; height: ${'read focused'.includes(this.renderStyle) ? '180px' : '120px'};"
262262
>${inputVal}</textarea>`
263263
: html`
264-
<input type="text" spellcheck="false" style="width:100%" class="request-param"
264+
<input type="${paramSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%" class="request-param"
265265
data-pname="${param.name}"
266266
data-ptype="${paramType}"
267267
data-array="false"

src/utils/schema-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function getTypeInfo(schema) {
2121
? '🆆'
2222
: '',
2323
deprecated: schema.deprecated ? '❌' : '',
24+
example: typeof schema.example === 'undefined' ? '' : `${schema.example}`,
2425
default: schema.default === 0 ? '0' : (schema.default ? schema.default : ''),
2526
description: schema.description ? schema.description : '',
2627
constrain: '',

0 commit comments

Comments
 (0)