Skip to content

Commit

Permalink
chore: refactor and add prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Cayla Hamann committed Jun 11, 2020
1 parent e6a8706 commit 90764ac
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/hooks/useApiDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,15 @@ const useApiDoc = (name) => {
typeof api[member] !== 'function'
)
.map((member) => {
const type =
api[member] instanceof Array ? 'array' : typeof api[member];
const constantValues =
type === 'object'
? Object.getOwnPropertyNames(api[member]).map(
(key) => `${key}:${JSON.stringify(api[member][key])}`
)
: api[member].map((el) => JSON.stringify(el));
return {
name: member,
type,
name: `${name}.${member}`,
type: api[member] instanceof Array ? 'array' : typeof api[member],
values:
constantValues instanceof Array
? constantValues
: [constantValues],
api[member] instanceof Array
? Object.getOwnPropertyNames(api[member]).map(
(key) => `${key}:${JSON.stringify(api[member][key])}`
)
: api[member].map((el) => JSON.stringify(el)),
};
});
};
Expand Down

0 comments on commit 90764ac

Please sign in to comment.