|
| 1 | +--- |
| 2 | +title: "Fields" |
| 3 | +description: "Set parameters for your API or SDK references" |
| 4 | +icon: 'letter-text' |
| 5 | +--- |
| 6 | + |
| 7 | +There are two types of fields: Paramameter Fields and Response Fields. |
| 8 | + |
| 9 | +## Paramameter Field |
| 10 | + |
| 11 | +A `ParamField` component is used to define the parameters for your APIs or SDKs. Adding a `ParamField` will automatically add an [API Playground](/api-playground/overview). |
| 12 | + |
| 13 | +<ParamField path="param" type="string" required> |
| 14 | + An example of a parameter field |
| 15 | +</ParamField> |
| 16 | + |
| 17 | +<RequestExample> |
| 18 | + |
| 19 | +```jsx Path Example |
| 20 | +<ParamField path="param" type="string"> |
| 21 | + An example of a parameter field |
| 22 | +</ParamField> |
| 23 | +``` |
| 24 | + |
| 25 | +```jsx Body Example |
| 26 | +<ParamField body="user_age" type="integer" default="0" required> |
| 27 | + The age of the user. Cannot be less than 0 |
| 28 | +</ParamField> |
| 29 | +``` |
| 30 | + |
| 31 | +```jsx Response Example |
| 32 | +<ResponseField name="response" type="string" required> |
| 33 | + A response field example |
| 34 | +</ResponseField> |
| 35 | +``` |
| 36 | + |
| 37 | +</RequestExample> |
| 38 | + |
| 39 | +### Props |
| 40 | + |
| 41 | +<ParamField body="query, path, body, or header" type="string"> |
| 42 | + Whether it is a query, path, body, or header parameter followed by the name |
| 43 | +</ParamField> |
| 44 | + |
| 45 | +<ParamField body="type" type="string"> |
| 46 | + Expected type of the parameter's value |
| 47 | + |
| 48 | + Supports `number`, `string`, `bool`, `object`. |
| 49 | + |
| 50 | + Arrays can be defined using the `[]` suffix. For example `string[]`. |
| 51 | +</ParamField> |
| 52 | + |
| 53 | +<ParamField body="required" type="boolean"> |
| 54 | + Indicate whether the parameter is required |
| 55 | +</ParamField> |
| 56 | + |
| 57 | +<ParamField body="deprecated" type="boolean"> |
| 58 | + Indicate whether the parameter is deprecated |
| 59 | +</ParamField> |
| 60 | + |
| 61 | +<ParamField body="default" type="string"> |
| 62 | + Default value used by the server if the request does not provide a value |
| 63 | +</ParamField> |
| 64 | + |
| 65 | +<ParamField body="initialValue" type="any"> |
| 66 | + Value that will be used to initialize the playground |
| 67 | +</ParamField> |
| 68 | + |
| 69 | +<ParamField body="placeholder" type="string"> |
| 70 | + Placeholder text for the input in the playground |
| 71 | +</ParamField> |
| 72 | + |
| 73 | +<ParamField body="children" type="string"> |
| 74 | + Description of the parameter (markdown enabled) |
| 75 | +</ParamField> |
| 76 | + |
| 77 | +## Response Field |
| 78 | + |
| 79 | +The `<ResponseField>` component is designed to define the return values of an API. Many docs also use `<ResponseField>` on pages when you need to list the types of something. |
| 80 | + |
| 81 | +<ResponseField name="response" type="string" required> |
| 82 | + A response field example |
| 83 | +</ResponseField> |
| 84 | + |
| 85 | +```jsx |
| 86 | +<ResponseField name="response" type="string" required> |
| 87 | + A response field example |
| 88 | +</ResponseField> |
| 89 | +``` |
| 90 | + |
| 91 | +### Props |
| 92 | + |
| 93 | +<ResponseField name="name" type="string" required> |
| 94 | + The name of the response value. |
| 95 | +</ResponseField> |
| 96 | + |
| 97 | +<ResponseField name="type" type="string" required> |
| 98 | + Expected type of the response value - this can be any arbitrary string. |
| 99 | +</ResponseField> |
| 100 | + |
| 101 | +<ResponseField name="default" type="string"> |
| 102 | + The default value. |
| 103 | +</ResponseField> |
| 104 | + |
| 105 | +<ResponseField name="required" type="boolean"> |
| 106 | + Show "required" beside the field name. |
| 107 | +</ResponseField> |
| 108 | + |
| 109 | +<ResponseField name="deprecated" type="boolean"> |
| 110 | + Whether a field is deprecated or not. |
| 111 | +</ResponseField> |
| 112 | + |
| 113 | +<ResponseField name="pre" type="string[]"> |
| 114 | + Labels that are shown before the name of the field |
| 115 | +</ResponseField> |
| 116 | + |
| 117 | +<ResponseField name="post" type="string[]"> |
| 118 | + Labels that are shown after the name of the field |
| 119 | +</ResponseField> |
0 commit comments