Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Ryuta Hamasaki @avosalmon

Slide 3

Slide 3 text

Agenda • Design-First API Development • Overview of OpenAPI • Designing API contract • Running mock server • Validating API response in testing

Slide 4

Slide 4 text

Design-First API Development • Design API contract first • Find and solve problems early on before building API • FE implements the feature using the mock API 👉 No need to wait until API is built • BE implements the API based on the API contract 👉 Validate API response in testing

Slide 5

Slide 5 text

Overview of OpenAPI • Documentation for REST API written in YAML or JSON • Previously known as Swagger • Swagger specification was donated to the OpenAPI Initiative • Swagger = tools to implement OpenAPI specification

Slide 6

Slide 6 text

Designing API Contract

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Rendering OpenAPI

Slide 11

Slide 11 text

Rendering OpenAPI • Stoplight (paid service) • Swagger UI • Swagger Hub (paid service) • Swagger Viewer (Chrome extension)

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Running mock server • Prism - OSS mock server for OpenAPI • Built by Stoplight • Returns response based on the OpenAPI schema • FE can use the mock server while BE is building the API • Docker image is available

Slide 17

Slide 17 text

Validate API response in feature tests • Make sure the actual response shape follows 
 the API contract • Spectator -> Didn’t work for me • Custom response assertion • league/openapi-psr7-validator • nyholm/psr7 • symfony/psr-http-message-bridge

Slide 18

Slide 18 text

Key take-aways • Design API contract before writing code • FE & BE develop the feature in parallel • OpenAPI is not just a documentation • Mock Server • Validate API Response in testing • Choose the right tool that works for you