medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.93k stars 2.6k forks source link

Fix URL in getPublicOas Function to Correct API Spec Download Path @medusajs/medusa-oas-cli #8762

Closed vholik closed 2 months ago

vholik commented 2 months ago

Bug report

I encountered an issue after installing a fresh oas package using the following command:

yarn add --dev @medusajs/medusa-oas-cli@preview

Upon running generate command, I received the following error:

ResolverError: Error downloading https://docs.medusajs.com/v2/api/download/admin 
HTTP ERROR 404
    at /Users/vholik/Desktop/medusa-2-0/node_modules/@readme/json-schema-ref-parser/lib/resolvers/http.js:101:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERESOLVER',
  source: 'https://docs.medusajs.com/v2/api/download/admin',
  path: null,
  toJSON: [Function: toJSON],
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}

Describe the bug

I was able to resolve the issue by modifying the getPublicOas URL in the package code.

async function getPublicOas(apiType) {
-    const url = `https://docs.medusajs.com/v2/api/download/${apiType}`;
+    const url = `https://docs.medusajs.com/api/download/${apiType}`;
    return await openapi_parser_1.default.parse(url);
}

System information

Medusa version (including plugins): Node.js version: Database: Operating system: Browser (if relevant):

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

If applicable, add code samples to help explain your problem

Additional context

Add any other context about the problem here

shahednasser commented 2 months ago

Hello! Are you trying to generate OAS for v1 or v2? If for v1, please use the @latest version instead.

However, for v2, it seems the URL is definitely incorrect. It should be https://docs.medusajs.com/v2/api/api/download/${apiType}. Will open a PR to fix it.

vholik commented 2 months ago

Hello @shahednasser. I am using Medusa 2.0.