@scalar/nextjs-api-reference 0.6.0 → 0.7.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 +20 -0
- package/README.md +4 -12
- package/dist/index.cjs +87 -16
- package/dist/index.js +87 -16
- package/dist/index.umd.cjs +87 -16
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @scalar/nextjs-api-reference
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5f9a8a2: feat!: remove the spec prefix, make content and url top-level attributes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [5f9a8a2]
|
|
12
|
+
- @scalar/types@0.1.0
|
|
13
|
+
- @scalar/core@0.1.3
|
|
14
|
+
|
|
15
|
+
## 0.6.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [fc6a45e]
|
|
20
|
+
- @scalar/types@0.0.41
|
|
21
|
+
- @scalar/core@0.1.2
|
|
22
|
+
|
|
3
23
|
## 0.6.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -33,9 +33,7 @@ If you have a OpenAPI/Swagger file already, you can pass a URL to the plugin in
|
|
|
33
33
|
import { ApiReference } from '@scalar/nextjs-api-reference'
|
|
34
34
|
|
|
35
35
|
const config = {
|
|
36
|
-
|
|
37
|
-
url: '/openapi.json',
|
|
38
|
-
},
|
|
36
|
+
url: '/openapi.json',
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
export const GET = ApiReference(config)
|
|
@@ -45,9 +43,7 @@ Or, if you just have a static OpenAPI spec, you can directly pass it as well:
|
|
|
45
43
|
|
|
46
44
|
```ts
|
|
47
45
|
const config = {
|
|
48
|
-
|
|
49
|
-
content: '...',
|
|
50
|
-
},
|
|
46
|
+
content: '{ "openapi": "3.1.1", … }',
|
|
51
47
|
}
|
|
52
48
|
```
|
|
53
49
|
|
|
@@ -84,9 +80,7 @@ export default function References() {
|
|
|
84
80
|
return (
|
|
85
81
|
<ApiReferenceReact
|
|
86
82
|
configuration={{
|
|
87
|
-
|
|
88
|
-
url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
|
|
89
|
-
},
|
|
83
|
+
url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
|
|
90
84
|
}}
|
|
91
85
|
/>
|
|
92
86
|
)
|
|
@@ -106,9 +100,7 @@ You can find all available CDN versions [here](https://www.jsdelivr.com/package/
|
|
|
106
100
|
import { ApiReference } from '@scalar/nextjs-api-reference'
|
|
107
101
|
|
|
108
102
|
const config = {
|
|
109
|
-
|
|
110
|
-
url: '/openapi.json',
|
|
111
|
-
},
|
|
103
|
+
url: '/openapi.json',
|
|
112
104
|
cdn: 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@latest',
|
|
113
105
|
}
|
|
114
106
|
|
package/dist/index.cjs
CHANGED
|
@@ -3990,18 +3990,53 @@ const integrationEnum = z.enum([
|
|
|
3990
3990
|
"vue"
|
|
3991
3991
|
]).nullable();
|
|
3992
3992
|
const specConfigurationSchema = z.object({
|
|
3993
|
-
/**
|
|
3993
|
+
/**
|
|
3994
|
+
* URL to an OpenAPI/Swagger document
|
|
3995
|
+
*
|
|
3996
|
+
* @deprecated Please move `url` to the top level and remove the `spec` prefix.
|
|
3997
|
+
*
|
|
3998
|
+
* @example
|
|
3999
|
+
* ```ts
|
|
4000
|
+
* const oldConfiguration = {
|
|
4001
|
+
* spec: {
|
|
4002
|
+
* url: 'https://example.com/openapi.json',
|
|
4003
|
+
* },
|
|
4004
|
+
* }
|
|
4005
|
+
*
|
|
4006
|
+
* const newConfiguration = {
|
|
4007
|
+
* url: 'https://example.com/openapi.json',
|
|
4008
|
+
* }
|
|
4009
|
+
* ```
|
|
4010
|
+
**/
|
|
3994
4011
|
url: z.string().optional(),
|
|
3995
4012
|
/**
|
|
3996
4013
|
* Directly embed the OpenAPI document.
|
|
3997
4014
|
* Can be a string, object, function returning an object, or null.
|
|
4015
|
+
*
|
|
3998
4016
|
* @remarks It's recommended to pass a URL instead of content.
|
|
3999
|
-
|
|
4017
|
+
*
|
|
4018
|
+
* @deprecated Please move `content` to the top level and remove the `spec` prefix.
|
|
4019
|
+
*
|
|
4020
|
+
* @example
|
|
4021
|
+
* ```ts
|
|
4022
|
+
* const oldConfiguration = {
|
|
4023
|
+
* spec: {
|
|
4024
|
+
* content: '…',
|
|
4025
|
+
* },
|
|
4026
|
+
* }
|
|
4027
|
+
*
|
|
4028
|
+
* const newConfiguration = {
|
|
4029
|
+
* content: '…',
|
|
4030
|
+
* }
|
|
4031
|
+
* ```
|
|
4032
|
+
**/
|
|
4000
4033
|
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
4001
4034
|
/**
|
|
4002
4035
|
* The title of the OpenAPI document.
|
|
4003
4036
|
*
|
|
4004
4037
|
* @example 'Scalar Galaxy'
|
|
4038
|
+
*
|
|
4039
|
+
* @deprecated Please move `title` to the top level and remove the `spec` prefix.
|
|
4005
4040
|
*/
|
|
4006
4041
|
title: z.string().optional(),
|
|
4007
4042
|
/**
|
|
@@ -4012,6 +4047,8 @@ const specConfigurationSchema = z.object({
|
|
|
4012
4047
|
* If no title is used, it’ll just use the index.
|
|
4013
4048
|
*
|
|
4014
4049
|
* @example 'scalar-galaxy'
|
|
4050
|
+
*
|
|
4051
|
+
* @deprecated Please move `slug` to the top level and remove the `spec` prefix.
|
|
4015
4052
|
*/
|
|
4016
4053
|
slug: z.string().optional()
|
|
4017
4054
|
});
|
|
@@ -4020,6 +4057,39 @@ const pathRoutingSchema = z.object({
|
|
|
4020
4057
|
basePath: z.string()
|
|
4021
4058
|
});
|
|
4022
4059
|
const apiClientConfigurationSchema = z.object({
|
|
4060
|
+
/**
|
|
4061
|
+
* URL to an OpenAPI/Swagger document
|
|
4062
|
+
**/
|
|
4063
|
+
url: z.string().optional(),
|
|
4064
|
+
/**
|
|
4065
|
+
* Directly embed the OpenAPI document.
|
|
4066
|
+
* Can be a string, object, function returning an object, or null.
|
|
4067
|
+
*
|
|
4068
|
+
* @remarks It’s recommended to pass a URL instead of content.
|
|
4069
|
+
**/
|
|
4070
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
4071
|
+
/**
|
|
4072
|
+
* The title of the OpenAPI document.
|
|
4073
|
+
*
|
|
4074
|
+
* @example 'Scalar Galaxy'
|
|
4075
|
+
*/
|
|
4076
|
+
title: z.string().optional(),
|
|
4077
|
+
/**
|
|
4078
|
+
* The slug of the OpenAPI document used in the URL.
|
|
4079
|
+
*
|
|
4080
|
+
* If none is passed, the title will be used.
|
|
4081
|
+
*
|
|
4082
|
+
* If no title is used, it’ll just use the index.
|
|
4083
|
+
*
|
|
4084
|
+
* @example 'scalar-galaxy'
|
|
4085
|
+
*/
|
|
4086
|
+
slug: z.string().optional(),
|
|
4087
|
+
/**
|
|
4088
|
+
* The OpenAPI/Swagger document to render
|
|
4089
|
+
*
|
|
4090
|
+
* @deprecated Use `url` and `content` on the top level instead.
|
|
4091
|
+
**/
|
|
4092
|
+
spec: specConfigurationSchema.optional(),
|
|
4023
4093
|
/** Prefill authentication */
|
|
4024
4094
|
authentication: z.any().optional(),
|
|
4025
4095
|
// Temp until we bring in the new auth
|
|
@@ -4042,8 +4112,6 @@ const apiClientConfigurationSchema = z.object({
|
|
|
4042
4112
|
* @default true
|
|
4043
4113
|
*/
|
|
4044
4114
|
showSidebar: z.boolean().optional().default(true).catch(true),
|
|
4045
|
-
/** The Swagger/OpenAPI spec to render */
|
|
4046
|
-
spec: specConfigurationSchema.optional(),
|
|
4047
4115
|
/** A string to use one of the color presets */
|
|
4048
4116
|
theme: themeIdEnum.optional().default("default").catch("default"),
|
|
4049
4117
|
/** Integration type identifier */
|
|
@@ -4216,12 +4284,21 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
4216
4284
|
operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
|
|
4217
4285
|
}));
|
|
4218
4286
|
const _apiReferenceConfigurationWithSourcesSchema = _apiReferenceConfigurationSchema.merge(z.object({
|
|
4219
|
-
|
|
4220
|
-
sources: z.array(specConfigurationSchema)
|
|
4221
|
-
})
|
|
4287
|
+
sources: z.array(specConfigurationSchema)
|
|
4222
4288
|
}));
|
|
4223
4289
|
const migrateConfiguration = (_configuration) => {
|
|
4290
|
+
var _a, _b;
|
|
4224
4291
|
const configuration = { ..._configuration };
|
|
4292
|
+
if ((_a = configuration.spec) == null ? void 0 : _a.url) {
|
|
4293
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`);
|
|
4294
|
+
configuration.url = configuration.spec.url;
|
|
4295
|
+
delete configuration.spec;
|
|
4296
|
+
}
|
|
4297
|
+
if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4298
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`);
|
|
4299
|
+
configuration.content = configuration.spec.content;
|
|
4300
|
+
delete configuration.spec;
|
|
4301
|
+
}
|
|
4225
4302
|
if (configuration.customCss) {
|
|
4226
4303
|
configuration.customCss = migrateThemeVariables(configuration.customCss);
|
|
4227
4304
|
}
|
|
@@ -4291,21 +4368,15 @@ function getScriptTags(configuration, cdn) {
|
|
|
4291
4368
|
`;
|
|
4292
4369
|
}
|
|
4293
4370
|
const getConfiguration = (givenConfiguration) => {
|
|
4294
|
-
var _a, _b, _c;
|
|
4295
4371
|
const configuration = {
|
|
4296
4372
|
...givenConfiguration
|
|
4297
4373
|
};
|
|
4298
|
-
if (
|
|
4299
|
-
delete configuration.
|
|
4300
|
-
} else if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4301
|
-
(_c = configuration.spec) == null ? true : delete _c.content;
|
|
4374
|
+
if (configuration.content) {
|
|
4375
|
+
delete configuration.content;
|
|
4302
4376
|
}
|
|
4303
4377
|
return JSON.stringify(configuration).split('"').join(""");
|
|
4304
4378
|
};
|
|
4305
|
-
const getScriptTagContent = (configuration) =>
|
|
4306
|
-
var _a, _b, _c, _d;
|
|
4307
|
-
return ((_a = configuration.spec) == null ? void 0 : _a.content) ? typeof ((_b = configuration.spec) == null ? void 0 : _b.content) === "function" ? JSON.stringify((_c = configuration.spec) == null ? void 0 : _c.content()) : JSON.stringify((_d = configuration.spec) == null ? void 0 : _d.content) : "";
|
|
4308
|
-
};
|
|
4379
|
+
const getScriptTagContent = (configuration) => configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : "";
|
|
4309
4380
|
const customTheme = `
|
|
4310
4381
|
/* basic theme */
|
|
4311
4382
|
.dark-mode {
|
package/dist/index.js
CHANGED
|
@@ -3988,18 +3988,53 @@ const integrationEnum = z.enum([
|
|
|
3988
3988
|
"vue"
|
|
3989
3989
|
]).nullable();
|
|
3990
3990
|
const specConfigurationSchema = z.object({
|
|
3991
|
-
/**
|
|
3991
|
+
/**
|
|
3992
|
+
* URL to an OpenAPI/Swagger document
|
|
3993
|
+
*
|
|
3994
|
+
* @deprecated Please move `url` to the top level and remove the `spec` prefix.
|
|
3995
|
+
*
|
|
3996
|
+
* @example
|
|
3997
|
+
* ```ts
|
|
3998
|
+
* const oldConfiguration = {
|
|
3999
|
+
* spec: {
|
|
4000
|
+
* url: 'https://example.com/openapi.json',
|
|
4001
|
+
* },
|
|
4002
|
+
* }
|
|
4003
|
+
*
|
|
4004
|
+
* const newConfiguration = {
|
|
4005
|
+
* url: 'https://example.com/openapi.json',
|
|
4006
|
+
* }
|
|
4007
|
+
* ```
|
|
4008
|
+
**/
|
|
3992
4009
|
url: z.string().optional(),
|
|
3993
4010
|
/**
|
|
3994
4011
|
* Directly embed the OpenAPI document.
|
|
3995
4012
|
* Can be a string, object, function returning an object, or null.
|
|
4013
|
+
*
|
|
3996
4014
|
* @remarks It's recommended to pass a URL instead of content.
|
|
3997
|
-
|
|
4015
|
+
*
|
|
4016
|
+
* @deprecated Please move `content` to the top level and remove the `spec` prefix.
|
|
4017
|
+
*
|
|
4018
|
+
* @example
|
|
4019
|
+
* ```ts
|
|
4020
|
+
* const oldConfiguration = {
|
|
4021
|
+
* spec: {
|
|
4022
|
+
* content: '…',
|
|
4023
|
+
* },
|
|
4024
|
+
* }
|
|
4025
|
+
*
|
|
4026
|
+
* const newConfiguration = {
|
|
4027
|
+
* content: '…',
|
|
4028
|
+
* }
|
|
4029
|
+
* ```
|
|
4030
|
+
**/
|
|
3998
4031
|
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
3999
4032
|
/**
|
|
4000
4033
|
* The title of the OpenAPI document.
|
|
4001
4034
|
*
|
|
4002
4035
|
* @example 'Scalar Galaxy'
|
|
4036
|
+
*
|
|
4037
|
+
* @deprecated Please move `title` to the top level and remove the `spec` prefix.
|
|
4003
4038
|
*/
|
|
4004
4039
|
title: z.string().optional(),
|
|
4005
4040
|
/**
|
|
@@ -4010,6 +4045,8 @@ const specConfigurationSchema = z.object({
|
|
|
4010
4045
|
* If no title is used, it’ll just use the index.
|
|
4011
4046
|
*
|
|
4012
4047
|
* @example 'scalar-galaxy'
|
|
4048
|
+
*
|
|
4049
|
+
* @deprecated Please move `slug` to the top level and remove the `spec` prefix.
|
|
4013
4050
|
*/
|
|
4014
4051
|
slug: z.string().optional()
|
|
4015
4052
|
});
|
|
@@ -4018,6 +4055,39 @@ const pathRoutingSchema = z.object({
|
|
|
4018
4055
|
basePath: z.string()
|
|
4019
4056
|
});
|
|
4020
4057
|
const apiClientConfigurationSchema = z.object({
|
|
4058
|
+
/**
|
|
4059
|
+
* URL to an OpenAPI/Swagger document
|
|
4060
|
+
**/
|
|
4061
|
+
url: z.string().optional(),
|
|
4062
|
+
/**
|
|
4063
|
+
* Directly embed the OpenAPI document.
|
|
4064
|
+
* Can be a string, object, function returning an object, or null.
|
|
4065
|
+
*
|
|
4066
|
+
* @remarks It’s recommended to pass a URL instead of content.
|
|
4067
|
+
**/
|
|
4068
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
4069
|
+
/**
|
|
4070
|
+
* The title of the OpenAPI document.
|
|
4071
|
+
*
|
|
4072
|
+
* @example 'Scalar Galaxy'
|
|
4073
|
+
*/
|
|
4074
|
+
title: z.string().optional(),
|
|
4075
|
+
/**
|
|
4076
|
+
* The slug of the OpenAPI document used in the URL.
|
|
4077
|
+
*
|
|
4078
|
+
* If none is passed, the title will be used.
|
|
4079
|
+
*
|
|
4080
|
+
* If no title is used, it’ll just use the index.
|
|
4081
|
+
*
|
|
4082
|
+
* @example 'scalar-galaxy'
|
|
4083
|
+
*/
|
|
4084
|
+
slug: z.string().optional(),
|
|
4085
|
+
/**
|
|
4086
|
+
* The OpenAPI/Swagger document to render
|
|
4087
|
+
*
|
|
4088
|
+
* @deprecated Use `url` and `content` on the top level instead.
|
|
4089
|
+
**/
|
|
4090
|
+
spec: specConfigurationSchema.optional(),
|
|
4021
4091
|
/** Prefill authentication */
|
|
4022
4092
|
authentication: z.any().optional(),
|
|
4023
4093
|
// Temp until we bring in the new auth
|
|
@@ -4040,8 +4110,6 @@ const apiClientConfigurationSchema = z.object({
|
|
|
4040
4110
|
* @default true
|
|
4041
4111
|
*/
|
|
4042
4112
|
showSidebar: z.boolean().optional().default(true).catch(true),
|
|
4043
|
-
/** The Swagger/OpenAPI spec to render */
|
|
4044
|
-
spec: specConfigurationSchema.optional(),
|
|
4045
4113
|
/** A string to use one of the color presets */
|
|
4046
4114
|
theme: themeIdEnum.optional().default("default").catch("default"),
|
|
4047
4115
|
/** Integration type identifier */
|
|
@@ -4214,12 +4282,21 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
4214
4282
|
operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
|
|
4215
4283
|
}));
|
|
4216
4284
|
const _apiReferenceConfigurationWithSourcesSchema = _apiReferenceConfigurationSchema.merge(z.object({
|
|
4217
|
-
|
|
4218
|
-
sources: z.array(specConfigurationSchema)
|
|
4219
|
-
})
|
|
4285
|
+
sources: z.array(specConfigurationSchema)
|
|
4220
4286
|
}));
|
|
4221
4287
|
const migrateConfiguration = (_configuration) => {
|
|
4288
|
+
var _a, _b;
|
|
4222
4289
|
const configuration = { ..._configuration };
|
|
4290
|
+
if ((_a = configuration.spec) == null ? void 0 : _a.url) {
|
|
4291
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`);
|
|
4292
|
+
configuration.url = configuration.spec.url;
|
|
4293
|
+
delete configuration.spec;
|
|
4294
|
+
}
|
|
4295
|
+
if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4296
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`);
|
|
4297
|
+
configuration.content = configuration.spec.content;
|
|
4298
|
+
delete configuration.spec;
|
|
4299
|
+
}
|
|
4223
4300
|
if (configuration.customCss) {
|
|
4224
4301
|
configuration.customCss = migrateThemeVariables(configuration.customCss);
|
|
4225
4302
|
}
|
|
@@ -4289,21 +4366,15 @@ function getScriptTags(configuration, cdn) {
|
|
|
4289
4366
|
`;
|
|
4290
4367
|
}
|
|
4291
4368
|
const getConfiguration = (givenConfiguration) => {
|
|
4292
|
-
var _a, _b, _c;
|
|
4293
4369
|
const configuration = {
|
|
4294
4370
|
...givenConfiguration
|
|
4295
4371
|
};
|
|
4296
|
-
if (
|
|
4297
|
-
delete configuration.
|
|
4298
|
-
} else if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4299
|
-
(_c = configuration.spec) == null ? true : delete _c.content;
|
|
4372
|
+
if (configuration.content) {
|
|
4373
|
+
delete configuration.content;
|
|
4300
4374
|
}
|
|
4301
4375
|
return JSON.stringify(configuration).split('"').join(""");
|
|
4302
4376
|
};
|
|
4303
|
-
const getScriptTagContent = (configuration) =>
|
|
4304
|
-
var _a, _b, _c, _d;
|
|
4305
|
-
return ((_a = configuration.spec) == null ? void 0 : _a.content) ? typeof ((_b = configuration.spec) == null ? void 0 : _b.content) === "function" ? JSON.stringify((_c = configuration.spec) == null ? void 0 : _c.content()) : JSON.stringify((_d = configuration.spec) == null ? void 0 : _d.content) : "";
|
|
4306
|
-
};
|
|
4377
|
+
const getScriptTagContent = (configuration) => configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : "";
|
|
4307
4378
|
const customTheme = `
|
|
4308
4379
|
/* basic theme */
|
|
4309
4380
|
.dark-mode {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -3992,18 +3992,53 @@
|
|
|
3992
3992
|
"vue"
|
|
3993
3993
|
]).nullable();
|
|
3994
3994
|
const specConfigurationSchema = z.object({
|
|
3995
|
-
/**
|
|
3995
|
+
/**
|
|
3996
|
+
* URL to an OpenAPI/Swagger document
|
|
3997
|
+
*
|
|
3998
|
+
* @deprecated Please move `url` to the top level and remove the `spec` prefix.
|
|
3999
|
+
*
|
|
4000
|
+
* @example
|
|
4001
|
+
* ```ts
|
|
4002
|
+
* const oldConfiguration = {
|
|
4003
|
+
* spec: {
|
|
4004
|
+
* url: 'https://example.com/openapi.json',
|
|
4005
|
+
* },
|
|
4006
|
+
* }
|
|
4007
|
+
*
|
|
4008
|
+
* const newConfiguration = {
|
|
4009
|
+
* url: 'https://example.com/openapi.json',
|
|
4010
|
+
* }
|
|
4011
|
+
* ```
|
|
4012
|
+
**/
|
|
3996
4013
|
url: z.string().optional(),
|
|
3997
4014
|
/**
|
|
3998
4015
|
* Directly embed the OpenAPI document.
|
|
3999
4016
|
* Can be a string, object, function returning an object, or null.
|
|
4017
|
+
*
|
|
4000
4018
|
* @remarks It's recommended to pass a URL instead of content.
|
|
4001
|
-
|
|
4019
|
+
*
|
|
4020
|
+
* @deprecated Please move `content` to the top level and remove the `spec` prefix.
|
|
4021
|
+
*
|
|
4022
|
+
* @example
|
|
4023
|
+
* ```ts
|
|
4024
|
+
* const oldConfiguration = {
|
|
4025
|
+
* spec: {
|
|
4026
|
+
* content: '…',
|
|
4027
|
+
* },
|
|
4028
|
+
* }
|
|
4029
|
+
*
|
|
4030
|
+
* const newConfiguration = {
|
|
4031
|
+
* content: '…',
|
|
4032
|
+
* }
|
|
4033
|
+
* ```
|
|
4034
|
+
**/
|
|
4002
4035
|
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
4003
4036
|
/**
|
|
4004
4037
|
* The title of the OpenAPI document.
|
|
4005
4038
|
*
|
|
4006
4039
|
* @example 'Scalar Galaxy'
|
|
4040
|
+
*
|
|
4041
|
+
* @deprecated Please move `title` to the top level and remove the `spec` prefix.
|
|
4007
4042
|
*/
|
|
4008
4043
|
title: z.string().optional(),
|
|
4009
4044
|
/**
|
|
@@ -4014,6 +4049,8 @@
|
|
|
4014
4049
|
* If no title is used, it’ll just use the index.
|
|
4015
4050
|
*
|
|
4016
4051
|
* @example 'scalar-galaxy'
|
|
4052
|
+
*
|
|
4053
|
+
* @deprecated Please move `slug` to the top level and remove the `spec` prefix.
|
|
4017
4054
|
*/
|
|
4018
4055
|
slug: z.string().optional()
|
|
4019
4056
|
});
|
|
@@ -4022,6 +4059,39 @@
|
|
|
4022
4059
|
basePath: z.string()
|
|
4023
4060
|
});
|
|
4024
4061
|
const apiClientConfigurationSchema = z.object({
|
|
4062
|
+
/**
|
|
4063
|
+
* URL to an OpenAPI/Swagger document
|
|
4064
|
+
**/
|
|
4065
|
+
url: z.string().optional(),
|
|
4066
|
+
/**
|
|
4067
|
+
* Directly embed the OpenAPI document.
|
|
4068
|
+
* Can be a string, object, function returning an object, or null.
|
|
4069
|
+
*
|
|
4070
|
+
* @remarks It’s recommended to pass a URL instead of content.
|
|
4071
|
+
**/
|
|
4072
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
4073
|
+
/**
|
|
4074
|
+
* The title of the OpenAPI document.
|
|
4075
|
+
*
|
|
4076
|
+
* @example 'Scalar Galaxy'
|
|
4077
|
+
*/
|
|
4078
|
+
title: z.string().optional(),
|
|
4079
|
+
/**
|
|
4080
|
+
* The slug of the OpenAPI document used in the URL.
|
|
4081
|
+
*
|
|
4082
|
+
* If none is passed, the title will be used.
|
|
4083
|
+
*
|
|
4084
|
+
* If no title is used, it’ll just use the index.
|
|
4085
|
+
*
|
|
4086
|
+
* @example 'scalar-galaxy'
|
|
4087
|
+
*/
|
|
4088
|
+
slug: z.string().optional(),
|
|
4089
|
+
/**
|
|
4090
|
+
* The OpenAPI/Swagger document to render
|
|
4091
|
+
*
|
|
4092
|
+
* @deprecated Use `url` and `content` on the top level instead.
|
|
4093
|
+
**/
|
|
4094
|
+
spec: specConfigurationSchema.optional(),
|
|
4025
4095
|
/** Prefill authentication */
|
|
4026
4096
|
authentication: z.any().optional(),
|
|
4027
4097
|
// Temp until we bring in the new auth
|
|
@@ -4044,8 +4114,6 @@
|
|
|
4044
4114
|
* @default true
|
|
4045
4115
|
*/
|
|
4046
4116
|
showSidebar: z.boolean().optional().default(true).catch(true),
|
|
4047
|
-
/** The Swagger/OpenAPI spec to render */
|
|
4048
|
-
spec: specConfigurationSchema.optional(),
|
|
4049
4117
|
/** A string to use one of the color presets */
|
|
4050
4118
|
theme: themeIdEnum.optional().default("default").catch("default"),
|
|
4051
4119
|
/** Integration type identifier */
|
|
@@ -4218,12 +4286,21 @@
|
|
|
4218
4286
|
operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
|
|
4219
4287
|
}));
|
|
4220
4288
|
const _apiReferenceConfigurationWithSourcesSchema = _apiReferenceConfigurationSchema.merge(z.object({
|
|
4221
|
-
|
|
4222
|
-
sources: z.array(specConfigurationSchema)
|
|
4223
|
-
})
|
|
4289
|
+
sources: z.array(specConfigurationSchema)
|
|
4224
4290
|
}));
|
|
4225
4291
|
const migrateConfiguration = (_configuration) => {
|
|
4292
|
+
var _a, _b;
|
|
4226
4293
|
const configuration = { ..._configuration };
|
|
4294
|
+
if ((_a = configuration.spec) == null ? void 0 : _a.url) {
|
|
4295
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`);
|
|
4296
|
+
configuration.url = configuration.spec.url;
|
|
4297
|
+
delete configuration.spec;
|
|
4298
|
+
}
|
|
4299
|
+
if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4300
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`);
|
|
4301
|
+
configuration.content = configuration.spec.content;
|
|
4302
|
+
delete configuration.spec;
|
|
4303
|
+
}
|
|
4227
4304
|
if (configuration.customCss) {
|
|
4228
4305
|
configuration.customCss = migrateThemeVariables(configuration.customCss);
|
|
4229
4306
|
}
|
|
@@ -4293,21 +4370,15 @@
|
|
|
4293
4370
|
`;
|
|
4294
4371
|
}
|
|
4295
4372
|
const getConfiguration = (givenConfiguration) => {
|
|
4296
|
-
var _a, _b, _c;
|
|
4297
4373
|
const configuration = {
|
|
4298
4374
|
...givenConfiguration
|
|
4299
4375
|
};
|
|
4300
|
-
if (
|
|
4301
|
-
delete configuration.
|
|
4302
|
-
} else if ((_b = configuration.spec) == null ? void 0 : _b.content) {
|
|
4303
|
-
(_c = configuration.spec) == null ? true : delete _c.content;
|
|
4376
|
+
if (configuration.content) {
|
|
4377
|
+
delete configuration.content;
|
|
4304
4378
|
}
|
|
4305
4379
|
return JSON.stringify(configuration).split('"').join(""");
|
|
4306
4380
|
};
|
|
4307
|
-
const getScriptTagContent = (configuration) =>
|
|
4308
|
-
var _a, _b, _c, _d;
|
|
4309
|
-
return ((_a = configuration.spec) == null ? void 0 : _a.content) ? typeof ((_b = configuration.spec) == null ? void 0 : _b.content) === "function" ? JSON.stringify((_c = configuration.spec) == null ? void 0 : _c.content()) : JSON.stringify((_d = configuration.spec) == null ? void 0 : _d.content) : "";
|
|
4310
|
-
};
|
|
4381
|
+
const getScriptTagContent = (configuration) => configuration.content ? typeof configuration.content === "function" ? JSON.stringify(configuration.content()) : JSON.stringify(configuration.content) : "";
|
|
4311
4382
|
const customTheme = `
|
|
4312
4383
|
/* basic theme */
|
|
4313
4384
|
.dark-mode {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"openapi",
|
|
19
19
|
"swagger"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.
|
|
21
|
+
"version": "0.7.0",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
],
|
|
36
36
|
"module": "./dist/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@scalar/
|
|
39
|
-
"@scalar/
|
|
38
|
+
"@scalar/types": "0.1.0",
|
|
39
|
+
"@scalar/core": "0.1.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^20.17.10",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-dom": "^19.0.0",
|
|
48
48
|
"vite": "^5.4.10",
|
|
49
49
|
"vite-plugin-dts": "^4.3.0",
|
|
50
|
-
"@scalar/api-reference": "1.
|
|
50
|
+
"@scalar/api-reference": "1.28.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^19.0.0",
|