Skip to content

feat(openapi): type rich text field value — spec, aliases, naming - #710

Merged
dipankarmaikap merged 15 commits into
mainfrom
feat/DX-487-openapi-codegen-richtext-spec
Jul 31, 2026
Merged

feat(openapi): type rich text field value — spec, aliases, naming#710
dipankarmaikap merged 15 commits into
mainfrom
feat/DX-487-openapi-codegen-richtext-spec

Conversation

@dipankarmaikap

@dipankarmaikap dipankarmaikap commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Extracts the tools/openapi-codegen changes from #684 into a standalone PR so the spec work can be reviewed and merged independently.

Changes

tools/openapi-codegen

Spec (specs/)

  • richtext-field-value.yaml — expanded from a loose type: object into a fully discriminated schema with $defs for all 17 node types and 12 mark types
    • BlockNode.attrs.body items reference ../block-content.yaml (canonical definition) instead of an inline duplicate
  • overlay.openapi.yaml — added RichTextNode and RichTextMark as top-level schema refs so they are emitted as named types; renamed RichtextFieldValueRichTextFieldValue
  • mapi/components/field-types/richtext-field.yaml — description updated to follow naming conventions

Source (src/)

  • aliases.ts — registered RichTextDoc, RichTextNode, RichTextMark; updated RichtextFieldValueRichTextFieldValue
  • index.ts — fixed copyWrapperTemplates to skip writing the empty types/_sources.ts when no wrapper templates are requested
  • known-types.ts, templates.ts — updated RichtextFieldValueRichTextFieldValue; registered RichtextFieldValue in provides for backward compat

Templates (templates/)

  • field.ts — updated import/export/map entry for RichTextFieldValue; added deprecated RichtextFieldValue alias

Backward compatibility

RichtextFieldValue has been renamed to RichTextFieldValue. To avoid breaking consumer packages all at once, the generated field.ts now also exports:

/** @deprecated Use RichTextFieldValue instead. Will be removed in a future major version. */
export type RichtextFieldValue = RichTextFieldValue;

This means packages that currently import RichtextFieldValue (mapi-client, schema, capi-client, migrations, etc.) will continue to compile after regeneration — TypeScript/editors will surface the @deprecated warning so each package can migrate at its own pace.

Naming conventions applied

Context Convention Example
Type names RichText (PascalCase) RichTextFieldValue, RichTextDoc
Sentence start Rich text Rich text field type …
Mid-sentence rich text … rich text document …
Wire values unchanged enum: [richtext], toggle-richtext
Node type names Block not Blok BlockNode

Fixes DX-487

Expands richtext-field-value.yaml from a loose type: object into a
fully discriminated schema with $defs for all 17 node types and 12 mark
types, mirroring richtext-attrs.ts.

- overlay.openapi.yaml: add RichTextNode and RichTextMark as top-level
  schema refs so they are emitted as named types
- aliases.ts: register RichtextDoc, RichTextNode, RichTextMark aliases
- index.ts: fix copyWrapperTemplates to skip writing the empty
  types/_sources.ts when no wrapper templates are requested
- richtext-field-value.yaml: BlokNode body items reference
  block-content.yaml instead of an inline duplicate schema

Fixes DX-487
Expands richtext-field-value.yaml from a loose type: object into a
fully discriminated schema with $defs for all 17 node types and 12 mark
types, mirroring richtext-attrs.ts.

- overlay.openapi.yaml: add RichTextNode and RichTextMark as top-level
  schema refs so they are emitted as named types
- aliases.ts: register RichTextDoc, RichTextNode, RichTextMark aliases
- index.ts: fix copyWrapperTemplates to skip writing the empty
  types/_sources.ts when no wrapper templates are requested
- richtext-field-value.yaml: BlockNode body items reference
  block-content.yaml instead of an inline duplicate schema

Naming: use RichText (not Richtext) for all type names and Block (not
Blok) for the embedded component node type. Wire values (enum: richtext,
enum: blok) are unchanged as they are API contract values.

Fixes DX-487
Type names keep RichText (PascalCase). In description strings,
use 'Rich text' at sentence start and 'rich text' mid-sentence.
Wire values (enum: richtext, toggle-richtext) are unchanged.

Fixes DX-487

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 848fae8. Configure here.

@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@storyblok/angular

npm i https://pkg.pr.new/@storyblok/angular@710

@storyblok/astro

npm i https://pkg.pr.new/@storyblok/astro@710

@storyblok/api-client

npm i https://pkg.pr.new/@storyblok/api-client@710

storyblok

npm i https://pkg.pr.new/storyblok@710

@storyblok/eslint-config

npm i https://pkg.pr.new/@storyblok/eslint-config@710

@storyblok/experiments

npm i https://pkg.pr.new/@storyblok/experiments@710

@storyblok/js

npm i https://pkg.pr.new/@storyblok/js@710

storyblok-js-client

npm i https://pkg.pr.new/storyblok-js-client@710

@storyblok/live-preview

npm i https://pkg.pr.new/@storyblok/live-preview@710

@storyblok/management-api-client

npm i https://pkg.pr.new/@storyblok/management-api-client@710

@storyblok/migrations

npm i https://pkg.pr.new/@storyblok/migrations@710

@storyblok/nuxt

npm i https://pkg.pr.new/@storyblok/nuxt@710

@storyblok/react

npm i https://pkg.pr.new/@storyblok/react@710

@storyblok/region-helper

npm i https://pkg.pr.new/@storyblok/region-helper@710

@storyblok/richtext

npm i https://pkg.pr.new/@storyblok/richtext@710

@storyblok/schema

npm i https://pkg.pr.new/@storyblok/schema@710

@storyblok/svelte

npm i https://pkg.pr.new/@storyblok/svelte@710

@storyblok/vue

npm i https://pkg.pr.new/@storyblok/vue@710

commit: 9a89ccd

…compat

RichtextFieldValue is renamed to RichTextFieldValue in this PR. To avoid
breaking consumer packages that already import the old name, export a
deprecated type alias from the field template so each package can migrate
at its own pace.

- templates/field.ts: export `RichtextFieldValue = RichTextFieldValue` with @deprecated JSDoc
- src/templates.ts: register RichtextFieldValue in the field template's provides list

Fixes DX-487
…r correct casing

Fixes RichtextFieldValue* type prefix to RichTextFieldValue* (PascalCase).

Fixes DX-487
An empty paragraph emitted by the editor is just {"type": "paragraph"}
with no attrs or content. Requiring attrs caused schema validation to
fail for that case.

Fixes DX-487
Comment thread tools/openapi-codegen/specs/shared/stories/field-types/rich-text-field-value.yaml Outdated
Comment thread tools/openapi-codegen/specs/shared/stories/field-types/rich-text-field-value.yaml Outdated
@maoberlehner

Copy link
Copy Markdown
Contributor
  • pnpm nx run-many -t generate leads to uncommitted changes!
  • pnpm nx run @storyblok/schema:build --skip-nx-cache shows [MISSING_EXPORT] Warning the alias must also be added to Zod output (internal-schemas.ts + validate-story.ts).
  • 'heading', 'paragraph', 'list_item', 'blockquote', 'code_block' need dir: 'ltr' | 'rtl' | null

- Add optional dir (ltr | rtl | null) to paragraph, heading, blockquote, list_item, and code_block nodes
- Make meta_data properties optional and allow custom additionalProperties (string | null)
- Make HighlightMark color nullable
- Make ImageNode src nullable

Fixes DX-487
@dipankarmaikap

Copy link
Copy Markdown
Contributor Author
  • pnpm nx run-many -t generate leads to uncommitted changes!

Should we do this in this PR?

…rd-compat aliases

- Regenerate src/generated with RichTextFieldValue (new canonical name)
- scripts/generate.ts: update include list entry to RichTextFieldValue
- helpers/define-field.ts: re-export RichTextFieldValue alongside deprecated RichtextFieldValue
- src/index.ts: export RichTextFieldValue (new) alongside kept RichtextFieldValue
- validators/internal-schemas.ts: import zRichTextFieldValue; export deprecated zRichtextFieldValue alias
- validators/validate-story.ts: use zRichTextFieldValue internally
- validators/validate-story.test.ts: add _uid to richtext embedded blok fixtures (required by tightened zBlockContentRoot)

Fixes DX-487
- Regenerate src/generated with RichTextFieldValue (new canonical name)
- resources/stories.ts: update internal import to RichTextFieldValue

Fixes DX-487
…ackward-compat alias

- Regenerate src/generated with RichTextFieldValue (new canonical name)
- src/index.ts: export RichTextFieldValue (new) alongside kept deprecated RichtextFieldValue

Fixes DX-487
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Cross-package changes detected

This PR is titled as a feat(openapi) commit but modifies files across 6 packages:

  • packages/capi-client/
  • packages/experiments/
  • packages/live-preview/
  • packages/mapi-client/
  • packages/migrations/
  • packages/schema/

When this PR is squash-merged, all changes become a single feat(openapi) commit.
Nx release uses file changes (not the commit scope) to determine which packages to bump,
so every package listed above will get a version bump on the next release.

If the changes to other packages are cosmetic (README fixes, dependency bumps, config cleanup),
please split them into a separate PR with a chore: title. chore commits don't trigger version bumps.

Comment thread packages/migrations/src/types.ts
Comment thread tools/openapi-codegen/specs/shared/stories/field-types/rich-text-field-value.yaml Outdated
@maoberlehner

Copy link
Copy Markdown
Contributor
  • pnpm nx run-many -t generate leads to uncommitted changes!

Should we do this in this PR?

Yes, absolutely!

… make link custom attr nullable

- BlockNode.body items now reference block-content-input.yaml so _uid is
  optional when writing richtext content with embedded bloks
- LinkMark attrs.custom changed to type [object, 'null'] to correctly
  reflect that the field may be null
@dipankarmaikap
dipankarmaikap merged commit ce864b6 into main Jul 31, 2026
7 checks passed
@dipankarmaikap
dipankarmaikap deleted the feat/DX-487-openapi-codegen-richtext-spec branch July 31, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants