Coder Social home page Coder Social logo

api-deep-dive's Introduction

API Design Workshop

Requirements

  • Read Adidas API Guidelines
  • Git
  • Code editor (e.g. VS Code)
    • in case you are using VS Code, install extensions such as openapi-lint and YAML
  • Swaggerhub account within adidas group (create an account and request access to it)
  • Spectral for local and ci/cd validations.

Design challenge

As a new assignment you are asked to write an API contract basing on a given list of affordances. You will base on a sample api description following adidas API guidelines and a number of predefined object models.

Your team decided wisely to think API First and API Design First.

API affordances (actions)

The existing core Product API provides this affordances:

  • Retrieve the list of products
  • Retrieve a single product
  • Retrieve the metadata related to products (tags, status, categories)
  • Create a product
  • Update an existing product (status...)
  • Retrieve reviews about a product
  • Add a product review
  • Retrieve product reviews statistics
  • Create a user
  • Retrieve user profile
  • Retrieve the user wishlist
  • Add a product into the wishlist
  • Delete a specific product from the wishlist
  • Clear the wishlist

Step1. Let's describe what actions our API affords

TASK: Translate the affordances into a REST API model. What endpoints will this API have? What operations will it perform on these endpoints? Can you find an alternative way to achieve similar, if not better, results from a design point of view?

Step2. Formalize the design in the Open API Specification

The OAS (Open API Specification) file can be edited in whatever tool you like BUT NOT GENERATED FROM YOUR CODE. We suggest either using the internal editor in Swaggerhub or VS Code with extensions. The most important thing is that the final one (the contract) MUST be in Swaggerhub.

TASK: Extend the existing sample-api.yaml. First change the filename into a name of your project.

We will walk step by step through the file explaining each of the different elements. Then basing on them you will, in pairs, complete a list of exercises defining subsequent parts of the API contract.

NOTE: Remember to validate your API specification after each exercise (step) completed.

Step3. Verify the design using Swaggerhub Documentation and Swaggerhub Auto-Mocking Service

TASK: Put your API contract into a new Swaggerhub API under a project. Put models in a Domain in Swaggerhub. Reference the models from the domain in your API. Check the validation. Does your API comply with the rules? If yes, try the Apiary Mock Service.

Step4. Review the API Design

At this stage you:

  • Ask feedback from your API users by sending them the documentation link.
  • Ask feedback from your product owner

In our context it means that you will change your pairs and in those new pairs verify each other's design (peer review).

Some example of bad designed APIs

Missing description Missing examples Missing HAL Exposing internal model Missing support contact

Usage of acronyms, what's ATP stands for ? Missing description / context Missing HAL Missing support contact

Some example of good designed APIs

Sample APIs following the guidelines are available at adidas-group GitHub. The samples include the following:

Very simple API including implementation, testing, and full CI/CD lifecycle.

Real-world API with state transition, API key client app authentication, exposed via API management.

Sample API used as the template for newly created projects at Apiary.

Real-world Adidas Inventory API (WIP)

Demo API, including implementation and testing used during training.

Sample API showcasing description of complex query parameter rules.

api-deep-dive's People

Contributors

amzani avatar jerzyn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.