Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show the display name in the sidebar #154

Merged
merged 2 commits into from
Jan 17, 2022
Merged

show the display name in the sidebar #154

merged 2 commits into from
Jan 17, 2022

Conversation

elmarburke
Copy link
Contributor

First of all: thanks for providing this package!

We missed a little feature - namely that the display names of tags are shown in the sidebar.
The PR adds exactly this possibility. I extended the code to loop over the tags, read the original file and replace the pure tag with the x-displayName if it's available.

For me, reading the file again, didn't looked the most elegant solution, but I didn't found another way to get the data otherwise. If you have an idea, I'm happy to change it :)

image

Added the ability to read out the x-displayName for the category type in the sidebar.
@netlify
Copy link

netlify bot commented Jan 14, 2022

✔️ Deploy Preview for docusaurus-openapi ready!

🔨 Explore the source changes: 66925df

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-openapi/deploys/61e5477beb2501000805cdeb

😎 Browse the preview: https://deploy-preview-154--docusaurus-openapi.netlify.app

@bourdakos1
Copy link
Member

Thank you for the contribution 😁 Looks great, I will try to take a closer look at the code this weekend!

@bourdakos1
Copy link
Member

@elmarburke I think a lot of this could be simplified if we modify createItems directly in order to override tags with the finalized list of display names. That way we wouldn't have to touch the groupByTags function and we wouldn't need to re-read the spec files.

something like:

const apiPage = {
  type: "api",
  // ... other metadata
  api: {
    ...defaults,
    tags: operationObject.tags.map(t => getTagDisplayName(t, openapiData)),
    // ... other overrides
  },
}

So that { tags: ["store"] } would end up as { tags: ["Petstore orders"] }

@elmarburke
Copy link
Contributor Author

That does sound like a better idea in deed. Somehow I missed this very function 😮

Copy link
Member

@bourdakos1 bourdakos1 left a comment

Choose a reason for hiding this comment

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

LGTM

@bourdakos1 bourdakos1 merged commit 6dab3c3 into cloud-annotations:main Jan 17, 2022
@elmarburke elmarburke deleted the add-display-name-to-sidebar branch April 8, 2022 08:43
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