docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Code being generated for NodeJS is too old and not correct

Open Doron-Bargo opened this issue 2 years ago • 2 comments

Describe the bug

The code that is being generated for NodeJS use deprecated packages (requests, unirest ) Also under Native code the code require fs which is not being used at all. I couldn't find a way to hide those tabs

Expected behavior

Those tabs shouldn't appear at all.

Screenshots

Screenshot 2024-01-02 at 22 43 29

Doron-Bargo avatar Jan 02 '24 20:01 Doron-Bargo

Ok so i found a solution to one of the problems

To remove the deprecated packages under node you need to do the following

  1. Swizzle the ApiExplorer/CodeSnippets yarn swizzle docusaurus-theme-openapi-docs ApiExplorer/CodeSnippets -- --eject

  2. Edit the file ../src/theme/ApiExplorer/CodeSnippets/index.js to remove the deprecated variants ( requests and unirest) https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/f6641c0ce01e3247a06ef8ddde7bafbe749d4ed1/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx#L74

  3. Edit the file ../src/theme/ApiExplorer/CodeSnippets/languages.json to remove the deprecated node packages parameters https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/f6641c0ce01e3247a06ef8ddde7bafbe749d4ed1/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/languages.json#L639 https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/f6641c0ce01e3247a06ef8ddde7bafbe749d4ed1/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/languages.json#L687

  4. Build the website yarn build

  5. Start the website yarn start

Regarding the second issue with the require('fs'); which is not needed it is related to the package paloaltonetworks/postman-code-generators.

Unfortunately its repo is not public so i cant offer a fix for it. I was able to watch the code on npmjs.com and in file codegens/nodejs-native/lib/request.js line 42 ( snippet += "fs = require('fs');\n\n"; ) need to be remove Here is link to the relevant file

Doron-Bargo avatar Jan 17 '24 17:01 Doron-Bargo

@sserrata can you help with the second issue?

Doron-Bargo avatar Jan 17 '24 17:01 Doron-Bargo