Skip to content

feat: add API reference links to generated TypeScript comments #559

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

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

CalebBarnes
Copy link
Contributor

@CalebBarnes CalebBarnes commented Jan 18, 2025

Summary

This PR introduces API reference links to the generated TypeScript comments for each method, enhancing developer experience with more context-rich documentation.

Changes

  • Enhancements to TypeScript type generation: Replaced the postbuild openapi-typescript command with a custom script, src/typegen.js, allowing for enhanced TypeScript comments without affecting the docs site, including API reference links for each method, in the generated index.d.ts file.
  • ESLint Configuration Update: Updated .eslintrc to use ecmaVersion: 2020, enabling support for dynamic imports.
  • Node Engine Update: Increased the minimum Node.js version from 14 to 14.8.0 to ensure compatibility with dynamic import syntax used in the type generation process.

Example of Changes:

Generated comments now include API reference links like this:

/**
 * API Reference: {@link https://open-api.netlify.com/#tag/site/operation/getSite `getSite`}
 */

When these types are used in the js-client, it adds helpful API reference links like this:
image

…enhance the ts comments before writing to index.d.ts

Also updated the eslintrc to ecmaVersion 2020 and node engine minimum
version to 14.8.0 to ensure support for dynamic import syntax
Copy link

netlify bot commented Jan 18, 2025

Deploy Preview for open-api ready!

Name Link
🔨 Latest commit dfe55a2
🔍 Latest deploy log https://app.netlify.com/sites/open-api/deploys/678afe3eeaf4ea000887cf40
😎 Deploy Preview https://deploy-preview-559--open-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -56,7 +56,7 @@
"start": "run-s lint build",
"bundle": "redocly bundle external@latest --output external.yml",
"build": "run-s convert bundle redoc",
"postbuild": "swagger2openapi external.yml -o dist/openapi.json && openapi-typescript dist/openapi.json -o dist/index.d.ts --alphabetize --empty-objects-unknown",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

--alphabetize --empty-objects-unknown
These flags didn't actually do anything in this version of openapi-typescript cli so this doesn't matter.

@CalebBarnes CalebBarnes marked this pull request as ready for review January 22, 2025 19:31
@CalebBarnes CalebBarnes requested a review from a team as a code owner January 22, 2025 19:31
Copy link
Contributor

@YujohnNattrass YujohnNattrass left a comment

Choose a reason for hiding this comment

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

nicee!!

@CalebBarnes CalebBarnes merged commit 4f0031d into master Jan 22, 2025
15 checks passed
@CalebBarnes CalebBarnes deleted the feat/enhance-generated-ts-comments branch January 22, 2025 21:29
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