PaloAltoNetworks / PaloAltoNetworks/docusaurus-openapi-docs

Custom item naming and path generation

Open
#886 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.1k
Forks
315
Avg merge
7d 5h
Merged PRs (30d)
7

Description

Is your feature request related to a problem?

Nope

Describe the solution you'd like

It would be great to be able to control the formatting of the path and the resulting file name

The baseId is a kebab cased operationId - https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts#L144-L146

And the resulting path is hardcoded using the id https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/index.ts#L357

Perhaps adding an item ID transformer and path generator to the plugin options would be possible,

{
  itemIdTransformer(item: ApiMetadata): string { }
  itemPathTransformer(item: ApiMetaData): string {}
}
Describe alternatives you've considered
  • Use a patch-package patch
  • Create redirects :(
Additional context

I am migrating a documentation site to docusaurus, the content has hardcoded links to an API schema in the markdown files which uses the operationId as the file name and route.

Being able to control the name of the item and the path it is written to would mean we don't have to construct redirects or change our content

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

Read packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts around lines 144-146 and packages/docusaurus-plugin-openapi-docs/src/index.ts around line 357 to trace how the base ID and generated path are formed. Review the plugin options and ApiMetadata usage before deciding how configurable naming and path generation should work; done means both the item name and output path can be controlled without requiring redirects or changing existing links.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
documentation, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.