Skip to content

Latest commit

 

History

History
460 lines (326 loc) · 8.11 KB

presentation.md

File metadata and controls

460 lines (326 loc) · 8.11 KB
theme title defaults speaker jobTitle transition
ksick-dynatrace
API First
eventName eventDate
API First - freeCodeCamp
September 20, 2023
Andreas Taranetz
Software Engineer
slide-left
<style> .blue { color: var(--blue); } .green { color: var(--green); } .purple { color: var(--purple); } </style>

API First Approach


layout: about transition: fade-out image: andreas.webp speaker: Andreas Taranetz jobTitle: Software Engineer website: andreas.taranetz.com


layout: center

API (Application Programming Interface)

API specification = description of an API


layout: center

input → function → output

getUser(email: String):User { ... }


REST (REpresentational State Transfer)

Transfer a representation of the state of some resource

Action Request Method
Create POST
👀 Read GET
📝 Update PATCH / PUT
🗑️ Delete DELETE

URI (Universal Resource Identifier)

https: // andreas .taranetz .com / whoami ?key=value

Protocol Host Name Path Query Parameter


Media Types

Representation is controlled by the accept header

text/html

image/jpeg

application/json


layout: center transition: fade-out

JSON

{
	"swagger": "2.0",
	"info": {
		"version": "4.2.0",
		"description": "This is a json example."
	},
	"schemes": [
		"http",
		"https"
	]
}

YAML

swagger: "2.0"
info:
  version: 4.2.0
  description: This is a yaml example.
schemes:
  - http
  - https


layout: image-right image: getPets.png

Open API Specs

openapi: 3.1.0
info: ...
paths:
  /pet/{petId}:
    get:
      summary: Find pet by ID
      operationId: getPetById
      parameters:
        - name: petId
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        ...

layout: center transition: fade-out

DEMO TIME 🤞

editor-next.swagger.io


Generation of server code


Generation of client code


transition: fade-out

Generation of mock servers

github.com/muonsoft/openapi-mock

```bash docker run \ -p 8080:8080 \ -e "OPENAPI_MOCK_SPECIFICATION_URL=https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml" \ --rm muonsoft/openapi-mock ```
curl localhost:8080/v3/pet/1
{
	"category": {
		"id": 564639390,
		"name": "Odio illum. Facilis. Exercitationem."
	},
	"id": 544596506,
	"name": "Voluptatum error. Earum perferendis aut repellendus. Culpa alias laborum ratione.",
	"photoUrls": [
		"Ut temporibus. Iure et architecto repellendus. Perferendis blanditiis.",
		...
	],
	"status": "pending",
	"tags": [
		{
			"id": 900087713,
			"name": "Nostrum cum excepturi reiciendis sed. Ut. Sed accusantium alias nulla. Quia et. Dolor ducimus molestiae nulla fugiat sapiente qui reprehenderit."
		},
		...
	]
}

transition: fade-out

Versioning

In the host name

api-v2.example.com/resource

In the path

api.example.com/v2/resource

In the query

api.example.com/resource?version=2


layout: none transition: fade-out


Guidelines

Zalando

Microsoft

Google

...

just don't ask ChatGPT


layout: outro-speaker image: andreas.webp speaker: Andreas Taranetz website: andreas.taranetz.com


layout: center

Link to the slides