Tag Archive Swagger

Byphunsanit

Swagger: การติดตั้ง Swagger Editor

การเขียน OpenAPI เครื่องมือที่สามารถช่วยตรวจสอบและ test ได้คือ swagger-editor โดยสามารถ download มาติดตั้งในเครื่องของตัวเองได้

การติดตั้ง Swagger Editor

  1. ดาวน์โหลดตัว zip file จาก https://github.com/swagger-api/swagger-editor มาแตกไว้ในโฟลเดอร์ C:\tools หรือจะใช้คำสั่ง
    git clone https://github.com/swagger-api/swagger-editor.git
  2. เปลี่ยนชื่อ folder จาก swagger-ui-master เป็น swagger-editor
  3. เปิด PowerShell แล้วไปที่
    cd c:\tools
  4. ติดตั้ง http โดยคำสั่ง
    npm install -g http-server
  5. จากนั้นอนุญาต โดยคำสั่ง
    Get-ExecutionPolicy
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
    Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

การเรียกใช้ Swagger Editor

  1. เปิด PowerShell แล้วไปที่
    cd c:\tools
  2. เปิด server โดยคำสั่ง
    http-server swagger-editor -a 127.0.0.1 -p 8080
  3. เปิด URL ตามที่แสดงใน Available on:
    http://127.0.0.1:8080

เท่านี้ก็สามารถใช้ swagger-editor ได้โดยไม่ต้องต่ออินเตอร์เน็ตแล้ว
Cr.