这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@timothycarambat
Copy link
Member

No description provided.

@timothycarambat timothycarambat merged commit 259079a into master Jan 10, 2024
@timothycarambat timothycarambat deleted the 561-relative-api-docs-url branch January 10, 2024 05:52
@review-agent-prime
Copy link

server/swagger/init.js

Consider using async/await instead of promises for better readability and error handling. This will make the code easier to read and maintain.
Create Issue
See the diff
Checkout the fix

    async function generateSwagger() {
      try {
        const data = await swaggerAutogen(outputFile, endpointsFiles, doc);
        const openApiSpec = {
          ...data,
          servers: [{
            url: "/api"
          }]
        }
        fs.writeFileSync(outputFile, JSON.stringify(openApiSpec, null, 2), { encoding: 'utf-8', flag: 'w' });
        console.log(`Swagger-autogen:  \x1b[32mPatched servers.url ✔\x1b[0m`)
      } catch (error) {
        console.error(`Error generating Swagger: ${error}`);
      }
    }

    generateSwagger();
git fetch origin && git checkout -b ReviewBot/Impro-ozbf872 origin/ReviewBot/Impro-ozbf872

Consider using fs.writeFile instead of fs.writeFileSync to write the file asynchronously. This will improve the performance of your application by not blocking the event loop.
Create Issue
See the diff
Checkout the fix

    fs.writeFile(outputFile, JSON.stringify(openApiSpec, null, 2), { encoding: 'utf-8', flag: 'w' }, (err) => {
      if (err) throw err;
      console.log(`Swagger-autogen:  \x1b[32mPatched servers.url ✔\x1b[0m`);
    });
git fetch origin && git checkout -b ReviewBot/Impro-nvbj5ux origin/ReviewBot/Impro-nvbj5ux

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