theme | title | defaults | speaker | jobTitle | transition | ||||
---|---|---|---|---|---|---|---|---|---|
ksick-dynatrace |
API First |
|
Andreas Taranetz |
Software Engineer |
slide-left |
layout: about transition: fade-out image: andreas.webp speaker: Andreas Taranetz jobTitle: Software Engineer website: andreas.taranetz.com
API specification = description of an API
input → function → output
getUser(email: String):User { ... }
Transfer a representation of the state of some resource
Action | Request Method |
---|---|
✨ Create | POST |
👀 Read | GET |
📝 Update | PATCH / PUT |
🗑️ Delete | DELETE |
https: // andreas .taranetz .com / whoami ?key=value
Protocol Host Name Path Query Parameter
Representation is controlled by the accept header
text/html
image/jpeg
application/json
{
"swagger": "2.0",
"info": {
"version": "4.2.0",
"description": "This is a json example."
},
"schemes": [
"http",
"https"
]
}
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'
...
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."
},
...
]
}
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: iframe-right url: https://opensource.zalando.com/restful-api-guidelines/
...
just don't ask ChatGPT