/*
 * Jooby https://jooby.io
 * Apache License Version 2.0 https://jooby.io/LICENSE.txt
 * Copyright 2014 Edgar Espina
 */
package issues.i3729.museum;

import static io.swagger.v3.oas.models.SpecVersion.V31;
import static org.junit.jupiter.api.Assertions.assertEquals;

import io.jooby.openapi.OpenAPIResult;
import io.jooby.openapi.OpenAPITest;

public class MuseumTest {

  @OpenAPITest(value = MuseumApp.class, version = V31)
  public void shouldGenerateDoc(OpenAPIResult result) {
    assertEquals(
        "openapi: 3.1.0\n"
            + "info:\n"
            + "  title: Redocly Museum API\n"
            + "  description: \"An imaginary, but delightful Museum API for interacting with"
            + " museum\\\n"
            + "    \\ services and information. Built with love by Redocly.\"\n"
            + "  contact:\n"
            + "    url: https://redocly.com/docs/cli/\n"
            + "    email: team@redocly.com\n"
            + "  license:\n"
            + "    name: MIT\n"
            + "    url: https://opensource.org/license/mit/\n"
            + "  version: 1.0.0\n"
            + "  x-logo:\n"
            + "    url: https://redocly.github.io/redoc/museum-logo.png\n"
            + "    altText: Museum logo\n"
            + "servers:\n"
            + "- url: https://api.fake-museum-example.com/v1\n"
            + "paths:\n"
            + "  /museum-hours:\n"
            + "    get:\n"
            + "      tags:\n"
            + "      - Operations\n"
            + "      summary: Get museum hours\n"
            + "      description: Get upcoming museum operating hours\n"
            + "      operationId: getMuseumHours\n"
            + "      parameters:\n"
            + "      - name: startDate\n"
            + "        in: query\n"
            + "        description: The starting date to retrieve future operating hours from."
            + " Defaults\n"
            + "          to today's date.\n"
            + "        schema:\n"
            + "          type: string\n"
            + "          format: date\n"
            + "        example: 2023-02-23\n"
            + "      - name: page\n"
            + "        in: query\n"
            + "        description: The page number to retrieve.\n"
            + "        schema:\n"
            + "          type: integer\n"
            + "          format: int32\n"
            + "      - name: limit\n"
            + "        in: query\n"
            + "        description: The number of days per page.\n"
            + "        schema:\n"
            + "          type: integer\n"
            + "          format: int32\n"
            + "      responses:\n"
            + "        \"200\":\n"
            + "          description: List of museum operating hours for consecutive days.\n"
            + "          content:\n"
            + "            application/json:\n"
            + "              schema:\n"
            + "                type: array\n"
            + "                items:\n"
            + "                  $ref: \"#/components/schemas/MuseumDailyHours\"\n"
            + "              example:\n"
            + "                default:\n"
            + "                  summary: Museum opening hours\n"
            + "                  value:\n"
            + "                  - date: 2023-09-11\n"
            + "                    timeOpen: 09:00\n"
            + "                    timeClose: 18:00\n"
            + "                  - date: 2023-09-12\n"
            + "                    timeOpen: 09:00\n"
            + "                    timeClose: 18:00\n"
            + "                  - date: 2023-09-13\n"
            + "                    timeOpen: 09:00\n"
            + "                    timeClose: 18:00\n"
            + "                  - date: 2023-09-17\n"
            + "                    timeOpen: 09:00\n"
            + "                    timeClose: 18:00\n"
            + "                closed:\n"
            + "                  summary: The museum is closed\n"
            + "                  value: []\n"
            + "        \"400\":\n"
            + "          description: Bad Request\n"
            + "        \"404\":\n"
            + "          description: Not Found\n"
            + "      x-badges:\n"
            + "      - name: Beta\n"
            + "        position: before\n"
            + "        color: purple\n"
            + "  /special-events:\n"
            + "    post:\n"
            + "      summary: Create special event.\n"
            + "      operationId: createSpecialEvent\n"
            + "      requestBody:\n"
            + "        content:\n"
            + "          application/json:\n"
            + "            schema:\n"
            + "              $ref: \"#/components/schemas/CreateSpecialEventRequest\"\n"
            + "        required: true\n"
            + "      responses:\n"
            + "        \"200\":\n"
            + "          description: Success\n"
            + "          content:\n"
            + "            application/json:\n"
            + "              schema:\n"
            + "                $ref: \"#/components/schemas/CreateSpecialEventRequest\"\n"
            + "        \"400\":\n"
            + "          description: Bad Request\n"
            + "        \"404\":\n"
            + "          description: Not Found\n"
            + "components:\n"
            + "  schemas:\n"
            + "    MuseumDailyHours:\n"
            + "      type: object\n"
            + "      description: Daily operating hours for the museum.\n"
            + "      properties:\n"
            + "        date:\n"
            + "          type: string\n"
            + "          format: date\n"
            + "          description: Date the operating hours apply to.\n"
            + "          example: 2024-12-31\n"
            + "        timeOpen:\n"
            + "          type: string\n"
            + "          description: Time the museum opens on a specific date. Uses 24-hour time\n"
            + "            format HH:mm.\n"
            + "          example: 09:00\n"
            + "        timeClose:\n"
            + "          type: string\n"
            + "          description: Time the museum closes on a specific date. Uses 24-hour"
            + " time\n"
            + "            format HH:mm.\n"
            + "          example: 18:00\n"
            + "    CreateSpecialEventRequest:\n"
            + "      type: object\n"
            + "      description: Request payload for creating new special events at the museum.\n"
            + "      properties:\n"
            + "        name:\n"
            + "          type: string\n"
            + "          description: Name of the special event.\n"
            + "          example: Pirate Coding Workshop\n"
            + "        location:\n"
            + "          type: string\n"
            + "          description: Location where the special event is held.\n"
            + "          example: Computer Room\n"
            + "        eventDescription:\n"
            + "          type: string\n"
            + "          description: Description of the special event.\n"
            + "        dates:\n"
            + "          type: array\n"
            + "          description: List of planned dates for the special event.\n"
            + "          items:\n"
            + "            type: string\n"
            + "            format: date\n"
            + "        price:\n"
            + "          type: number\n"
            + "          description: Price of a ticket for the special event.\n"
            + "          example: 25\n",
        result.toYaml());
  }
}
