diff --git a/.github/scripts/generateApiReference.js b/.github/scripts/generateApiReference.js index 265d02cb..fa700187 100644 --- a/.github/scripts/generateApiReference.js +++ b/.github/scripts/generateApiReference.js @@ -131,7 +131,11 @@ const generateSampleApiResponse = async ( } const slugify = text => text?.replace?.(/ /g, '-').replace(/\//g, '-') -const resolveRef = ref => jsonFile.definitions[ref.split('/').pop()] +const resolveRef = ref => { + const refName = ref.split('/').pop() + return { refName, ...jsonFile.definitions[refName] } +} + const resolveRefs = obj => { if (typeof obj === 'object') { for (const key in obj) { diff --git a/components/ApiReference/Network.tsx b/components/ApiReference/Network.tsx index 31b8a844..629a52c8 100644 --- a/components/ApiReference/Network.tsx +++ b/components/ApiReference/Network.tsx @@ -49,7 +49,13 @@ const NetworkSwitcher: React.FC = () => { const [network, setNetwork] = useContext(NetworkContext) return ( <> - + - - - Base URL: {network}{' '} - - - `${network}`} /> - - - + + + diff --git a/components/ApiReference/Property.tsx b/components/ApiReference/Property.tsx index 9929bbd5..9e38600f 100644 --- a/components/ApiReference/Property.tsx +++ b/components/ApiReference/Property.tsx @@ -1,44 +1,133 @@ +import { useState } from 'react' import Grid from '@mui/material/Grid' import Typography from '@mui/material/Typography' import { theme } from '../../styles/theme' +import AccordionDetails from '@mui/material/AccordionDetails' +import Accordion from '@mui/material/Accordion' +import { AccordionSummary } from '@mui/material' +import Link from '@mui/material/Link' // eslint-disable-next-line @typescript-eslint/no-explicit-any const Property: React.FC<{ property: any, required?: boolean }> = ({ property, required -}) => ( - palette.grey[400] }} - > - - {property.name} - {required === true && ( - <> - {' - '} - - required - - +}) => { + const [isExpanded, setIsExpanded] = useState(false) + const reference = + property.value?.type === 'object' + ? property.value?.properties + : property.value?.type === 'array' + ? property.value?.items?.properties + : null + const refName = property?.value?.refName ?? property.value?.items?.refName + + return ( + { + if ( + property.value?.type === 'object' || + property.value?.type === 'array' + ) { + setIsExpanded(!isExpanded) + } + }} + sx={{ + border: 'none', + background: 'transparent', + color: theme.palette.grey[400], + boxShadow: 'none', + '&.Mui-expanded': { + border: 'none' + }, + '&:before': { + display: 'none' + }, + '& .MuiAccordionSummary-content': { + margin: 0 + } + }} + > + + palette.grey[400] }} + > + + + {property.name} + + {required === true && ( + <> + {' - '} + + required + + + )} + + + + {refName} + {property.value?.type === 'array' + ? '[]' + : property.value?.type === 'object' + ? '' + : property.value?.type} + + + {property.value?.description} + + + + + {reference != null && ( + + {Object.entries(reference as Record).map( + ([name, value]) => ( + + ) + )} + )} - - - {property.value?.type} - - {property.value?.description} - - - -) + + ) +} export default Property diff --git a/components/ApiReference/Response.tsx b/components/ApiReference/Response.tsx index 45a49f4a..e25fb83f 100644 --- a/components/ApiReference/Response.tsx +++ b/components/ApiReference/Response.tsx @@ -24,7 +24,11 @@ const Response: React.FC<{ response: any, index: number }> = ({ type === 'object' ? response.schema?.properties : response.schema?.items - ).map(([key, value]) => ({ name: key, value })) + ).map(([key, value]) => ({ + name: key, + value, + required: response.schema?.required?.includes(key) + })) return ( <> @@ -102,26 +106,27 @@ const Response: React.FC<{ response: any, index: number }> = ({ > {properties ?.filter( - property => - !( - type === 'array' && - (property.name === 'required' || property.name === 'type') - ) + property => !(type === 'array' && property.name !== 'properties') ) - ?.map?.((property, index) => { - return type === 'object' ? ( - + ?.map?.((property, index) => + type === 'object' ? ( + ) : ( Object.entries(property.value as Record) - .map(([key, value]) => ({ - name: key, - value - })) - .map((property, index) => ( - + .map(([name, value]) => ({ name, value })) + .map((_property, index) => ( + )) ) - })}{' '} + )}{' '}
diff --git a/components/ApiReference/generated-reference.mdx b/components/ApiReference/generated-reference.mdx index fa6a7008..90a400f5 100644 --- a/components/ApiReference/generated-reference.mdx +++ b/components/ApiReference/generated-reference.mdx @@ -33,7 +33,7 @@ This service is available on [multiple networks](../../core-api/transaction-serv - + @@ -99,7 +99,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/contracts/ \ - + @@ -179,7 +179,7 @@ as in case of ABI collision service will know which ABI to use. - + @@ -300,7 +300,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/data-decoder/ \ - + @@ -356,7 +356,7 @@ For example: - + @@ -404,7 +404,7 @@ Check `POST /delegates/` - + @@ -459,7 +459,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/delegates/0x5 - + @@ -498,7 +498,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b5 - + @@ -547,7 +547,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/messages/0x3b3b - + @@ -593,7 +593,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/module-transacti - + @@ -645,7 +645,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/modules/0xcd2E72 - + @@ -718,7 +718,7 @@ Unix UTC epoch time (no milliseconds) and dividing by 3600 (natural division, no - + @@ -766,7 +766,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/multisig-tran - + @@ -815,7 +815,7 @@ the use of delegates to make a transaction trusted. - + @@ -864,7 +864,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/multisig-transa - + @@ -916,7 +916,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/owners/0xcd2E72a - + @@ -973,7 +973,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE = Safe current nonce` are also returned","type":"boolean","default":true},{"name":"trusted","in":"query","description":"If `True` just trusted transactions are shown (indexed, added by a delegate or with at least one confirmation)","type":"boolean","default":true}]} /> - + @@ -1186,7 +1186,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - + @@ -1279,7 +1279,7 @@ Check `POST /delegates/` - + @@ -1328,7 +1328,7 @@ curl -X DELETE https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E7 - + @@ -1420,7 +1420,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - + @@ -1473,7 +1473,7 @@ service needs to derive it itself. - + @@ -1518,7 +1518,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - + @@ -1568,7 +1568,7 @@ By default only ``trusted`` multisig transactions are returned. - + @@ -1755,7 +1755,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - + @@ -1811,8 +1811,8 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - - + + @@ -1864,7 +1864,7 @@ curl -X POST https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72a - + @@ -1962,7 +1962,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/safes/0xcd2E72aE - + @@ -2030,7 +2030,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/ \ - + @@ -2076,7 +2076,7 @@ curl -X GET https://safe-transaction-mainnet.safe.global/api/v1/tokens/0xcd2E72a - + diff --git a/components/ApiReference/paths-metadata.json b/components/ApiReference/paths-metadata.json index 7feab960..9a12d99c 100644 --- a/components/ApiReference/paths-metadata.json +++ b/components/ApiReference/paths-metadata.json @@ -126,7 +126,7 @@ }, "/v1/safes/{address}/balances/": { "get": { - "title": "List a Safe's Balances" + "title": "List a Safe's Balances (Deprecated)" } }, "/v1/safes/{address}/balances/usd/": { diff --git a/styles/styles.css b/styles/styles.css index a3d0a81b..f3cb9530 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -7,6 +7,10 @@ html[class~='dark'] .dark\:nx-bg-dark.dark\:nx-bg-dark { background-color: #121312; } +h1 { + line-height: 60px; +} + /* Navbar */ #__next > div > div > div { backdrop-filter: blur(8px);