@scalar/api-reference 1.24.15 → 1.24.17
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 +29 -0
- package/README.md +84 -249
- package/dist/browser/standalone.js +16598 -13496
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/ApiClientModal.vue.js +26 -0
- package/dist/components/ApiClientModal.vue2.js +4 -0
- package/dist/components/ApiReferenceLayout.vue.d.ts.map +1 -1
- package/dist/components/ApiReferenceLayout.vue.js +1 -1
- package/dist/components/ApiReferenceLayout.vue2.js +156 -138
- package/dist/components/Content/Operation/PathResponses/ExampleResponse.vue.d.ts.map +1 -1
- package/dist/components/Content/Operation/PathResponses/ExampleResponse.vue.js +2 -2
- package/dist/components/Content/Operation/PathResponses/ExampleResponse.vue2.js +55 -44
- package/dist/components/MobileHeader.vue.d.ts.map +1 -1
- package/dist/components/MobileHeader.vue.js +3 -3
- package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.vue.js +1 -1
- package/dist/hooks/useReactiveSpec.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @scalar/api-reference
|
|
2
2
|
|
|
3
|
+
## 1.24.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c20c7d0]
|
|
8
|
+
- Updated dependencies [c20c7d0]
|
|
9
|
+
- @scalar/components@0.12.1
|
|
10
|
+
- @scalar/oas-utils@0.2.4
|
|
11
|
+
- @scalar/api-client@1.3.16
|
|
12
|
+
- @scalar/api-client-modal@0.0.13
|
|
13
|
+
|
|
14
|
+
## 1.24.16
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 716811f: fix: HTML API does not work with YAML content inside script tag
|
|
19
|
+
- 5812c2f: feat: allow custom headers
|
|
20
|
+
- ee5fdee: fix: api reference allof items merge objects
|
|
21
|
+
- Updated dependencies [e4419ce]
|
|
22
|
+
- Updated dependencies [e5ac3e1]
|
|
23
|
+
- Updated dependencies [f2c1019]
|
|
24
|
+
- Updated dependencies [fd0c93d]
|
|
25
|
+
- Updated dependencies [7b87b8c]
|
|
26
|
+
- Updated dependencies [512c815]
|
|
27
|
+
- @scalar/components@0.12.0
|
|
28
|
+
- @scalar/use-tooltip@1.0.0
|
|
29
|
+
- @scalar/api-client@1.3.15
|
|
30
|
+
- @scalar/api-client-modal@0.0.12
|
|
31
|
+
|
|
3
32
|
## 1.24.15
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -29,284 +29,119 @@ import '@scalar/api-reference/style.css'
|
|
|
29
29
|
</template>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- pl4n3t5
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### x-tagGroup
|
|
61
|
-
|
|
62
|
-
You can group your tags with `x-tagGroup`.
|
|
63
|
-
|
|
64
|
-
```diff
|
|
65
|
-
openapi: 3.1.0
|
|
66
|
-
info:
|
|
67
|
-
title: Example
|
|
68
|
-
version: "1.0"
|
|
69
|
-
tags:
|
|
70
|
-
- name: planets
|
|
71
|
-
+x-tagGroups:
|
|
72
|
-
+ - name: galaxy
|
|
73
|
-
+ tags:
|
|
74
|
-
+ - planets
|
|
75
|
-
paths:
|
|
76
|
-
'/planets':
|
|
77
|
-
get:
|
|
78
|
-
summary: Get all planets
|
|
79
|
-
tags:
|
|
80
|
-
- planets
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### x-internal
|
|
84
|
-
|
|
85
|
-
You can hide operations from the reference with `x-internal`.
|
|
86
|
-
|
|
87
|
-
```diff
|
|
88
|
-
openapi: 3.1.0
|
|
89
|
-
info:
|
|
90
|
-
title: Example
|
|
91
|
-
version: "1.0"
|
|
92
|
-
paths:
|
|
93
|
-
'/planets':
|
|
94
|
-
get:
|
|
95
|
-
summary: Get all planets
|
|
96
|
-
post:
|
|
97
|
-
summary: Create a new planet
|
|
98
|
-
+ x-internal: true
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Configuration
|
|
102
|
-
|
|
103
|
-
There’s a configuration object that can be used on all platforms. In Vue.js, you use it like this:
|
|
104
|
-
|
|
105
|
-
#### isEditable?: boolean
|
|
106
|
-
|
|
107
|
-
Whether the Swagger editor should be shown.
|
|
108
|
-
|
|
109
|
-
```vue
|
|
110
|
-
<ApiReference :configuration="{ isEditable: true }" />
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
#### spec.content?: string
|
|
114
|
-
|
|
115
|
-
Directly pass an OpenAPI/Swagger spec.
|
|
32
|
+
### CDN
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<!doctype html>
|
|
36
|
+
<html>
|
|
37
|
+
<head>
|
|
38
|
+
<title>Scalar API Reference</title>
|
|
39
|
+
<meta charset="utf-8" />
|
|
40
|
+
<meta
|
|
41
|
+
name="viewport"
|
|
42
|
+
content="width=device-width, initial-scale=1" />
|
|
43
|
+
</head>
|
|
44
|
+
<body>
|
|
45
|
+
<!-- Add your own OpenAPI/Swagger specification URL here: -->
|
|
46
|
+
<!-- Note: The example is our public proxy (to avoid CORS issues). You can remove the `data-proxy-url` attribute if you don’t need it. -->
|
|
47
|
+
<script
|
|
48
|
+
id="api-reference"
|
|
49
|
+
data-url="https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml"
|
|
50
|
+
data-proxy-url="https://proxy.scalar.com"></script>
|
|
51
|
+
|
|
52
|
+
<!-- Optional: You can set a full configuration object like this: -->
|
|
53
|
+
<script>
|
|
54
|
+
var configuration = {
|
|
55
|
+
theme: 'purple',
|
|
56
|
+
}
|
|
116
57
|
|
|
117
|
-
|
|
118
|
-
|
|
58
|
+
document.getElementById('api-reference').dataset.configuration =
|
|
59
|
+
JSON.stringify(configuration)
|
|
60
|
+
</script>
|
|
61
|
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
119
64
|
```
|
|
120
65
|
|
|
121
|
-
|
|
66
|
+
You can also use the following syntax to directly pass an OpenAPI specification:
|
|
122
67
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
68
|
+
```html
|
|
69
|
+
<script
|
|
70
|
+
id="api-reference"
|
|
71
|
+
type="application/json">
|
|
72
|
+
{ … }
|
|
73
|
+
</script>
|
|
127
74
|
```
|
|
128
75
|
|
|
129
|
-
|
|
76
|
+
If you’d like to add a request proxy for the API client (to avoid CORS issues):
|
|
130
77
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
78
|
+
```html
|
|
79
|
+
<script
|
|
80
|
+
id="api-reference"
|
|
81
|
+
type="application/json"
|
|
82
|
+
data-proxy-url="https://proxy.scalar.com">
|
|
83
|
+
{ … }
|
|
84
|
+
</script>
|
|
135
85
|
```
|
|
136
86
|
|
|
137
|
-
|
|
87
|
+
#### Events [beta]
|
|
138
88
|
|
|
139
|
-
|
|
140
|
-
<ApiReference :configuration="{ proxy: 'https://proxy.scalar.com' }" />
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
If you like to run your own, check out our [example proxy written in Go](https://github.com/scalar/scalar/tree/main/examples/proxy-server).
|
|
89
|
+
We have recently added two events to the standalone CDN build only.
|
|
144
90
|
|
|
145
|
-
|
|
91
|
+
##### scalar:reload-references
|
|
146
92
|
|
|
147
|
-
|
|
93
|
+
Reload the references, this will re-mount the app in case you have switched pages or the dom
|
|
94
|
+
elements have been removed.
|
|
148
95
|
|
|
149
|
-
```
|
|
150
|
-
|
|
96
|
+
```ts
|
|
97
|
+
document.dispatchEvent(new Event('scalar:reload-references'))
|
|
151
98
|
```
|
|
152
99
|
|
|
153
|
-
|
|
100
|
+
##### scalar:update-references-config
|
|
154
101
|
|
|
155
|
-
|
|
102
|
+
If you have updated the config or spec, you can trigger this event with the new payload to update
|
|
103
|
+
the app. It should update reactively so you do not need to trigger the reload event above after.
|
|
156
104
|
|
|
157
|
-
|
|
105
|
+
```ts
|
|
106
|
+
import { type ReferenceProps } from './types'
|
|
158
107
|
|
|
159
|
-
|
|
160
|
-
|
|
108
|
+
const ev = new CustomEvent('scalar:update-references-config', {
|
|
109
|
+
detail: {
|
|
110
|
+
configuration: {
|
|
111
|
+
spec: {
|
|
112
|
+
url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
} satisfies ReferenceProps,
|
|
116
|
+
})
|
|
117
|
+
document.dispatchEvent(ev)
|
|
161
118
|
```
|
|
162
119
|
|
|
163
|
-
|
|
120
|
+
## Vue.js
|
|
164
121
|
|
|
165
|
-
|
|
122
|
+
The API Reference is built in Vue.js. If you’re working in Vue.js, too, you can directly use our Vue components.
|
|
123
|
+
Install them via `npm`:
|
|
166
124
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
```vue
|
|
170
|
-
<ApiReference :configuration="{ hideDownloadButton: true } />
|
|
125
|
+
```bash
|
|
126
|
+
npm install @scalar/api-reference
|
|
171
127
|
```
|
|
172
128
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
You can pass custom CSS directly to the component. This is helpful for the integrations for Fastify, Express, Hono and others where you it’s easier to add CSS to the configuration.
|
|
176
|
-
|
|
177
|
-
In Vue or React you’d probably use other ways to add custom CSS.
|
|
129
|
+
And import the `ApiReference` component and style to your app:
|
|
178
130
|
|
|
179
131
|
```vue
|
|
180
|
-
<script setup>
|
|
181
|
-
|
|
132
|
+
<script setup lang="ts">
|
|
133
|
+
import { ApiReference } from '@scalar/api-reference'
|
|
134
|
+
import '@scalar/api-reference/style.css'
|
|
182
135
|
</script>
|
|
183
136
|
|
|
184
137
|
<template>
|
|
185
|
-
<ApiReference
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
#### searchHotKey?: string
|
|
190
|
-
|
|
191
|
-
Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k)
|
|
192
|
-
|
|
193
|
-
```vue
|
|
194
|
-
<ApiReference :configuration="{ searchHotKey: 'l'} />
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
#### servers?: Server[]
|
|
198
|
-
|
|
199
|
-
List of servers to override the openapi spec servers
|
|
200
|
-
|
|
201
|
-
@default undefined
|
|
202
|
-
@example [{ url: 'https://api.scalar.com', description: 'Production server' }]
|
|
203
|
-
|
|
204
|
-
```vue
|
|
205
|
-
<ApiReference :configuration="{ servers: [{ url: 'https://api.scalar.com', description: 'Production server' }] } />
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
#### metaData?: object
|
|
209
|
-
|
|
210
|
-
You can pass information to the config object to configure meta information out of the box.
|
|
211
|
-
|
|
212
|
-
```vue
|
|
213
|
-
<ApiReference :configuration="{
|
|
214
|
-
metaData: {
|
|
215
|
-
title: 'Page title',
|
|
216
|
-
description: 'My page page',
|
|
217
|
-
ogDescription: 'Still about my my page',
|
|
218
|
-
ogTitle: 'Page title',
|
|
219
|
-
ogImage: 'https://example.com/image.png',
|
|
220
|
-
twitterCard: 'summary_large_image',
|
|
221
|
-
//Add more...
|
|
222
|
-
}
|
|
223
|
-
} />
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
#### hiddenClients?: array | true
|
|
227
|
-
|
|
228
|
-
You can pass an array of [httpsnippet clients](https://github.com/Kong/httpsnippet/wiki/Targets) to hide from the clients menu.
|
|
229
|
-
|
|
230
|
-
```vue
|
|
231
|
-
<ApiReference :configuration="{
|
|
232
|
-
hiddenClients: ['fetch']
|
|
233
|
-
} />
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
By default hides Unirest, pass `[]` to **show** all clients or `true` to **hide** all clients:
|
|
237
|
-
|
|
238
|
-
```vue
|
|
239
|
-
<ApiReference :configuration="{
|
|
240
|
-
hiddenClients: true
|
|
241
|
-
} />
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
#### onSpecUpdate?: (spec: string) => void
|
|
245
|
-
|
|
246
|
-
You can listen to spec changes with onSpecUpdate that runs on spec/swagger content change
|
|
247
|
-
|
|
248
|
-
```vue
|
|
249
|
-
<ApiReference :configuration="{
|
|
250
|
-
onSpecUpdate: (value: string) => {
|
|
251
|
-
console.log('Content updated:', value)
|
|
252
|
-
}
|
|
253
|
-
} />
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
#### authentication?: Partial<AuthenticationState>
|
|
257
|
-
|
|
258
|
-
To make authentication easier you can prefill the credentials for your users:
|
|
259
|
-
|
|
260
|
-
```vue
|
|
261
|
-
<ApiReference :configuration="{
|
|
262
|
-
authentication: {
|
|
263
|
-
// The OpenAPI file has keys for all security schemes:
|
|
264
|
-
// Which one should be used by default?
|
|
265
|
-
preferredSecurityScheme: 'my_custom_security_scheme',
|
|
266
|
-
// The `my_custom_security_scheme` security scheme is of type `apiKey`, so prefill the token:
|
|
267
|
-
apiKey: {
|
|
268
|
-
token: 'super-secret-token',
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
} />
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
For OpenAuth2 it’s more looking like this:
|
|
275
|
-
|
|
276
|
-
```vue
|
|
277
|
-
<ApiReference :configuration="{
|
|
278
|
-
authentication: {
|
|
279
|
-
// The OpenAPI file has keys for all security schemes
|
|
280
|
-
// Which one should be used by default?
|
|
281
|
-
preferredSecurityScheme: 'oauth2',
|
|
282
|
-
// The `oauth2` security scheme is of type `oAuth2`, so prefill the client id and the scopes:
|
|
283
|
-
oAuth2: {
|
|
284
|
-
clientId: 'foobar123',
|
|
285
|
-
// optional:
|
|
286
|
-
scopes: ['read:planets', 'write:planets'],
|
|
138
|
+
<ApiReference
|
|
139
|
+
:configuration="{
|
|
140
|
+
spec: {
|
|
141
|
+
url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml',
|
|
287
142
|
},
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
#### withDefaultFonts?: boolean
|
|
293
|
-
|
|
294
|
-
By default we’re using Inter and JetBrains Mono, served by Google Fonts. If you use a different font or just don’t want to use Google Fonts, pass `withDefaultFonts: false` to the configuration.
|
|
295
|
-
|
|
296
|
-
```vue
|
|
297
|
-
<ApiReference :configuration="{
|
|
298
|
-
withDefaultFonts: false
|
|
299
|
-
} />
|
|
143
|
+
}" />
|
|
144
|
+
</template>
|
|
300
145
|
```
|
|
301
146
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
You don’t like the color scheme? We’ve prepared some themes for you:
|
|
305
|
-
|
|
306
|
-
Can be one of: **alternate**, **default**, **moon**, **purple**, **solarized**, **bluePlanet**, **saturn**, **kepler**, **mars**, **deepSpace**, **none**
|
|
307
|
-
|
|
308
|
-
```vue
|
|
309
|
-
<ApiReference :configuration="{
|
|
310
|
-
theme: default
|
|
311
|
-
} />
|
|
312
|
-
```
|
|
147
|
+
You can [pass props to customize the API reference](https://github.com/scalar/scalar/tree/main/documentation/configuration.md).
|