From a0b6a56ef7ee434fd9d7f800f18d4748c21791c7 Mon Sep 17 00:00:00 2001 From: Cesca <3009298@stud.hs-mannheim.de> Date: Tue, 11 Nov 2025 12:33:42 +0000 Subject: [PATCH] Aufgabe 6 --- .../labor/05_loesungen/01_REST-API_Übung.txt | 65 ++++++++++++ web/05/labor/05_loesungen/greeting.json | 99 +++++++++++++++++++ .../labor/05_loesungen/staudenpflanzen.json | 30 ++++++ web/06/labor/loesungen_06/swagger.yaml | 72 ++++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 web/05/labor/05_loesungen/01_REST-API_Übung.txt create mode 100644 web/05/labor/05_loesungen/greeting.json create mode 100644 web/05/labor/05_loesungen/staudenpflanzen.json create mode 100644 web/06/labor/loesungen_06/swagger.yaml diff --git a/web/05/labor/05_loesungen/01_REST-API_Übung.txt b/web/05/labor/05_loesungen/01_REST-API_Übung.txt new file mode 100644 index 0000000..f1b1c09 --- /dev/null +++ b/web/05/labor/05_loesungen/01_REST-API_Übung.txt @@ -0,0 +1,65 @@ +1.1) Antonette +1.2) 10 +1.3) sunt aut facere repellat provident occaecati excepturi optio reprehenderit +1.4) 5 +1.5) Ja +1.6) curl https://jsonplaceholder.typicode.com/posts?userId=2 + + +2.1)68eb4a0b-6c49-44e9-aec8-5af947d22141 + curl https://hp-api.onrender.com/api/characters/staff + +2.2) curl https://hp-api.onrender.com/api/character/68eb4a0b-6c49-44e9-aec8-5af947d22141 +2.3) blond + +3) siehe Datei staudenpflanzen.json + +4.1) +{ + "name": "Alex", + "alter": 30, + "wohnort": "Berlin" +} + +4.2) +{ + "produktname": "Kopfhörer", + "preis": 98.99, + "verfügbarkeit": "Ja", + "farben":["schwarz", "weiß"] +} + +4.3) +{ + "benutzername": "maria1999", + "passwort": "abc123", + "rolle": "Admin", + "adresse": { + "straße": "Bauernring 15", + "stadt": "Weilbach", + "plz": 12345 + } +} + +4.4) +[ + { + "titel": "Task1", + "erledigt": true + }, + { + "titel": "Task2", + "erledigt": false + } + ] + + 4.5) + { + "titel": "Blabla", + "autor": "Blubb", + "inhalt": "Nix", + "kommentar": { + "autor": "Niemand", + "text": "Auch nix!" + } + } diff --git a/web/05/labor/05_loesungen/greeting.json b/web/05/labor/05_loesungen/greeting.json new file mode 100644 index 0000000..441b685 --- /dev/null +++ b/web/05/labor/05_loesungen/greeting.json @@ -0,0 +1,99 @@ +{ + "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!" } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/web/05/labor/05_loesungen/staudenpflanzen.json b/web/05/labor/05_loesungen/staudenpflanzen.json new file mode 100644 index 0000000..82f3079 --- /dev/null +++ b/web/05/labor/05_loesungen/staudenpflanzen.json @@ -0,0 +1,30 @@ +[ + { + "_id": "6909f3da83629c03e8adedd7", + "name": "Lavendel", + "botanischer_name": "Lavandula angustifolia", + "standort": "Sonnig, trocken", + "besonderheiten": "Duftend, bienenfreundlich, winterhart" + }, + { + "_id": "6909f3db83629c03e8adedd9", + "name": "Funkie", + "botanischer_name": "Hosta", + "standort": "Halbschatten bis Schatten", + "besonderheiten": "Dekoratives Laub, schneckenanfällig, robust" + }, + { + "_id": "6909f3db83629c03e8adedda", + "name": "Sonnenhut", + "botanischer_name": "Echinacea purpurea", + "standort": "Sonnig", + "besonderheiten": "Heilpflanze, zieht Schmetterlinge, schneckenanfällig" + }, + { + "_id": "6909f3dc83629c03e8adeddb", + "name": "Tränendes Herz", + "botanischer_name": "Lamprocapnos spectabilis", + "standort": "Halbschatten", + "besonderheiten": "Herzförmige Blüten, romantisch, giftig" + } +] diff --git a/web/06/labor/loesungen_06/swagger.yaml b/web/06/labor/loesungen_06/swagger.yaml new file mode 100644 index 0000000..42c1a2f --- /dev/null +++ b/web/06/labor/loesungen_06/swagger.yaml @@ -0,0 +1,72 @@ +openapi: 3.0.0 +info: + title: Workshop-Anmeldung API + version: 1.0.0 +servers: + - url: https://web-637691723779.europe-west2.run.app +paths: + /registrierung: + post: + summary: Anmeldung zu einem Workshop + description: API für Anmeldedaten eines den Workshops. + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/WorkshopForm' + application/json: + schema: + $ref: '#/components/schemas/WorkshopForm' + responses: + '200': + description: Erfolgreiche Anmeldung + '400': + description: Ungültige Eingabe +components: + schemas: + WorkshopForm: + type: object + properties: + vorname: + type: string + example: "Max" + nachname: + type: string + example: "Mustermann" + email: + type: string + format: email + example: "max@beispiel.de" + handy: + type: string + example: "+491751234567" + kurs: + type: string + example: "Webentwicklung Basics" + session: + type: string + enum: ["vormittag", "nachmittag", "abend", "wochenende"] + example: "abend" + agb: + type: string + enum: ["ja", "on"] + example: "on" + newsletter: + type: string + enum: ["ja", "on"] + example: "ja" + equipment: + type: string + enum: ["ja", "on"] + example: "ja" + format: + type: string + enum: ["online", "praesenz"] + example: "online" + required: + - vorname + - nachname + - email + - agb + - format