Skip to content

Commit

Permalink
Edit sample requests
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-md committed May 15, 2024
1 parent 50dedb3 commit f8cd465
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 33 deletions.
13 changes: 12 additions & 1 deletion .github/scripts/generateApiReference.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const generateMethodContent = (path, method) => {
<Grid item xs={12} md={5.6}>
<Path path="${path}" method="${method}" />
#### Sample Request
<SampleRequestHeader method="${method}" pathWithParams="${pathWithParams}" />
<CH.Section>
<CH.Code>
Expand All @@ -298,6 +298,14 @@ ${curlify({
\`\`\`
</CH.Code>
</CH.Section>
<Box sx={{ fontSize: '12px', mt: -5, mb: 3 }}>
This snippet shows a sample request on mainnet. For other networks you should use
<Link
href='/core-api/transaction-service-supported-networks'
rel='noopener noreferrer'
target='_blank'
>the corresponding base URL</Link>.
</Box>
${
hasResponse && sampleResponse !== '{}'
Expand Down Expand Up @@ -369,12 +377,15 @@ const generateMainContent = () => {

return `import Path from './Path'
import Hr from '../Hr'
import SampleRequestHeader from './SampleRequestHeader'
import Parameters from './Parameter'
import NetworkSwitcher from './Network'
import Responses from './Response'
import Feedback from '../Feedback'
import Grid from '@mui/material/Grid'
import Box from '@mui/material/Box'
import NextLink from 'next/link'
import Link from '@mui/material/Link'
# Safe Transaction Service API Reference
Expand Down
29 changes: 29 additions & 0 deletions components/ApiReference/SampleRequestHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Button from '@mui/material/Button'
import Grid from '@mui/material/Grid'
import { useContext } from 'react'
import { NetworkContext } from './Network'
import { MdxHeading } from '../../lib/mdx'

const SampleRequestHeader: React.FC<{
method: string
pathWithParams: string
}> = ({ method, pathWithParams }) => {
const [network] = useContext(NetworkContext)

return (
<Grid container justifyContent='space-between'>
<MdxHeading headingLevel={4}>Sample Request</MdxHeading>
<Button
variant='outlined'
size='small'
href={method === 'get' ? `${network}/api${pathWithParams}` : network}
target='_blank'
rel='noopener noreferrer'
>
Try it on Swagger
</Button>
</Grid>
)
}

export default SampleRequestHeader
Loading

0 comments on commit f8cd465

Please sign in to comment.