Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API sample responses and request parameters #675

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/scripts/generateApiReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const generateMethodContent = (path: string, method: string) => {
method.toUpperCase()
const filePath = `./components/ApiReference/examples/${slugify(
path
)}-${method}`
)}-${method}`.replace('-api', '')
const examplePath = filePath + '.ts'
const sampleResponsePath = filePath + '.json'
const hasExample = fs.existsSync(examplePath)
Expand Down Expand Up @@ -353,23 +353,22 @@ const generateMethodContent = (path: string, method: string) => {

<CH.Section>
<CH.Code style={{boxShadow: 'none'}}>
${
hasExample && example !== 'export {}\n'
? `
\`\`\`js TypeScript
// from ${examplePath.replace('./components/ApiReference/', '')}
\`\`\`
`
: ''
}
\`\`\`bash ${hasExample && example !== 'export {}\n' ? 'curl' : ''}
${curlify({
url: pathWithParams,
method: method.toUpperCase(),
body: requestBody
})}
\`\`\`

${
hasExample && example !== 'export {}\n'
? `
\`\`\`js TypeScript
// from ./examples/${slugify(path)}-${method}.ts
\`\`\`
`
: ''
}
</CH.Code>
</CH.Section>
<NetworkNotice />
Expand Down
7 changes: 6 additions & 1 deletion components/ApiReference/Property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ const Property: React.FC<{ property: any; required?: boolean }> = ({
? '[]'
: property.value?.type === 'object'
? ''
: property.value?.type}
: Array.isArray(property.value?.type)
? property.value?.type.join(' | ')
: (property.value?.type ??
(Array.isArray(property.value.schema?.type)
? property.value.schema?.type.join(' | ')
: property.value.schema?.type))}
</code>
<Typography
variant='body1'
Expand Down
Loading
Loading