scanapi
play

ScanAPI Automated Integration Testing and Live Documentation for - PowerPoint PPT Presentation

ScanAPI Automated Integration Testing and Live Documentation for your API Camila Maia EuroPython 2020 1 Motivation Everything started in a week which I as Firefighter 2 I work at... 3 Who am I? - Brazilian Backend


  1. ScanAPI Automated Integration Testing and Live Documentation for your API Camila Maia EuroPython 2020 1

  2. Motivation Everything started in a week which I as Firefighter 🔦 ฀฀ 🚓 2

  3. I work at... 3

  4. Who am I? - Brazilian Backend Developer - Bachelor of Computer Information System - Coding since 2010 - Python and Ruby - Events: Pyjamas and EuroPython 4

  5. Motivation Everything started in a week which I as Firefighter 🔦 ฀฀ 🚓 5

  6. Motivation Integration Errors 💦 - Client sending fields different than what’s expected - Frontend receiving fields different than what’s expected 6

  7. Motivation Outdated documentation 📝 - Missing endpoints - Missing fields - Misinformation 7

  8. Motivation Hard to recreate scenarios 😥 /reserve/:seat_id flight_id? airplane_id? passenger_id? Is the airplane available? ???? 8

  9. Motivation Hard to recreate scenarios 😥 9

  10. Proposal - Open Source Framework - Written in Python 1. Provide a Live Documentation 2. Tool to implement integration tests 11

  11. How does it work? Example: PokéAPI PokéAPI: https://pokeapi.co $ http https://pokeapi.co/api/v2/pokemon/ 12

  12. 13

  13. 14

  14. How does it work? Example: PokéAPI Installing: $ pip install scanapi 15

  15. How does it work? Example: PokéAPI # api.yaml api: endpoints: - name: pokeapi path: https://pokeapi.co/api/v2/ endpoints: - name: pokemon path: pokemon requests: - name: list_all method: get path: / 16

  16. How does it work? Example: PokéAPI Running 17

  17. How does it work? Documentation 📅 18

  18. 19

  19. 20

  20. 21

  21. How does it work? Integration tests ✅ ... requests: - name: list_all method: get path: / tests: - name: status_code_is_200 assert: ${{ response.status_code == 200 }} - name: response_time_is_under_half_second assert: ${{ response.elapsed.total_seconds() < 0.5 }} - name: count_is_964 assert: ${{ response.json()["count"] == 964 }} https://requests.readthedocs.io 22

  22. 23

  23. How does it work? Chaining Requests ⛓ - Get details of a Pokémon - In this case, the data is “static”, but it might not be. - https://pokeapi.co/api/v2/pokemon/bulbasaur 24

  24. How does it work? Chaining requests ⛓ requests: - name: pokemon path: pokemon requests: - name: list_all method: get path: / vars: pokemon_name: ${{ response.json()["results"][0]["name"] }} tests: ... - name: details method: get pokemon/${pokemon_name} path: ${pokemon_name} 25

  25. 26

  26. Adding ScanAPI to a project 27

  27. Adding ScanAPI to a project 28

  28. ... workflows: scanapi: version: 2 docker: main: - image: jobs: camilamaia/scanapi:1.0.5 - scanapi: steps: filters: - checkout branches: - run: only: name: Run ScanAPI - master - build-push: command: | name: build-push-staging scanapi scanapi/api.yaml env: staging -c scanapi/.scanapi.yaml requires: -o scanapi/report.html - scanapi - store_artifacts: filters: path: scanapi/report.html branches: only: - master 29

  29. How does it work? And there is more 🎊 - Language-independent - It also accepts API spec in JSON - Environment variables - Hide sensitive info in the report - Multiple files API specification - Custom templates 30

  30. Can I start using it? For sure! 👎 31

  31. scanapi.dev 32

  32. Next Steps What about the future? 🔯 - Missing HTTP methods (current: GET, POST, PUT, PATCH, DELETE) - JSON visualization - Docs + Tutorials - Website improvements - GitHub Action And what if…. - OpenAPI 33

  33. Why to contribute? Join us! 🚁 - Backend, frontend, automation, design - “Pure Python” - Understand how a lib works - Test coverage > 90% - Issues with labels - i.e: good first issue 34

  34. Why to contribute? Join us! 🚁 How Open Source Changed My Life with Max Stoiber 35

  35. Sprint Session - Sprint session on this weekend - July 25th and 26th (free!) #sprint-scanapi More information 36

  36. github.com/scanapi ⭐ 37

  37. We are hiring! Loadsmart Direct Link 38

  38. #talk-scanapi #sprint-scanapi THANK YOU @cmaiacd camilamaia

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend