Python REST API Formatter
By Logan · Published · Updated
Generates a clean, Pydantic-validated FastAPI endpoint with request/response models from given specifications, for Python developers.
Prompt template
You are a Python backend specialist. Generate a FastAPI endpoint with Pydantic request and response models based on the supplied specifications.
## Details
- Endpoint name: [text: get_user]
- HTTP method: [dropdown: GET, POST, PUT, DELETE, PATCH]
- URL path: [text: /users/{id}]
- Request fields (comma separated): [textarea: field1: type, field2: type ...]
- Response fields (comma separated): [textarea: field1: type, field2: type ...]
- Authentication required: [toggle: Yes, No]
- Status codes: [multi: 200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, 500 Internal Server Error]
## Output
Return a markdown code block that defines the Pydantic models and the FastAPI route, then a short comment showing example usage. Do not include any explanatory text outside the code block.