在Linux上展示Swagger API文档,可以通过以下几种方法实现:
sudo apt-get update sudo apt-get install swagger-editor http://localhost:3000即可看到Swagger Editor界面,并可以查看和编辑API文档。nest new swagger-demo -p npm cd swagger-demo npm install --save @nestjs/swagger main.ts中添加以下代码:import { DocumentBuilder } from '@nestjs/swagger'; import { SwaggerModule } from '@nestjs/swagger'; import { AppModule } from './app.module'; const documentConfig = new DocumentBuilder() .setTitle('Swagger Example') .setDescription('The API description') .setVersion('1.0') .addTag('swagger') .build(); @Module({ imports: [ AppModule, SwaggerModule.register({ document: documentConfig, cors: true, }), ], controllers: [], providers: [], }) export class AppModule {} npm run start:dev http://localhost:3000/doc即可看到Swagger API文档。go install github.com/swaggo/swag/cmd/swag@latest swag init http://localhost:8080/swagger/index.html即可看到Swagger API文档。通过以上方法,你可以在Linux系统上成功展示Swagger API文档。选择适合你项目的方法进行操作即可。