diff --git a/packages/wp-types/index.ts b/packages/wp-types/index.ts index 3cc8c36..0adfa8a 100644 --- a/packages/wp-types/index.ts +++ b/packages/wp-types/index.ts @@ -1924,78 +1924,8 @@ export interface WP_REST_API_Font_Collection { * The font families for the font collection. */ font_families: { - font_family_settings: { - name: string; - fontFamily: string; - slug: string; - fontFace?: { - /** - * URL to a preview image of the font. - */ - preview?: string; - /** - * CSS font-family value. - */ - fontFamily: string; - /** - * CSS font-style value. - */ - fontStyle?: string; - /** - * List of available font weights, separated by a space. - */ - fontWeight?: string | number; - /** - * CSS font-display value. - */ - fontDisplay?: "auto" | "block" | "fallback" | "swap" | "optional"; - /** - * Paths or URLs to the font files. - */ - src: string | string[]; - /** - * CSS font-stretch value. - */ - fontStretch?: string; - /** - * CSS ascent-override value. - */ - ascentOverride?: string; - /** - * CSS descent-override value. - */ - descentOverride?: string; - /** - * CSS font-variant value. - */ - fontVariant?: string; - /** - * CSS font-feature-settings value. - */ - fontFeatureSettings?: string; - /** - * CSS font-variation-settings value. - */ - fontVariationSettings?: string; - /** - * CSS line-gap-override value. - */ - lineGapOverride?: string; - /** - * CSS size-adjust value. - */ - sizeAdjust?: string; - /** - * CSS unicode-range value. - */ - unicodeRange?: string; - [k: string]: unknown; - }[]; - preview?: string; - [k: string]: unknown; - }; + font_family_settings: WP_Font_Family_Settings; categories?: string[]; - [k: string]: unknown; }[]; /** * The categories for the font collection. @@ -2003,11 +1933,85 @@ export interface WP_REST_API_Font_Collection { categories: { name: string; slug: string; - [k: string]: unknown; }[]; _links: WP_REST_API_Object_Links; [k: string]: unknown; } +/** + * Font family settings. + */ +export interface WP_Font_Family_Settings { + name: string; + fontFamily: string; + slug: string; + fontFace?: WP_Font_Face[]; + preview?: string; +} +/** + * A font face. + */ +export interface WP_Font_Face { + /** + * URL to a preview image of the font. + */ + preview?: string; + /** + * CSS font-family value. + */ + fontFamily: string; + /** + * CSS font-style value. + */ + fontStyle?: string; + /** + * List of available font weights, separated by a space. + */ + fontWeight?: string | number; + /** + * CSS font-display value. + */ + fontDisplay?: "auto" | "block" | "fallback" | "swap" | "optional"; + /** + * Paths or URLs to the font files. + */ + src: string | string[]; + /** + * CSS font-stretch value. + */ + fontStretch?: string; + /** + * CSS ascent-override value. + */ + ascentOverride?: string; + /** + * CSS descent-override value. + */ + descentOverride?: string; + /** + * CSS font-variant value. + */ + fontVariant?: string; + /** + * CSS font-feature-settings value. + */ + fontFeatureSettings?: string; + /** + * CSS font-variation-settings value. + */ + fontVariationSettings?: string; + /** + * CSS line-gap-override value. + */ + lineGapOverride?: string; + /** + * CSS size-adjust value. + */ + sizeAdjust?: string; + /** + * CSS unicode-range value. + */ + unicodeRange?: string; +} /** * A font family object in a REST API context. */ @@ -2024,13 +2028,7 @@ export interface WP_REST_API_Font_Family { * The IDs of the child font faces in the font family. */ font_faces: number[]; - font_family_settings: { - name?: string; - slug?: string; - fontFamily?: string; - preview?: string; - [k: string]: unknown; - }; + font_family_settings: WP_Font_Family_Settings; _links: WP_REST_API_Object_Links; /** * The embedded representation of relations. Only present when the '_embed' query parameter is set. @@ -2076,13 +2074,7 @@ export interface WP_REST_API_Font_Face { * The IDs of the child font faces in the font family. */ font_faces?: number[]; - font_family_settings?: { - name?: string; - slug?: string; - fontFamily?: string; - preview?: string; - [k: string]: unknown; - }; + font_family_settings?: WP_Font_Family_Settings; _links?: WP_REST_API_Object_Links; /** * The embedded representation of relations. Only present when the '_embed' query parameter is set. diff --git a/schemas/rest-api/font-collection.json b/schemas/rest-api/font-collection.json index 99046a8..37aa8b5 100644 --- a/schemas/rest-api/font-collection.json +++ b/schemas/rest-api/font-collection.json @@ -37,126 +37,11 @@ ], "properties": { "font_family_settings": { - "type": "object", - "required": [ - "name", - "fontFamily", - "slug" - ], - "properties": { - "name": { - "type": "string" - }, - "fontFamily": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "fontFace": { - "type": "array", - "items": { - "type": "object", - "required": [ - "src", - "fontFamily" - ], - "properties": { - "preview": { - "description": "URL to a preview image of the font.", - "type": "string", - "format": "uri" - }, - "fontFamily": { - "description": "CSS font-family value.", - "type": "string" - }, - "fontStyle": { - "description": "CSS font-style value.", - "type": "string" - }, - "fontWeight": { - "description": "List of available font weights, separated by a space.", - "oneOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - }, - "fontDisplay": { - "description": "CSS font-display value.", - "type": "string", - "enum": [ - "auto", - "block", - "fallback", - "swap", - "optional" - ] - }, - "src": { - "description": "Paths or URLs to the font files.", - "oneOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - "fontStretch": { - "description": "CSS font-stretch value.", - "type": "string" - }, - "ascentOverride": { - "description": "CSS ascent-override value.", - "type": "string" - }, - "descentOverride": { - "description": "CSS descent-override value.", - "type": "string" - }, - "fontVariant": { - "description": "CSS font-variant value.", - "type": "string" - }, - "fontFeatureSettings": { - "description": "CSS font-feature-settings value.", - "type": "string" - }, - "fontVariationSettings": { - "description": "CSS font-variation-settings value.", - "type": "string" - }, - "lineGapOverride": { - "description": "CSS line-gap-override value.", - "type": "string" - }, - "sizeAdjust": { - "description": "CSS size-adjust value.", - "type": "string" - }, - "unicodeRange": { - "description": "CSS unicode-range value.", - "type": "string" - } - }, - "additionalProperties": true - } - }, - "preview": { - "type": "string", - "format": "uri" + "oneOf": [ + { + "$ref": "properties/font-family-settings.json" } - }, - "additionalProperties": true + ] }, "categories": { "type": "array", @@ -165,7 +50,7 @@ } } }, - "additionalProperties": true + "additionalProperties": false } }, "categories": { @@ -185,7 +70,7 @@ "type": "string" } }, - "additionalProperties": true + "additionalProperties": false } }, "_links": { diff --git a/schemas/rest-api/font-face.json b/schemas/rest-api/font-face.json index a6a2f9a..a118a60 100644 --- a/schemas/rest-api/font-face.json +++ b/schemas/rest-api/font-face.json @@ -47,22 +47,11 @@ } }, "font_family_settings": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "fontFamily": { - "type": "string" - }, - "preview": { - "type": "string", - "format": "uri" + "oneOf": [ + { + "$ref": "properties/font-family-settings.json" } - } + ] }, "_links": { "$ref": "properties/object-links.json" diff --git a/schemas/rest-api/font-family.json b/schemas/rest-api/font-family.json index 4b5cd3f..f8c5414 100644 --- a/schemas/rest-api/font-family.json +++ b/schemas/rest-api/font-family.json @@ -30,22 +30,11 @@ } }, "font_family_settings": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "fontFamily": { - "type": "string" - }, - "preview": { - "type": "string", - "format": "uri" + "oneOf": [ + { + "$ref": "properties/font-family-settings.json" } - } + ] }, "_links": { "$ref": "properties/object-links.json" diff --git a/schemas/rest-api/properties/font-face.json b/schemas/rest-api/properties/font-face.json new file mode 100644 index 0000000..2587799 --- /dev/null +++ b/schemas/rest-api/properties/font-face.json @@ -0,0 +1,99 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/properties/font-face.json", + "title": "WP_Font_Face", + "description": "A font face.", + "type": "object", + "required": [ + "src", + "fontFamily" + ], + "properties": { + "preview": { + "description": "URL to a preview image of the font.", + "type": "string", + "format": "uri" + }, + "fontFamily": { + "description": "CSS font-family value.", + "type": "string" + }, + "fontStyle": { + "description": "CSS font-style value.", + "type": "string" + }, + "fontWeight": { + "description": "List of available font weights, separated by a space.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "fontDisplay": { + "description": "CSS font-display value.", + "type": "string", + "enum": [ + "auto", + "block", + "fallback", + "swap", + "optional" + ] + }, + "src": { + "description": "Paths or URLs to the font files.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "fontStretch": { + "description": "CSS font-stretch value.", + "type": "string" + }, + "ascentOverride": { + "description": "CSS ascent-override value.", + "type": "string" + }, + "descentOverride": { + "description": "CSS descent-override value.", + "type": "string" + }, + "fontVariant": { + "description": "CSS font-variant value.", + "type": "string" + }, + "fontFeatureSettings": { + "description": "CSS font-feature-settings value.", + "type": "string" + }, + "fontVariationSettings": { + "description": "CSS font-variation-settings value.", + "type": "string" + }, + "lineGapOverride": { + "description": "CSS line-gap-override value.", + "type": "string" + }, + "sizeAdjust": { + "description": "CSS size-adjust value.", + "type": "string" + }, + "unicodeRange": { + "description": "CSS unicode-range value.", + "type": "string" + } + }, + "additionalProperties": false +} diff --git a/schemas/rest-api/properties/font-family-settings.json b/schemas/rest-api/properties/font-family-settings.json new file mode 100644 index 0000000..d66ee7d --- /dev/null +++ b/schemas/rest-api/properties/font-family-settings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/properties/font-family-settings.json", + "title": "WP_Font_Family_Settings", + "description": "Font family settings.", + "type": "object", + "required": [ + "name", + "fontFamily", + "slug" + ], + "properties": { + "name": { + "type": "string" + }, + "fontFamily": { + "type": "string" + }, + "slug": { + "type": "string" + }, + "fontFace": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "./font-face.json" + } + ] + } + }, + "preview": { + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false +}