/
options.ts
61 lines (54 loc) · 1.46 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
58
59
60
61
import { Joi } from '@docusaurus/utils-validation';
import type { RawConfig } from '@redocly/openapi-core';
type LayoutProps = {
title?: string;
noFooter?: boolean;
description?: string;
image?: string;
keywords?: string[];
permalink?: string;
wrapperClassName?: string;
searchMetadatas?: {
version?: string;
tag?: string;
};
};
/**
* Can pass only if directly using plugin.
* `redocusaurus` auto populates them
*/
export interface PluginDirectUsageOptions {
debug?: boolean;
themeId?: string;
/**
* Redocly config to bundle file
* @see https://redocly.com/docs/cli/configuration/configuration-file/
*/
config?: string | RawConfig;
layout?: LayoutProps;
}
export interface PluginOptions extends PluginDirectUsageOptions {
id?: string;
spec: string;
url?: string;
route?: string;
}
export interface PluginOptionsWithDefault extends PluginOptions {
debug: boolean;
}
export const DEFAULT_OPTIONS = {
layout: {},
debug: false,
} satisfies Omit<PluginOptions, 'spec'>;
export const PluginOptionSchema = Joi.object<PluginOptions>({
// Direct Usage without redocusaurus preset
id: Joi.string(),
debug: Joi.boolean().default(DEFAULT_OPTIONS.debug),
config: Joi.any().optional(),
themeId: Joi.string().optional(),
// Basic
spec: Joi.string(),
url: Joi.string().uri({ allowRelative: true }).optional(),
route: Joi.string().uri({ relativeOnly: true }).optional(),
layout: Joi.any().default(DEFAULT_OPTIONS.layout),
});