From fc274a1b55bb47473e66d6209531144170056cf6 Mon Sep 17 00:00:00 2001 From: Fabian <2121190@stud.hs-mannheim.de> Date: Mon, 2 Feb 2026 19:54:42 +0100 Subject: [PATCH] add readme --- README.md | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2101836 --- /dev/null +++ b/README.md @@ -0,0 +1,170 @@ +# API-Design und Dokumentation mit OpenAPI Workshop + +Datum: Di, 10.02.2026 +Startzeit: 08:30 Uhr +Raum: A108 + +Workshop-Folien: _pending_ + +## Installationsanleitung + +Benötigte Hardware: Eigener Laptop + +- [Visual Studio Code](#visual-studio-code) +- [Visual Studio Code Extensions](#visual-studio-code-extensions) +- [Python](#python) +- [Python Packages](#python-packages) +- [Abhängigkeiten installieren](#abhängigkeiten-installieren) +- [Java](#java) +- [Tools ausführen](#tools-ausführen) + +### Visual Studio Code + +Installationsanleitung hier zu finden: [https://code.visualstudio.com/](https://code.visualstudio.com/) + +### Visual Studio Code Extensions + +- YAML von RedHat (`redhat.vscode-yaml`) +- OpenAPI (Swagger) Editor von 42crunch (`42crunch.vscode-openapi`) +- Python von Microsoft (`ms-python.python`) + +### Python + +#### Download + +Lade Python von der offiziellen Website herunter: +👉 https://www.python.org/downloads/ + +**Empfohlene Version:** + +- Python **3.11 oder neuer** + +#### Installation + +- macOS / Windows: Installer ausführen +- **Wichtig (Windows):** +   ☑️ _“Add Python to PATH”_ aktivieren +- Linux: Normalerweise ist Python schon installiert + +#### Installation prüfen + +```bash +python --version +``` + +#### Projektordner vorbereiten + +```bash +mkdir openapi-workshop +cd openapi-workshop +``` + +#### Virtuelle Umgebung erstellen (empfohlen) + +**Virtuelle Umgebung anlegen** + +```bash +python -m venv .venv +``` + +**Aktivieren** +macOS / Linux + +```bash +source .venv/bin/activate +``` + +Windows (PowerShell) + +```powershell +.venv\Scripts\activate +``` + +Wenn alles korrekt ist, siehst du im Terminal: + +```text +(.venv) +``` + +#### pip aktualisieren + +```bash +python -m pip install --upgrade pip +``` + +### Python Packages + +Wir verwenden: + +- **FastAPI** – API Framework +- **Uvicorn** – ASGI Server +- **uv** + +```bash +python -m pip install fastapi uvicorn uv +``` + +Installation prüfen: + +```bash +python -m pip show fastapi uvicorn uv +``` + +### Abhängigkeiten installieren + +```sh +uv add openapi-generator-cli +``` + +### Java + +[https://jdk.java.net/25/](https://jdk.java.net/25/) + +### Tools ausführen + +#### FastAPI-Anwendung + +**Datei `code_first.py`** + +```python +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +def root(): +    return { +        "status": "ok", +        "docs": "/docs", +        "openapi": "/openapi.json" +    } +``` + +**Server starten** +⚠️ **FastAPI wird nicht mit `python code_first.py` gestartet**,   +sondern mit **`uvicorn`**. + +```bash +python -m uvicorn code_first:app --reload +``` + +**API aufrufen** +Im Browser: + +- **Swagger UI (interaktive API-Dokumentation):**   +   http://127.0.0.1:8000/docs +- **OpenAPI JSON:**   +   http://127.0.0.1:8000/openapi.json + +**Server stoppen** +Im Terminal: + +```text +CTRL + C +``` + +### OpenAPI Generator CLI + +```sh +uv run openapi-generator-cli +```