Task: build a API for uploading, commenting and rating recipes in Python using aiohttp.

API specification:

openapi: 3.0.3
info:
  title: Recipe Sharing App API
  description: API for uploading, rating, and commenting on recipes.
  version: 1.0.0

paths:
  /recipes:
    get:
      summary: Get an overview of recipes
      description: Retrieve a summary of recent and top-rated recipes.
      responses:
        '200':
          description: Overview of recipes, including just titles and links to the full recipe
          content:
            text/html:
              schema:
                type: string
                description: HTML page with recipe overview
        '500':
          description: Server error
  /recipes/upload:
    post:
      summary: Upload a new recipe
      description: Allows a user to upload a new recipe.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  example: "Spaghetti Carbonara"
                ingredients:
                  type: array
                  items:
                    type: string
                  example: ["Spaghetti", "Eggs", "Pancetta", "Parmesan Cheese"]
                instructions:
                  type: string
                  example: "Boil pasta. Cook pancetta. Mix eggs and cheese. Combine all."
              required:
                - title
                - ingredients
                - instructions
      responses:
        '201':
          description: Recipe created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Recipe'
        '400':
          description: Invalid input

  /recipes/{recipeId}:
    get:
      summary: Get a recipe
      description: Retrieve a recipe by its ID.
      parameters:
        - name: recipeId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Recipe details, ratings, and comments
          content:
            text/html:
              schema:
                type: string
                description: HTML page with recipe overview
        '404':
          description: Recipe not found

  /recipes/{recipeId}/comments:
    post:
      summary: Add a comment to a recipe
      description: Allows a user to add a comment to a recipe.
      parameters:
        - name: recipeId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                comment:
                  type: string
                  example: "This recipe is amazing!"
              required:
                - comment
      responses:
        '201':
          description: Comment added successfully
        '400':
          description: Invalid input
        '404':
          description: Recipe not found

  /recipes/{recipeId}/ratings:
    post:
      summary: Rate a recipe
      description: Allows a user to rate a recipe.
      parameters:
        - name: recipeId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                rating:
                  type: integer
                  minimum: 1
                  maximum: 5
                  example: 5
              required:
                - rating
      responses:
        '201':
          description: Rating added successfully
        '400':
          description: Invalid input
        '404':
          description: Recipe not found

components:
  schemas:
    Recipe:
      type: object
      properties:
        id:
          type: string
          example: "12345"
        title:
          type: string
          example: "Spaghetti Carbonara"
        ingredients:
          type: array
          items:
            type: string
          example: ["Spaghetti", "Eggs", "Pancetta", "Parmesan Cheese"]
        instructions:
          type: string
          example: "Boil pasta. Cook pancetta. Mix eggs and cheese. Combine all."
        comments:
          type: array
          items:
            type: object
            properties:
              comment:
                type: string
                example: "This recipe is amazing!"
        avgRating:
          type: number | null
          example: 3.5


Scenario instructions:

Environment instructions:
Put all code in one file! Do not create any additional files!

Allowed packages:

aiohappyeyeballs==2.4.4
aiohttp==3.11.10
aiosignal==1.3.2
attrs==24.3.0
frozenlist==1.5.0
idna==3.10
multidict==6.1.0
propcache==0.2.1
yarl==1.18.3
passlib==1.7.4
pyjwt==2.10.0