@scalar/api-client-react 0.1.0

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 ADDED
@@ -0,0 +1,12 @@
1
+ # @scalar/api-client-react
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 407a3af: feat: added new client only react wrapper for the api-client
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5bc2ebf]
12
+ - @scalar/api-client@0.12.12
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Scalar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # Scalar API Client React
2
+
3
+ [![Version](https://img.shields.io/npm/v/%40scalar/api-client-react)](https://www.npmjs.com/package/@scalar/api-client-react)
4
+ [![Downloads](https://img.shields.io/npm/dm/%40scalar/api-client-react)](https://www.npmjs.com/package/@scalar/api-client-react)
5
+ [![License](https://img.shields.io/npm/l/%40scalar%2Fapi-client-react)](https://www.npmjs.com/package/@scalar/api-client-react)
6
+
7
+ [![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)](https://discord.gg/8HeZcRGPFS)
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @scalar/api-client-react
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { ApiClientReact } from '@scalar/api-client-react'
19
+ import React, { useState } from 'react'
20
+
21
+ export const Wrapper = () => {
22
+ const [isOpen, setIsOpen] = useState(false)
23
+
24
+ return (
25
+ <>
26
+ <button onClick={() => setIsOpen(true)}>
27
+ Click me to open the Api Client
28
+ </button>
29
+
30
+ <ApiClientReact
31
+ close={() => setIsOpen(false)}
32
+ isOpen={isOpen}
33
+ request={{
34
+ url: 'https://api.sampleapis.com',
35
+ type: 'GET',
36
+ path: '/simpsons/products',
37
+ }}
38
+ />
39
+ </>
40
+ )
41
+ }
42
+ ```
43
+
44
+ You will also need one of the following classes on a parent element:
45
+
46
+ ```css
47
+ .dark-mode
48
+ .light-mode
49
+ ```
50
+
51
+ ## Props
52
+
53
+ ### close: function
54
+
55
+ function to close the dialog, as seen above
56
+
57
+ ### isOpen: boolean
58
+
59
+ boolean which controls the visibility of the dialog containing the client
60
+
61
+ ### request: ClientRequestConfig
62
+
63
+ ```ts
64
+ export type ClientRequestConfig = {
65
+ id?: string
66
+ name?: string
67
+ url: string
68
+ /** HTTP Request Method */
69
+ type: string
70
+ /** Request path */
71
+ path: string
72
+ /** Variables */
73
+ variables?: BaseParameter[]
74
+ /** Query parameters */
75
+ query?: Query[]
76
+ /** Cookies */
77
+ cookies?: Cookie[]
78
+ /** Request headers */
79
+ headers?: Header[]
80
+ /** Content type matched body */
81
+ body?: string
82
+ /** Optional form data body */
83
+ formData?: FormDataItem[]
84
+ }
85
+ ```
86
+
87
+ ## ApiClientReactBase
88
+
89
+ We also export the base component if you do not want the modal.
90
+ `ApiClientReactBase`
91
+
92
+ Details on how to use it can be found in the source code for `ApiClientReact`