mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
Remove default properties before generating the config types
This commit is contained in:
parent
4f9988a799
commit
0bda748ad9
@ -233,6 +233,23 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround for type duplication when a $ref property has siblings.
|
||||||
|
*
|
||||||
|
* @param json - The input JSON object.
|
||||||
|
*
|
||||||
|
* @see https://github.com/bcherny/json-schema-to-typescript/issues/193
|
||||||
|
*/
|
||||||
|
function removeProp(json: any, name: string) {
|
||||||
|
for (const prop in json) {
|
||||||
|
if (prop === name) {
|
||||||
|
delete json[prop];
|
||||||
|
} else if (typeof json[prop] === 'object') {
|
||||||
|
removeProp(json[prop], name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Main function */
|
/** Main function */
|
||||||
async function main() {
|
async function main() {
|
||||||
if (verifyOnly) {
|
if (verifyOnly) {
|
||||||
@ -243,6 +260,8 @@ async function main() {
|
|||||||
|
|
||||||
const configJsonSchema = await loadJsonSchemaFromYaml();
|
const configJsonSchema = await loadJsonSchemaFromYaml();
|
||||||
|
|
||||||
|
removeProp(configJsonSchema, 'default');
|
||||||
|
|
||||||
validateSchema(configJsonSchema);
|
validateSchema(configJsonSchema);
|
||||||
|
|
||||||
// Generate types from JSON Schema
|
// Generate types from JSON Schema
|
||||||
|
@ -783,8 +783,8 @@ export interface XYChartConfig extends BaseDiagramConfig {
|
|||||||
* Should show the chart title
|
* Should show the chart title
|
||||||
*/
|
*/
|
||||||
showTitle?: boolean;
|
showTitle?: boolean;
|
||||||
xAxis?: XYChartAxisConfig1;
|
xAxis?: XYChartAxisConfig;
|
||||||
yAxis?: XYChartAxisConfig2;
|
yAxis?: XYChartAxisConfig;
|
||||||
/**
|
/**
|
||||||
* How to plot will be drawn horizontal or vertical
|
* How to plot will be drawn horizontal or vertical
|
||||||
*/
|
*/
|
||||||
@ -794,104 +794,6 @@ export interface XYChartConfig extends BaseDiagramConfig {
|
|||||||
*/
|
*/
|
||||||
plotReservedSpacePercent?: number;
|
plotReservedSpacePercent?: number;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This object contains configuration for XYChart axis config
|
|
||||||
*/
|
|
||||||
export interface XYChartAxisConfig1 {
|
|
||||||
/**
|
|
||||||
* Should show the axis labels (tick text)
|
|
||||||
*/
|
|
||||||
showLabel?: boolean;
|
|
||||||
/**
|
|
||||||
* font size of the axis labels (tick text)
|
|
||||||
*/
|
|
||||||
labelFontSize?: number;
|
|
||||||
/**
|
|
||||||
* top and bottom space from axis label (tick text)
|
|
||||||
*/
|
|
||||||
labelPadding?: number;
|
|
||||||
/**
|
|
||||||
* Should show the axis title
|
|
||||||
*/
|
|
||||||
showTitle?: boolean;
|
|
||||||
/**
|
|
||||||
* font size of the axis title
|
|
||||||
*/
|
|
||||||
titleFontSize?: number;
|
|
||||||
/**
|
|
||||||
* top and bottom space from axis title
|
|
||||||
*/
|
|
||||||
titlePadding?: number;
|
|
||||||
/**
|
|
||||||
* Should show the axis tick lines
|
|
||||||
*/
|
|
||||||
showTick?: boolean;
|
|
||||||
/**
|
|
||||||
* length of the axis tick lines
|
|
||||||
*/
|
|
||||||
tickLength?: number;
|
|
||||||
/**
|
|
||||||
* width of the axis tick lines
|
|
||||||
*/
|
|
||||||
tickWidth?: number;
|
|
||||||
/**
|
|
||||||
* Show line across the axis
|
|
||||||
*/
|
|
||||||
showAxisLine?: boolean;
|
|
||||||
/**
|
|
||||||
* Width of the axis line
|
|
||||||
*/
|
|
||||||
axisLineWidth?: number;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* This object contains configuration for XYChart axis config
|
|
||||||
*/
|
|
||||||
export interface XYChartAxisConfig2 {
|
|
||||||
/**
|
|
||||||
* Should show the axis labels (tick text)
|
|
||||||
*/
|
|
||||||
showLabel?: boolean;
|
|
||||||
/**
|
|
||||||
* font size of the axis labels (tick text)
|
|
||||||
*/
|
|
||||||
labelFontSize?: number;
|
|
||||||
/**
|
|
||||||
* top and bottom space from axis label (tick text)
|
|
||||||
*/
|
|
||||||
labelPadding?: number;
|
|
||||||
/**
|
|
||||||
* Should show the axis title
|
|
||||||
*/
|
|
||||||
showTitle?: boolean;
|
|
||||||
/**
|
|
||||||
* font size of the axis title
|
|
||||||
*/
|
|
||||||
titleFontSize?: number;
|
|
||||||
/**
|
|
||||||
* top and bottom space from axis title
|
|
||||||
*/
|
|
||||||
titlePadding?: number;
|
|
||||||
/**
|
|
||||||
* Should show the axis tick lines
|
|
||||||
*/
|
|
||||||
showTick?: boolean;
|
|
||||||
/**
|
|
||||||
* length of the axis tick lines
|
|
||||||
*/
|
|
||||||
tickLength?: number;
|
|
||||||
/**
|
|
||||||
* width of the axis tick lines
|
|
||||||
*/
|
|
||||||
tickWidth?: number;
|
|
||||||
/**
|
|
||||||
* Show line across the axis
|
|
||||||
*/
|
|
||||||
showAxisLine?: boolean;
|
|
||||||
/**
|
|
||||||
* Width of the axis line
|
|
||||||
*/
|
|
||||||
axisLineWidth?: number;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* The object containing configurations specific for entity relationship diagrams
|
* The object containing configurations specific for entity relationship diagrams
|
||||||
*
|
*
|
||||||
@ -1487,13 +1389,7 @@ export interface SankeyDiagramConfig extends BaseDiagramConfig {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
linkColor?: SankeyLinkColor | string;
|
linkColor?: SankeyLinkColor | string;
|
||||||
/**
|
nodeAlignment?: SankeyNodeAlignment;
|
||||||
* Controls the alignment of the Sankey diagrams.
|
|
||||||
*
|
|
||||||
* See <https://github.com/d3/d3-sankey#alignments>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
nodeAlignment?: 'left' | 'right' | 'center' | 'justify';
|
|
||||||
useMaxWidth?: boolean;
|
useMaxWidth?: boolean;
|
||||||
/**
|
/**
|
||||||
* Toggle to display or hide values along with title.
|
* Toggle to display or hide values along with title.
|
||||||
|
@ -21,8 +21,9 @@
|
|||||||
# - Use `meta:enum` to document enum values (from jsonschema2md)
|
# - Use `meta:enum` to document enum values (from jsonschema2md)
|
||||||
# - Use `tsType` to override the TypeScript type (from json-schema-to-typescript)
|
# - Use `tsType` to override the TypeScript type (from json-schema-to-typescript)
|
||||||
# - If adding a new object to `MermaidConfig` (e.g. a new diagram type),
|
# - If adding a new object to `MermaidConfig` (e.g. a new diagram type),
|
||||||
# you may need to add it to `.vite/jsonSchemaPlugin.ts` and `src/docs.mts`
|
# you may need to add it to `.vite/jsonSchemaPlugin.ts`, `src/docs.mts`
|
||||||
# to get the docs/default values to generate properly.
|
# and `scripts/create-types-from-json-schema.mjs`
|
||||||
|
# to get the docs/default values/types to generate properly.
|
||||||
$id: https://mermaid-js.github.io/schemas/config.schema.json
|
$id: https://mermaid-js.github.io/schemas/config.schema.json
|
||||||
$schema: https://json-schema.org/draft/2019-09/schema
|
$schema: https://json-schema.org/draft/2019-09/schema
|
||||||
title: Mermaid Config
|
title: Mermaid Config
|
||||||
@ -2002,10 +2003,12 @@ $defs: # JSON Schema definition (maybe we should move these to a separate file)
|
|||||||
$ref: '#/$defs/SankeyNodeAlignment'
|
$ref: '#/$defs/SankeyNodeAlignment'
|
||||||
default: justify
|
default: justify
|
||||||
useMaxWidth:
|
useMaxWidth:
|
||||||
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
showValues:
|
showValues:
|
||||||
description: |
|
description: |
|
||||||
Toggle to display or hide values along with title.
|
Toggle to display or hide values along with title.
|
||||||
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
prefix:
|
prefix:
|
||||||
description: |
|
description: |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user