Skip to content

fix(api-docs): show nullable parameter types as "string | null" - #20506

Merged
yasen-posthog merged 1 commit into
masterfrom
posthog/api-docs-nullable-types
Sep 28, 2026
Merged

yasen-posthog merged 1 commit into
masterfrom
posthog/api-docs-nullable-types

Conversation

@yasen-posthog

@yasen-posthog yasen-posthog commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Changes

The API reference pages show "stringnull" as the type of nullable request parameters. For example, product_description on the create project endpoint shows "stringnull".

The cause: the OpenAPI spec is version 3.1. In 3.1, a nullable field has a type array, such as ["string", "null"]. ApiEndpoint.tsx rendered this array directly, and React joined the items with no separator.

This PR makes two changes in src/templates/ApiEndpoint.tsx:

  • The parameter type badge joins the array with |. The badge now shows string | null.
  • The example request body uses the non-null type. Before this change, the example could show an array value.

Fields that have one type do not change.

Why: A customer reported "stringnull" in the API docs and asked what it means.

Screenshots

Screenshots pending: before/after at 640px and 1440px, in light and dark mode.

Checklist

  • I've read the docs and/or content style guides.
  • Words are spelled using American English
  • Use relative URLs for internal links
  • I've checked the pages added or changed in the Vercel preview build (the preview has no API pages; see verification)
  • If I moved a page, I added a redirect in vercel.json (no pages moved)

Verification:

  • I ran Prettier (the pnpm format config) on the changed file.
  • The deploy preview is a minimal build and has no API pages. So I ran GATSBY_MINIMAL=true pnpm start locally, with a temporary local change (not in this PR) that adds /docs/api/projects to the minimal build.
  • Before: the live site. After: the local dev server. I used headless Chromium at 640px and 1440px, in light and dark mode. The type badges show string | null and boolean | null.
  • Console: the local page had no errors. The live site shows React hydration errors (Burger menu color fix #418, Small fixes for pricing and free trial pages #423) at 640px before this change. These come from the production build, not from this change.

Created with PostHog from a Slack thread

🤖 Generated with Claude Code

OpenAPI 3.1 gives nullable fields a type array, such as ["string", "null"]. The template rendered the array directly, so React joined it to "stringnull". Show the types joined with " | ", and use the non-null type in the example request body.

Generated-By: PostHog Desktop
Task-Id: 949b6cd7-13d9-41e7-8c9d-fdc7b72d097e
@yasen-posthog yasen-posthog self-assigned this Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview

Status Details Updated (UTC)
🟢 Ready View preview Sep 28, 2026 09:00AM

@github-actions github-actions Bot added the website About the website (beyond just landing pages) label Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle report

Total JS (gzip)

8.65 MiB (no change)

Eager graph (modules shipped in each entrypoint's initial chunks)

Entrypoint Eager size Budget Modules
✅ app 18.75 MiB (-0.1 KiB / -0.0%) report-only 2078
Largest modules in the app closure
Module Size
./src/data/mcp-tools.json 1246.6 KiB
css ./node_modules/.pnpm/css-loader@5.2.7_webpack@5.101.3/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[1]!./node_modules/.pnpm/postcss-loader@4.3.0_postcss@8.5.6_webpack@5.101.3/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[2]!./src/styles/global.css 774.1 KiB
./src/components/Stickers/Stickers.tsx 696.4 KiB
./node_modules/.pnpm/@radix-ui+react-icons@1.3.2_react@18.3.1/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js 481.4 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/x-ray.mjs 480.8 KiB
./node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js + 29 modules 395.1 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/im-the-driver.mjs 385.7 KiB
./src/hooks/useCustomers.tsx + 55 modules 373.0 KiB
./node_modules/.pnpm/@posthog+icons@0.36.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js 354.8 KiB
./node_modules/.pnpm/react-markdown@8.0.7_@types+react@16.14.66_react@18.3.1/node_modules/react-markdown/lib/react-markdown.js + 88 modules 351.4 KiB
./src/components/ProductComparisonTable/index.tsx + 127 modules 310.3 KiB
./node_modules/.pnpm/cloudinary-core@2.14.0_lodash@4.17.21/node_modules/cloudinary-core/cloudinary-core.js 281.9 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/doll-house.mjs 281.7 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/director.mjs 275.6 KiB
./src/components/SearchUI/index.tsx + 87 modules 273.7 KiB

Eager-graph budgets are report-only until a baseline is established. Sizes are gzip of public/**/*.js; eager size is webpack module source bytes for the modules actually shipped in the entrypoint's initial chunks (post-tree-shake).

@yasen-posthog
yasen-posthog marked this pull request as ready for review September 28, 2026 09:21
@yasen-posthog
yasen-posthog requested a review from a team September 28, 2026 09:21
@yasen-posthog
yasen-posthog merged commit d80be18 into master Sep 28, 2026
23 checks passed
@yasen-posthog
yasen-posthog deleted the posthog/api-docs-nullable-types branch September 28, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

website About the website (beyond just landing pages)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants