Import OpenAPI/Swagger spec và test endpoints như Swagger UI
💡 Hướng dẫn sử dụng:
Swagger API Tester là công cụ miễn phí giúp developers import OpenAPI/Swagger specification và test API endpoints trực tiếp từ browser như Swagger UI. Hỗ trợ OpenAPI 3.0, Swagger 2.0, auto-parse endpoints, parameters, request body, và responses. Tích hợp authentication: Bearer Token/JWT, Basic Auth, API Key. Giao diện trực quan với color-coded methods, grouped endpoints by tags, và real-time testing. Hoàn hảo cho API development, testing, debugging, và documentation verification.
OpenAPI/Swagger specs là industry standard cho API documentation, nhưng việc test APIs từ spec thường cần tools như Swagger UI hoặc Postman. Swagger API Tester cho phép developers nhanh chóng import spec và test endpoints ngay trên browser mà không cần setup phức tạp. Công cụ tự động parse spec, extract endpoints với parameters và examples, tích hợp đầy đủ authentication methods (Bearer Token/JWT, Basic Auth, API Key) giúp test secured APIs dễ dàng. Đặc biệt hữu ích khi verify API implementation matches specification, test third-party APIs có OpenAPI docs, debug API issues với structured testing, và demo APIs cho team members hoặc clients.
OpenAPI Specification (trước đây là Swagger) là industry-standard format để describe RESTful APIs. Spec file (JSON hoặc YAML) chứa đầy đủ thông tin về API: endpoints, HTTP methods, parameters, request/response schemas, authentication methods, và examples. OpenAPI 3.0 là phiên bản hiện tại, Swagger 2.0 là phiên bản cũ nhưng vẫn được sử dụng rộng rãi. Spec giúp: Auto-generate API documentation (Swagger UI, ReDoc), generate client SDKs cho nhiều languages, validate requests/responses, mock servers cho testing, và API design-first development. Nhiều frameworks có built-in OpenAPI generation: FastAPI (Python), NestJS (Node.js), Spring Boot (Java). Public APIs thường provide OpenAPI specs để developers dễ integrate.
OpenAPI spec có structure chuẩn: 'openapi' field chỉ version (3.0.0, 3.1.0). 'info' object chứa title, version, description, contact, license. 'servers' array list base URLs cho different environments (production, staging, development). 'paths' object chứa tất cả endpoints, mỗi path có methods (get, post, put, delete, patch) với details: summary, description, operationId, tags, parameters (path, query, header, cookie), requestBody với content types và schemas, responses với status codes và schemas, security requirements. 'components' object define reusable schemas, parameters, responses, securitySchemes. 'tags' array group endpoints. 'security' array define global security requirements. Spec có thể reference external files với $ref. Tools như Swagger Editor giúp write và validate specs.
Swagger UI là official tool từ OpenAPI Initiative, embedded trong nhiều APIs, cho phép interactive testing trực tiếp từ documentation. Pros: Tích hợp sẵn với API docs, auto-generated từ spec, always in sync. Cons: Cần host/deploy, không flexible cho custom testing. Postman là comprehensive API platform với Collections, Environments, Tests, Mock servers, Monitoring. Pros: Powerful features, team collaboration, automation. Cons: Cần cài đặt (hoặc web version), manual setup cho mỗi endpoint, không auto-sync với spec changes. Swagger API Tester là middle ground: Browser-based như Swagger UI, import spec và auto-extract endpoints, không cần hosting/deployment, simpler interface cho quick testing, không có advanced features như Postman Collections/Tests. Use cases: Swagger UI cho embedded documentation, Postman cho comprehensive testing và automation, Swagger API Tester cho quick ad-hoc testing từ specs.
Verify spec accuracy: Đảm bảo spec up-to-date với actual API implementation. Outdated specs lead to confusion và failed tests. Test happy paths first: Start với valid inputs và expected responses để verify basic functionality. Test edge cases: Invalid parameters, missing required fields, wrong data types, boundary values. Verify error responses: Check 4xx và 5xx responses match spec, error messages helpful. Authentication testing: Test với valid tokens, expired tokens, missing auth, wrong permissions. Parameter validation: Test required vs optional parameters, parameter types (string, number, boolean), format validation (email, URL, date). Response schema validation: Verify response structure matches spec schema, check data types, required fields, nested objects. Performance testing: Monitor response times, test với large payloads, concurrent requests. Environment testing: Test trên different servers (dev, staging, prod) nếu spec có multiple servers. Documentation verification: Ensure examples trong spec actually work, descriptions accurate. Version compatibility: Test backward compatibility khi API có breaking changes.
Công cụ hỗ trợ cả OpenAPI 3.0 (phiên bản hiện tại) và Swagger 2.0 (phiên bản cũ). Bạn chỉ cần paste JSON spec vào và tool sẽ tự động detect version và parse accordingly. Lưu ý: Tool hiện tại chỉ support JSON format, chưa support YAML. Nếu spec của bạn là YAML, convert sang JSON trước (có thể dùng online YAML to JSON converters).
Click nút 'Authorize' ở góc trên bên phải, chọn 'Bearer Token (JWT)' trong dropdown Authentication Type, paste JWT token của bạn vào field Bearer Token (token thường bắt đầu với eyJ...), click 'Apply'. Tool sẽ tự động thêm header 'Authorization: Bearer [your-token]' vào tất cả requests. Token được mask (password field) để bảo mật. Bạn có thể clear auth bất kỳ lúc nào bằng nút 'Clear'.
Click 'Authorize', chọn 'Basic Auth', nhập username và password. Tool sẽ tự động encode credentials thành base64 format (username:password) và gửi trong header 'Authorization: Basic [encoded-credentials]'. Đây là standard HTTP Basic Authentication theo RFC 7617. Lưu ý: Basic Auth gửi credentials mỗi request, nên chỉ dùng qua HTTPS để bảo mật.
Có! Khi chọn 'API Key' authentication, bạn có thể chọn 'Add to' là 'Header' hoặc 'Query Parameter'. Nếu chọn Header, key sẽ được gửi trong request header (ví dụ: X-API-Key: your-key). Nếu chọn Query Parameter, key sẽ được append vào URL (ví dụ: ?api_key=your-key). Bạn có thể customize key name (X-API-Key, api_key, apikey, etc.) tùy theo yêu cầu của API.
Có nhiều cách: 1) Check API documentation - nhiều APIs provide download link cho OpenAPI spec file. 2) API endpoint - một số APIs expose spec tại /openapi.json, /swagger.json, hoặc /api-docs. 3) Swagger UI - nếu API có Swagger UI, thường có link 'Download spec' hoặc view raw JSON. 4) Generate từ code - nếu bạn own API, frameworks như FastAPI, NestJS, Spring Boot auto-generate specs. 5) Third-party API directories như APIs.guru có collection của public API specs. 6) Contact API provider nếu spec không publicly available.
Không, tool không lưu bất kỳ data nào. Mỗi lần refresh page, tất cả data (spec, endpoints, test results) sẽ bị clear. Đây là design choice để đảm bảo privacy và security - specs có thể chứa sensitive API information. Nếu cần lưu specs hoặc organize tests, recommend sử dụng Postman Collections hoặc save specs locally trong project repository.
Có! Bạn có thể thêm authentication headers trong phần Headers. Ví dụ: Authorization: Bearer your-token-here cho JWT/Bearer tokens, Authorization: Basic base64-encoded-credentials cho Basic Auth, X-API-Key: your-api-key cho API keys, hoặc custom headers theo yêu cầu của API. Tool sẽ gửi headers này cùng với request. Lưu ý: Không paste sensitive tokens vào public/shared environments.
CORS (Cross-Origin Resource Sharing) là browser security feature ngăn requests từ domain khác. Khi test từ tanphatdigital.com gọi API ở domain khác, browser check CORS headers. Nếu API không allow origin của bạn, request bị block. Solutions: 1) Yêu cầu API team enable CORS cho domain hoặc localhost. 2) Sử dụng Postman desktop app (không bị CORS). 3) Test API trên same domain nếu possible. 4) Sử dụng backend proxy. CORS chỉ affect browser requests, không ảnh hưởng server-to-server calls.
Hiện tại tool chỉ support import và parse existing specs, không có built-in spec editor. Nếu cần edit spec: 1) Edit trong text editor hoặc IDE của bạn. 2) Sử dụng Swagger Editor (editor.swagger.io) - official tool với validation và preview. 3) Paste edited spec vào tool để re-import. 4) Hoặc edit trực tiếp trong textarea trước khi parse. Future versions có thể add inline editing capabilities.
Hiện tại tool focus vào JSON APIs. File uploads với multipart/form-data chưa được support. Cho file upload testing, recommend: 1) Postman với form-data support. 2) cURL commands với -F flag. 3) Browser DevTools Console với FormData API. 4) Insomnia với multipart support. Tool có thể add feature này trong future versions based on user demand.
Cho complex parameters: 1) Path/query parameters - tool auto-extract từ spec, bạn chỉ cần fill values. 2) Request body - paste full JSON object trong Body textarea, including nested objects và arrays. Tool sẽ gửi exactly JSON bạn nhập. 3) Sử dụng examples từ spec nếu có - tool auto-fill từ spec examples. 4) Validate JSON syntax trước khi send để avoid errors. 5) Cho arrays, format đúng JSON: ["item1", "item2"] hoặc [{"key": "value"}].
Chúng tôi không chỉ thiết kế website, mà còn giúp doanh nghiệp xây dựng thương hiệu số mạnh mẽ. Cung cấp dịch vụ thiết kế website trọn gói từ thiết kế đến tối ưu SEO. Hãy liên hệ ngay với Tấn Phát Digital để cùng tạo nên những giải pháp công nghệ đột phá, hiệu quả và bền vững cho doanh nghiệp của bạn tại Hồ Chí Minh.
Tạo file .env và .env.example cho dự án.
Tạo .gitignore cho Node.js, Python, Java.
Tạo mock JSON data cho API testing.
Format và phân tích API response.
Test REST API: GET, POST, PUT, DELETE.
Chuyển đổi Binary, Hex, Base32.
Mã hóa/giải mã Base64.
Chuyển đổi Decimal, Binary, Hex.
Tạo CSS box-shadow trực quan.
Tính quyền file Linux.
Kiểm tra WCAG accessibility.
Tạo bảng màu ngẫu nhiên.