@scalar/api-reference-react 0.0.2

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,11 @@
1
+ # @scalar/api-reference-react
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 775646a: feat: added react wrapper for api references
8
+ - Updated dependencies [ddc9b17]
9
+ - Updated dependencies [775646a]
10
+ - Updated dependencies [ef3a015]
11
+ - @scalar/api-reference@1.18.2
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,119 @@
1
+ # Scalar API Client React
2
+
3
+ [![Version](https://img.shields.io/npm/v/%40scalar/api-reference-react)](https://www.npmjs.com/package/@scalar/api-reference-react)
4
+ [![Downloads](https://img.shields.io/npm/dm/%40scalar/api-reference-react)](https://www.npmjs.com/package/@scalar/api-reference-react)
5
+ [![License](https://img.shields.io/npm/l/%40scalar%2Fapi-reference-react)](https://www.npmjs.com/package/@scalar/api-reference-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-reference-react
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { ApiReferenceReact } from '@scalar/api-reference-react'
19
+ import React from 'react'
20
+
21
+ function App() {
22
+ return (
23
+ <ApiReferenceReact
24
+ configuration={{
25
+ spec: {
26
+ url: 'https://petstore.swagger.io/v2/swagger.json',
27
+ },
28
+ }}
29
+ />
30
+ )
31
+ }
32
+
33
+ export default App
34
+ ```
35
+
36
+ ### Example
37
+
38
+ You can find an example in this repo under [examples/react](https://github.com/scalar/scalar/tree/main/examples/react)
39
+
40
+ ## Props
41
+
42
+ ApiReference only takes one prop which is the configuration object.
43
+
44
+ ### configuration: ReferenceProps
45
+
46
+ You can find the full configuration options under
47
+ [packages/api-reference](https://github.com/scalar/scalar/tree/main/packages/api-reference).
48
+ Here are the type definitions:
49
+
50
+ ```ts
51
+ export type ReferenceProps = {
52
+ configuration?: {
53
+ /** A string to use one of the color presets */
54
+ theme?: ThemeId
55
+ /** The layout to use for the references */
56
+ layout?: ReferenceLayoutType
57
+ /** The Swagger/OpenAPI spec to render */
58
+ spec?: {
59
+ /** URL to a Swagger/OpenAPI file */
60
+ url?: string
61
+ /** Swagger/Open API spec */
62
+ content?: string | Record<string, any> | (() => Record<string, any>)
63
+ }
64
+ /** URL to a request proxy for the API client */
65
+ proxy?: string
66
+ /** Whether the spec input should show */
67
+ isEditable?: boolean
68
+ /** Whether to show the sidebar */
69
+ showSidebar?: boolean
70
+ /** Whether dark mode is on or off (light mode) */
71
+ darkMode?: boolean
72
+ /** Key used with CNTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
73
+ searchHotKey?:
74
+ | 'a'
75
+ | 'b'
76
+ | 'c'
77
+ | 'd'
78
+ | 'e'
79
+ | 'f'
80
+ | 'g'
81
+ | 'h'
82
+ | 'i'
83
+ | 'j'
84
+ | 'k'
85
+ | 'l'
86
+ | 'm'
87
+ | 'n'
88
+ | 'o'
89
+ | 'p'
90
+ | 'q'
91
+ | 'r'
92
+ | 's'
93
+ | 't'
94
+ | 'u'
95
+ | 'v'
96
+ | 'w'
97
+ | 'x'
98
+ | 'y'
99
+ | 'z'
100
+ /**
101
+ * If used, passed data will be added to the HTML header
102
+ * @see https://unhead.unjs.io/usage/composables/use-seo-meta
103
+ * */
104
+ metaData?: MetaFlatInput
105
+ /**
106
+ * List of httpsnippet clients to hide from the clients menu
107
+ * By default hides Unirest, pass `[]` to show all clients
108
+ * @see https://github.com/Kong/httpsnippet/wiki/Targets
109
+ */
110
+ hiddenClients?: string[]
111
+ /** Custom CSS to be added to the page */
112
+ customCss?: string
113
+ /** onSpecUpdate is fired on spec/swagger content change */
114
+ onSpecUpdate?: (spec: string) => void
115
+ /** Prefill authentication */
116
+ authentication?: Partial<AuthenticationState>
117
+ }
118
+ }
119
+ ```