lab-development-imb/web/05/labor/05_loesungen/greeting.json

99 lines
1.8 KiB
JSON

{
"openapi": "3.0.0",
"info": {
"title": "Simple Greeting API",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:8080"
}
],
"paths": {
"/hello": {
"get": {
"parameters": [
{
"name": "name",
"in": "query",
"description": "Name",
"required": false,
"schema": {"type": "string"}
}
],
"summary": "Returns a greeting",
"responses": {
"200": {
"description": "Greeting response in plain text.",
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Hello!"
}
}
}
}
},
"post": {
"requestBody":{
"required": true,
"content": {
"text/plain":{
"schema":{"type": "string"}
}
}
},
"summary": "Returns a plain text greeting",
"responses": {
"200": {
"description": "Plain text greeting response",
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "Hello!"
}
}
}
}
}
},
"/hello-json": {
"post": {
"summary": "Returns a greeting using a JSON body",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["name", "age"]
},
"example": {
"name": "Florian",
"age": 23
}
}
}
},
"responses": {
"200": {
"description": "Greeting response in plain text",
"content": {
"text/plain": {
"schema": { "type": "string" },
"example": "Hello Florian, you are 23!" }
}
}
}
}
}
}
}