@stainless-api/docs 0.1.0-beta.91 → 0.1.0-beta.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.92
4
+
5
+ ### Patch Changes
6
+
7
+ - 61ba36f: add support for form data bodies
8
+ - Updated dependencies [61ba36f]
9
+ - @stainless-api/docs-ui@0.1.0-beta.69
10
+ - @stainless-api/docs-search@0.1.0-beta.22
11
+
3
12
  ## 0.1.0-beta.91
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.91",
3
+ "version": "0.1.0-beta.92",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -56,8 +56,8 @@
56
56
  "vite-plugin-prebundle-workers": "^0.2.0",
57
57
  "web-worker": "^1.5.0",
58
58
  "yaml": "^2.8.2",
59
- "@stainless-api/docs-search": "0.1.0-beta.21",
60
- "@stainless-api/docs-ui": "0.1.0-beta.68",
59
+ "@stainless-api/docs-search": "0.1.0-beta.22",
60
+ "@stainless-api/docs-ui": "0.1.0-beta.69",
61
61
  "@stainless-api/ui-primitives": "0.1.0-beta.47"
62
62
  },
63
63
  "devDependencies": {
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import * as SDKJSON from '@stainless/sdk-json';
3
3
  import { useSpec } from '@stainless-api/docs-ui/contexts';
4
- import { extractParams } from './spec-helpers';
4
+ import { extractParams, Param } from './spec-helpers';
5
5
  import type { SnippetStainlessIslandProps } from './props';
6
6
 
7
7
  /** Load and process the spec on the server side to avoid inflating client bundle */
@@ -14,9 +14,15 @@ export function RequestBuilder({
14
14
  children: ReactNode;
15
15
  method: SDKJSON.Method;
16
16
  }) {
17
+ let params: Param[];
17
18
  const spec = useSpec();
18
- if (!spec) throw new Error('Spec is required for RequestBuilder');
19
- const params = spec && extractParams(spec, method);
19
+ try {
20
+ if (!spec) throw new Error('Spec is required for RequestBuilder');
21
+ params = spec && extractParams(spec, method);
22
+ } catch (e) {
23
+ console.warn(e);
24
+ return <div className={className}>{children}</div>;
25
+ }
20
26
  const [httpMethod, path] = method.endpoint.split(' ') as [string, string];
21
27
 
22
28
  return (
@@ -1,6 +1,7 @@
1
1
  import type * as SDKJSON from '@stainless/sdk-json';
2
2
  import { printer } from '@stainless-api/docs-ui/markdown';
3
3
  import z from 'zod';
4
+ import { getBodyParams } from '@stainless-api/docs-ui/utils';
4
5
 
5
6
  export const ParamSchema = z.object({
6
7
  stainlessPath: z.string(),
@@ -20,14 +21,10 @@ export function extractParams(spec: SDKJSON.Spec | undefined, method: SDKJSON.Me
20
21
  'expected HttpDeclFunction at stainlessPath "' + method.stainlessPath + '", got ' + decl?.kind,
21
22
  );
22
23
  }
23
- const bodyTypes = Object.keys(decl.bodyParamsChildren ?? {});
24
- if (bodyTypes.length > 0 && !bodyTypes.includes('application/json')) {
25
- throw new Error('TODO: support non-json body params');
26
- }
27
- const bodyParams = decl.bodyParamsChildren?.['application/json'];
24
+ const bodyParams = getBodyParams(decl);
28
25
  const params = [
29
26
  ...Object.entries(decl.paramsChildren ?? {}).map(([location, children]) => ({ location, children })),
30
- ...(bodyParams ? [{ location: 'body', children: bodyParams }] : []),
27
+ ...(bodyParams ? [{ location: 'body', children: bodyParams.params }] : []),
31
28
  ]
32
29
  .filter((e) => e.children.length)
33
30
  .flatMap(({ location, children }) =>
package/styles/code.css CHANGED
@@ -170,10 +170,15 @@
170
170
  }
171
171
 
172
172
  .stldocs-snippet .stldocs-snippet-footer.try-it-footer {
173
- display: flex;
173
+ display: none;
174
174
  justify-content: flex-end;
175
175
  gap: 0.5rem;
176
176
 
177
+ /* only show footer if RequestBuilder was rendered successfully */
178
+ stl-island[component='SnippetStainlessIsland'] & {
179
+ display: flex;
180
+ }
181
+
177
182
  .try-it-button,
178
183
  .send-button {
179
184
  width: 7rem;