Redocly / Redocly/redocly-cli

Update syntax for decorators to support markdown as well as file paths

Open
#1,528 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Enhancement Type: Idea
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

Our update-a-description decorators expect the user to put the markdown into a separate file, and then refer to the file from the decorator. This is a decent use case, but can be overkill when just a couple of lines of content is needed, such as to update the description for a single operation. In comparison with overlays, the decorators look more complicated, when they're really not.

I propose we update the syntax for the *-description-override decorators, to make them consistent with one another, and to add the option of in-config markdown as well as the existing external-file markdown.

In all cases, the user can use either filePath or description to specify the new contents of the relevant description field.

Info info-description-override

Current example:

info-description-override:
  filePath: ./my-custom-description.md

Also add support for:

info-description-override:
  description: >-
    Words or markdown here, [CommonMark format](https://commonmark.org/) is supported.
Tag tag-description-override

Current example:

tag-description-override:
  tagNames:
    planet: ./my-planet-description.md
    star: ./my-star-description.md

Change to:

tag-description-override:
  tagNames:
    planet:
      filePath: ./my-planet-description.md
    star:
      filePath: ./my-star-description.md

And add support for markdown as an alternative:

tag-description-override:
  tagNames:
    planet:
      description: A very interesting planet, with a charming orbit.
    star:
      description: Solo primary dwarf.
Operation operation-description-override

Current usage example:

operation-description-override:
  operationIds:
    updateEvent: ./my-custom-description.md
    createEvent: ./add-an-event.md

Update to the following syntax for filenames:

operation-description-override:
  operationIds:
    updateEvent:
      filePath: ./my-custom-description.md
    createEvent:
      filePath: ./add-an-event.md

And add support for markdown:

operation-description-override:
  operationIds:
    updateEvent:
      description: Change the details of an existing event.
    createEvent:
      description: Add an event to the upcoming events listing.

Alternatives considered

Do nothing; users are adopting overlays. However I do think the descriptions are an 80% use case and the decorators are a nicer experience for doing those updates.

We should also consider doing https://redocly.com/docs/cli/decorators/media-type-examples-override/ as a followup.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementations and tests for the info-description-override, tag-description-override, and operation-description-override decorators. Review how their current filePath values are parsed, then define the equivalent description forms and update coverage for both alternatives. Done means all three decorators accept either filePath or in-config markdown with the documented syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, typescript, yaml
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.