From 2c27001128af44a4ae94f0a064bd3cbd7a894912 Mon Sep 17 00:00:00 2001 From: oliver-statsig Date: Thu, 23 Jan 2025 16:29:23 -0800 Subject: [PATCH] Add description for API versioning (#2512) --- docs/console-api/autogenerated.mdx | 3 -- docs/console-api/introduction.mdx | 6 +++ src/components/Rapidoc.js | 61 ++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/docs/console-api/autogenerated.mdx b/docs/console-api/autogenerated.mdx index 3eb405194..14715e377 100644 --- a/docs/console-api/autogenerated.mdx +++ b/docs/console-api/autogenerated.mdx @@ -8,9 +8,6 @@ import Rapidoc from "../../src/components/Rapidoc" The endpoints below are the latest and auto-generated. While we strive to provide comprehensive descriptions and examples for each endpoint during this migration, if you notice any missing information or have feedback, please reach out to us on Slack.
- -
-
{ + localStorage.setItem(SELECTED_API_VERSION_STORAGE_KEY, version); + setApiVersion(version); + } + + useEffect(() => { + if (!apiVersion) { + // Can't have this in the useState init because it prevents this from being server renderable. + setApiVersion(localStorage.getItem(SELECTED_API_VERSION_STORAGE_KEY) ?? apiVersions[0]); + } + }, [apiVersion]); useEffect(() => { + if (!specUrl) { + return; + } + const rapidoc = document.getElementById(id); if (entity === "all-endpoints-generated") { - rapidoc.loadSpec("https://api.statsig.com/openapi"); + rapidoc.loadSpec(specUrl); return; } @@ -39,7 +68,7 @@ export default function Rapidoc(props) { const tag = entityToTagMap[entity]; // Fetch and filter the spec by tag - fetch("https://api.statsig.com/openapi") + fetch(specUrl) .then((response) => response.json()) .then((data) => { if (tag) { @@ -54,7 +83,7 @@ export default function Rapidoc(props) { rapidoc.loadSpec(data); } }); - }, [entity]); + }, [specUrl, entity]); return ( +

+ API Version:{' '} + + {' '} + +

+

Authorization

All requests must include the STATSIG-API-KEY field in the @@ -98,6 +141,16 @@ export default function Rapidoc(props) { To use the 'try it' section on this page, enter your Console API into the box below.

+

API Version

+

+ The Console API is versioned. Each version is guaranteed to not break + existing usage; each new version introduces breaking changes. There is + currently only one version: 20240601. +
+ Pass the version in the STATSIG-API-VERSION field in the + header. For now, this is optional; in the future, this will be + required. +