การเขียน OpenAPI เครื่องมือที่สามารถช่วยตรวจสอบและ test ได้คือ swagger-editor โดยสามารถ download มาติดตั้งในเครื่องของตัวเองได้
การติดตั้ง Swagger Editor
- ดาวน์โหลดตัว zip file จาก https://github.com/swagger-api/swagger-editor มาแตกไว้ในโฟลเดอร์ C:\tools หรือจะใช้คำสั่ง
git clone https://github.com/swagger-api/swagger-editor.git
- เปลี่ยนชื่อ folder จาก swagger-ui-master เป็น swagger-editor
- เปิด PowerShell แล้วไปที่
cd c:\tools
- ติดตั้ง http โดยคำสั่ง
npm install -g http-server
- จากนั้นอนุญาต โดยคำสั่ง
Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
การเรียกใช้ Swagger Editor
- เปิด PowerShell แล้วไปที่
cd c:\tools
- เปิด server โดยคำสั่ง
http-server swagger-editor -a 127.0.0.1 -p 8080
- เปิด URL ตามที่แสดงใน Available on:
http://127.0.0.1:8080
เท่านี้ก็สามารถใช้ swagger-editor ได้โดยไม่ต้องต่ออินเตอร์เน็ตแล้ว
Cr.