diff --git a/.changeset/eighty-dolls-sniff.md b/.changeset/eighty-dolls-sniff.md new file mode 100644 index 0000000000..7b82ccb72e --- /dev/null +++ b/.changeset/eighty-dolls-sniff.md @@ -0,0 +1,5 @@ +--- +"@redocly/cli": patch +--- + +Fixed a problem where the `split` command produced backslashes instead of forward slashes in `$ref`s on Windows. diff --git a/.github/workflows/smoke-plugins.yaml b/.github/workflows/smoke-plugins.yaml index 2c44553b42..31af7f6ee4 100644 --- a/.github/workflows/smoke-plugins.yaml +++ b/.github/workflows/smoke-plugins.yaml @@ -20,7 +20,7 @@ jobs: - name: Install dependencies run: npm ci - name: Prepare Smoke - run: bash ./scripts/prepare-smoke-plugins.sh + run: bash ./__tests__/smoke-plugins/prepare-smoke-plugins.sh - uses: actions/cache@v3 with: path: __tests__/smoke-plugins/ diff --git a/.github/workflows/smoke.yaml b/.github/workflows/smoke.yaml index 26ca1ef653..01cc699bb2 100644 --- a/.github/workflows/smoke.yaml +++ b/.github/workflows/smoke.yaml @@ -20,7 +20,7 @@ jobs: - name: Install dependencies run: npm ci - name: Prepare Smoke - run: bash ./scripts/prepare-smoke.sh + run: bash ./__tests__/smoke/prepare-smoke.sh - uses: actions/cache@v3 with: path: __tests__/smoke/ @@ -291,15 +291,23 @@ jobs: run: docker build -t redocly/cli:latest . - name: Run docker image run: | + # Prepare + cp resources/pets.yaml resources/museum.yaml __tests__/smoke/ cd __tests__/smoke/ + + # Run commands docker run --rm redocly/cli:latest --version docker run --rm -v $PWD:/spec redocly/cli:latest lint openapi.yaml docker run --rm -v $PWD:/spec redocly/cli:latest bundle openapi.yaml --ext json docker run --rm -v $PWD:/spec redocly/cli:latest build-docs openapi.yaml - # Check for broken styles (related issue: https://github.com/Redocly/redocly-cli/issues/1073) - if [[ "$(wc -l redoc-static.html)" == "324 redoc-static.html" ]]; then - echo "Docs built correctly." - else - echo "Docs built incorrectly. Received lines: $(wc -l redoc-static.html) (expected 324 lines in redoc-static.html)." - exit 1 - fi + docker run --rm -v $PWD:/spec redocly/cli:latest split pets.yaml --outDir output/split/petstore && docker run --rm -v $PWD:/spec redocly/cli:latest split museum.yaml --outDir output/split/museum + + # Check for broken styles when building docs (related issue: https://github.com/Redocly/redocly-cli/issues/1073) + echo "Checking docs for issues..." + diff pre-built/redoc.html redoc-static.html + echo "✅ Docs built correctly." + + # Check for broken $refs (or other issues) in the split files, especially on Windows (it will fail on a difference) + echo "Checking split files for issues..." + diff -r pre-split output/split + echo "✅ Files split correctly." diff --git a/scripts/prepare-smoke-plugins.sh b/__tests__/smoke-plugins/prepare-smoke-plugins.sh similarity index 100% rename from scripts/prepare-smoke-plugins.sh rename to __tests__/smoke-plugins/prepare-smoke-plugins.sh diff --git a/__tests__/smoke/package.json b/__tests__/smoke/package.json index 14d09dfb93..8f5f348587 100644 --- a/__tests__/smoke/package.json +++ b/__tests__/smoke/package.json @@ -8,7 +8,8 @@ "redocly-version": "redocly --version", "redocly-lint": "redocly lint openapi.yaml", "redocly-bundle": "redocly bundle openapi.yaml --ext json", - "redocly-build-docs": "redocly build-docs openapi.yaml" + "redocly-build-docs": "redocly build-docs openapi.yaml", + "redocly-split": "redocly split pets.yaml --outDir output/split/petstore && redocly split museum.yaml --outDir output/split/museum" }, "author": "redocly", "license": "ISC" diff --git a/__tests__/smoke/pre-built/redoc.html b/__tests__/smoke/pre-built/redoc.html new file mode 100644 index 0000000000..6dc028cc3c --- /dev/null +++ b/__tests__/smoke/pre-built/redoc.html @@ -0,0 +1,324 @@ + + + + + + Sample API + + + + + + + + + +

Sample API (1.0.0)

Download OpenAPI specification:

Get a greeting message

Responses

Response samples

Content type
application/json
{
  • "message": "string"
}
+ + + + diff --git a/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsRequestExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsRequestExample.yaml new file mode 100644 index 0000000000..985f2faf1c --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsRequestExample.yaml @@ -0,0 +1,6 @@ +summary: Special event ticket +value: + ticketType: general + eventId: dad4bce8-f5cb-4078-a211-995864315e39 + ticketDate: '2023-09-05' + email: todd@example.com diff --git a/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsResponseExample.yaml new file mode 100644 index 0000000000..ab1617a206 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/BuyEventTicketsResponseExample.yaml @@ -0,0 +1,8 @@ +summary: Special event ticket +value: + message: Museum special event ticket purchased + ticketId: b811f723-17b2-44f7-8952-24b03e43d8a9 + eventName: Mermaid Treasure Identification and Analysis + ticketType: event + ticketDate: '2023-09-05' + confirmationCode: ticket-event-9c55eg-8v82a diff --git a/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsRequestExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsRequestExample.yaml new file mode 100644 index 0000000000..35ef9c3e0e --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsRequestExample.yaml @@ -0,0 +1,5 @@ +summary: General entry ticket +value: + ticketType: general + ticketDate: '2023-09-07' + email: todd@example.com diff --git a/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsResponseExample.yaml new file mode 100644 index 0000000000..03dd9db417 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/BuyGeneralTicketsResponseExample.yaml @@ -0,0 +1,7 @@ +summary: General entry ticket +value: + message: Museum general entry ticket purchased + ticketId: 382c0820-0530-4f4b-99af-13811ad0f17a + ticketType: general + ticketDate: '2023-09-07' + confirmationCode: ticket-general-e5e5c6-dce78 diff --git a/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventRequestExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventRequestExample.yaml new file mode 100644 index 0000000000..1221d9eb72 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventRequestExample.yaml @@ -0,0 +1,11 @@ +summary: Create special event +value: + name: Mermaid Treasure Identification and Analysis + location: Under the seaaa 🦀 🎶 🌊. + eventDescription: >- + Join us as we review and classify a rare collection of 20 thingamabobs, + gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel. + dates: + - '2023-09-05' + - '2023-09-08' + price: 0 diff --git a/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventResponseExample.yaml new file mode 100644 index 0000000000..6c67d1a414 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/CreateSpecialEventResponseExample.yaml @@ -0,0 +1,12 @@ +summary: Special event created +value: + eventId: dad4bce8-f5cb-4078-a211-995864315e39 + name: Mermaid Treasure Identification and Analysis + location: Under the seaaa 🦀 🎶 🌊. + eventDescription: >- + Join us as we review and classify a rare collection of 20 thingamabobs, + gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel. + dates: + - '2023-09-05' + - '2023-09-08' + price: 30 diff --git a/__tests__/smoke/pre-split/museum/components/examples/GetMuseumHoursResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/GetMuseumHoursResponseExample.yaml new file mode 100644 index 0000000000..75af54eaf9 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/GetMuseumHoursResponseExample.yaml @@ -0,0 +1,32 @@ +summary: Get hours response +value: + - date: '2023-09-11' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-12' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-13' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-14' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-15' + timeOpen: '10:00' + timeClose: '16:00' + - date: '2023-09-18' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-19' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-20' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-21' + timeOpen: '09:00' + timeClose: '18:00' + - date: '2023-09-22' + timeOpen: '10:00' + timeClose: '16:00' diff --git a/__tests__/smoke/pre-split/museum/components/examples/GetSpecialEventResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/GetSpecialEventResponseExample.yaml new file mode 100644 index 0000000000..29f16ac3c5 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/GetSpecialEventResponseExample.yaml @@ -0,0 +1,11 @@ +summary: Get special event +value: + eventId: 6744a0da-4121-49cd-8479-f8cc20526495 + name: Time Traveler Tea Party + location: Temporal Tearoom + eventDescription: Sip tea with important historical figures. + dates: + - '2023-11-18' + - '2023-11-25' + - '2023-12-02' + price: 60 diff --git a/__tests__/smoke/pre-split/museum/components/examples/ListSpecialEventsResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/ListSpecialEventsResponseExample.yaml new file mode 100644 index 0000000000..39e7e8d71c --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/ListSpecialEventsResponseExample.yaml @@ -0,0 +1,93 @@ +summary: List of special events +value: + - eventId: f3e0e76e-e4a8-466e-ab9c-ae36c15b8e97 + name: Sasquatch Ballet + location: Seattle... probably + eventDescription: >- + They're big, they're hairy, but they're also graceful. Come learn how the + biggest feet can have the lightest touch. + dates: + - '2023-12-15' + - '2023-12-22' + price: 40 + - eventId: 2f14374a-9c65-4ee5-94b7-fba66d893483 + name: Solar Telescope Demonstration + location: Far from the sun. + eventDescription: Look at the sun without going blind! + dates: + - '2023-09-07' + - '2023-09-14' + price: 50 + - eventId: 6aaa61ba-b2aa-4868-b803-603dbbf7bfdb + name: Cook like a Caveman + location: Fire Pit on East side + eventDescription: Learn to cook on an open flame. + dates: + - '2023-11-10' + - '2023-11-17' + - '2023-11-24' + price: 5 + - eventId: 602b75e1-5696-4ab8-8c7a-f9e13580f910 + name: Underwater Basket Weaving + location: Rec Center Pool next door. + eventDescription: Learn to weave baskets underwater. + dates: + - '2023-09-12' + - '2023-09-15' + price: 15 + - eventId: dad4bce8-f5cb-4078-a211-995864315e39 + name: Mermaid Treasure Identification and Analysis + location: Room Sea-12 + eventDescription: >- + Join us as we review and classify a rare collection of 20 thingamabobs, + gadgets, gizmos, whoosits, and whatsits — kindly donated by Ariel. + dates: + - '2023-09-05' + - '2023-09-08' + price: 30 + - eventId: 6744a0da-4121-49cd-8479-f8cc20526495 + name: Time Traveler Tea Party + location: Temporal Tearoom + eventDescription: Sip tea with important historical figures. + dates: + - '2023-11-18' + - '2023-11-25' + - '2023-12-02' + price: 60 + - eventId: 3be6453c-03eb-4357-ae5a-984a0e574a54 + name: Pirate Coding Workshop + location: Computer Room + eventDescription: >- + Captain Blackbeard shares his love of the C...language. And possibly + Arrrrr (R lang). + dates: + - '2023-10-29' + - '2023-10-30' + - '2023-10-31' + price: 45 + - eventId: 9d90d29a-2af5-4206-97d9-9ea9ceadcb78 + name: Llama Street Art Through the Ages + location: Auditorium + eventDescription: Llama street art?! Alpaca my bags -- let's go! + dates: + - '2023-10-29' + - '2023-10-30' + - '2023-10-31' + price: 45 + - eventId: a3c7b2c4-b5fb-4ef7-9322-00a919864957 + name: The Great Parrot Debate + location: Outdoor Amphitheatre + eventDescription: See leading parrot minds discuss important geopolitical issues. + dates: + - '2023-11-03' + - '2023-11-10' + price: 35 + - eventId: b92d46b7-4c5d-422b-87a5-287767e26f29 + name: Eat a Bunch of Corn + location: Cafeteria + eventDescription: We accidentally bought too much corn. Please come eat it. + dates: + - '2023-11-10' + - '2023-11-17' + - '2023-11-24' + price: 5 diff --git a/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventRequestExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventRequestExample.yaml new file mode 100644 index 0000000000..b4e981989b --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventRequestExample.yaml @@ -0,0 +1,4 @@ +summary: Update special event request +value: + location: On the beach. + price: 15 diff --git a/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventResponseExample.yaml b/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventResponseExample.yaml new file mode 100644 index 0000000000..fd69527987 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/examples/UpdateSpecialEventResponseExample.yaml @@ -0,0 +1,12 @@ +summary: Update special event +value: + eventId: dad4bce8-f5cb-4078-a211-995864315e39 + name: Mermaid Treasure Identification and Analysis + location: On the beach. + eventDescription: >- + Join us as we review and classify a rare collection of 20 thingamabobs, + gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel. + dates: + - '2023-09-05' + - '2023-09-08' + price: 15 diff --git a/__tests__/smoke/pre-split/museum/components/parameters/EndDate.yaml b/__tests__/smoke/pre-split/museum/components/parameters/EndDate.yaml new file mode 100644 index 0000000000..3eca72b558 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/EndDate.yaml @@ -0,0 +1,9 @@ +name: endDate +in: query +description: >- + End of a date range to retrieve special events for. Defaults to 7 days after + `startDate`. +schema: + type: string + format: date + example: '2023-04-18' diff --git a/__tests__/smoke/pre-split/museum/components/parameters/EventId.yaml b/__tests__/smoke/pre-split/museum/components/parameters/EventId.yaml new file mode 100644 index 0000000000..c026dffadd --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/EventId.yaml @@ -0,0 +1,8 @@ +name: eventId +in: path +description: Identifier for a special event. +required: true +schema: + type: string + format: uuid + example: dad4bce8-f5cb-4078-a211-995864315e39 diff --git a/__tests__/smoke/pre-split/museum/components/parameters/PaginationLimit.yaml b/__tests__/smoke/pre-split/museum/components/parameters/PaginationLimit.yaml new file mode 100644 index 0000000000..f999cbeb53 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/PaginationLimit.yaml @@ -0,0 +1,8 @@ +name: limit +in: query +description: Number of days per page. +schema: + type: integer + default: 10 + maximum: 30 + example: 15 diff --git a/__tests__/smoke/pre-split/museum/components/parameters/PaginationPage.yaml b/__tests__/smoke/pre-split/museum/components/parameters/PaginationPage.yaml new file mode 100644 index 0000000000..573d342fd8 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/PaginationPage.yaml @@ -0,0 +1,7 @@ +name: page +in: query +description: Page number to retrieve. +schema: + type: integer + default: 1 + example: 2 diff --git a/__tests__/smoke/pre-split/museum/components/parameters/StartDate.yaml b/__tests__/smoke/pre-split/museum/components/parameters/StartDate.yaml new file mode 100644 index 0000000000..26333b5862 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/StartDate.yaml @@ -0,0 +1,9 @@ +name: startDate +in: query +description: >- + Starting date to retrieve future operating hours from. Defaults to today's + date. +schema: + type: string + format: date + example: '2023-02-23' diff --git a/__tests__/smoke/pre-split/museum/components/parameters/TicketId.yaml b/__tests__/smoke/pre-split/museum/components/parameters/TicketId.yaml new file mode 100644 index 0000000000..889b6aeffa --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/parameters/TicketId.yaml @@ -0,0 +1,8 @@ +name: ticketId +in: path +description: Identifier for a ticket to a museum event. Used to generate ticket image. +required: true +schema: + type: string + format: uuid + example: a54a57ca-36f8-421b-a6b4-2e8f26858a4c diff --git a/__tests__/smoke/pre-split/museum/components/responses/BadRequest.yaml b/__tests__/smoke/pre-split/museum/components/responses/BadRequest.yaml new file mode 100644 index 0000000000..14e9a2822c --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/responses/BadRequest.yaml @@ -0,0 +1,5 @@ +description: Bad request. +content: + application/problem+json: + schema: + $ref: ../schemas/Error.yaml diff --git a/__tests__/smoke/pre-split/museum/components/responses/NotFound.yaml b/__tests__/smoke/pre-split/museum/components/responses/NotFound.yaml new file mode 100644 index 0000000000..eb202e0e4b --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/responses/NotFound.yaml @@ -0,0 +1,5 @@ +description: Not found. +content: + application/problem+json: + schema: + $ref: ../schemas/Error.yaml diff --git a/__tests__/smoke/pre-split/museum/components/responses/Unauthorized.yaml b/__tests__/smoke/pre-split/museum/components/responses/Unauthorized.yaml new file mode 100644 index 0000000000..82085d983d --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/responses/Unauthorized.yaml @@ -0,0 +1,5 @@ +description: Unauthorized. +content: + application/problem+json: + schema: + $ref: ../schemas/Error.yaml diff --git a/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsRequest.yaml b/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsRequest.yaml new file mode 100644 index 0000000000..3fc0cbac5e --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsRequest.yaml @@ -0,0 +1,21 @@ +description: Request payload used for purchasing museum tickets. +type: object +properties: + ticketType: + $ref: ./TicketType.yaml + eventId: + description: >- + Unique identifier for a special event. Required if purchasing tickets for + the museum's special events. + $ref: ./EventId.yaml + ticketDate: + description: Date that the ticket is valid for. + $ref: ./Date.yaml + email: + $ref: ./Email.yaml + phone: + $ref: ./Phone.yaml +required: + - ticketType + - ticketDate + - email diff --git a/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsResponse.yaml b/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsResponse.yaml new file mode 100644 index 0000000000..0e46dc5e68 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/BuyMuseumTicketsResponse.yaml @@ -0,0 +1,22 @@ +description: Details for a museum ticket after a successful purchase. +type: object +properties: + message: + $ref: ./TicketMessage.yaml + eventName: + $ref: ./EventName.yaml + ticketId: + $ref: ./TicketId.yaml + ticketType: + $ref: ./TicketType.yaml + ticketDate: + description: Date the ticket is valid for. + $ref: ./Date.yaml + confirmationCode: + $ref: ./TicketConfirmation.yaml +required: + - message + - ticketId + - ticketType + - ticketDate + - confirmationCode diff --git a/__tests__/smoke/pre-split/museum/components/schemas/CreateSpecialEventRequest.yaml b/__tests__/smoke/pre-split/museum/components/schemas/CreateSpecialEventRequest.yaml new file mode 100644 index 0000000000..af79a9056f --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/CreateSpecialEventRequest.yaml @@ -0,0 +1,19 @@ +description: Request payload for creating new special events at the museum. +type: object +properties: + name: + $ref: ./EventName.yaml + location: + $ref: ./EventLocation.yaml + eventDescription: + $ref: ./EventDescription.yaml + dates: + $ref: ./EventDates.yaml + price: + $ref: ./EventPrice.yaml +required: + - name + - location + - eventDescription + - dates + - price diff --git a/__tests__/smoke/pre-split/museum/components/schemas/Date.yaml b/__tests__/smoke/pre-split/museum/components/schemas/Date.yaml new file mode 100644 index 0000000000..a887a4eea9 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/Date.yaml @@ -0,0 +1,3 @@ +type: string +format: date +example: '2023-10-29' diff --git a/__tests__/smoke/pre-split/museum/components/schemas/Email.yaml b/__tests__/smoke/pre-split/museum/components/schemas/Email.yaml new file mode 100644 index 0000000000..2fe66c7c92 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/Email.yaml @@ -0,0 +1,4 @@ +description: Email address for ticket purchaser. +type: string +format: email +example: museum-lover@example.com diff --git a/__tests__/smoke/pre-split/museum/components/schemas/Error.yaml b/__tests__/smoke/pre-split/museum/components/schemas/Error.yaml new file mode 100644 index 0000000000..c8c62bed04 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/Error.yaml @@ -0,0 +1,8 @@ +type: object +properties: + type: + type: string + example: object + title: + type: string + example: Validation failed diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventDates.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventDates.yaml new file mode 100644 index 0000000000..b41579bd44 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventDates.yaml @@ -0,0 +1,4 @@ +type: array +items: + $ref: ./Date.yaml +description: List of planned dates for the special event. diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventDescription.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventDescription.yaml new file mode 100644 index 0000000000..d7218a9e84 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventDescription.yaml @@ -0,0 +1,5 @@ +type: string +description: Description of the special event. +example: >- + Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R + lang). diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventId.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventId.yaml new file mode 100644 index 0000000000..4c6f8e7fe8 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventId.yaml @@ -0,0 +1,4 @@ +description: Identifier for a special event. +type: string +format: uuid +example: 3be6453c-03eb-4357-ae5a-984a0e574a54 diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventLocation.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventLocation.yaml new file mode 100644 index 0000000000..78841026dc --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventLocation.yaml @@ -0,0 +1,3 @@ +type: string +description: Location where the special event is held. +example: Computer Room diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventName.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventName.yaml new file mode 100644 index 0000000000..9351836e00 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventName.yaml @@ -0,0 +1,3 @@ +type: string +description: Name of the special event. +example: Pirate Coding Workshop diff --git a/__tests__/smoke/pre-split/museum/components/schemas/EventPrice.yaml b/__tests__/smoke/pre-split/museum/components/schemas/EventPrice.yaml new file mode 100644 index 0000000000..902f556fdb --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/EventPrice.yaml @@ -0,0 +1,4 @@ +description: Price of a ticket for the special event. +type: number +format: float +example: 25 diff --git a/__tests__/smoke/pre-split/museum/components/schemas/GetMuseumHoursResponse.yaml b/__tests__/smoke/pre-split/museum/components/schemas/GetMuseumHoursResponse.yaml new file mode 100644 index 0000000000..afd1520905 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/GetMuseumHoursResponse.yaml @@ -0,0 +1,4 @@ +description: List of museum operating hours for consecutive days. +type: array +items: + $ref: ./MuseumDailyHours.yaml diff --git a/__tests__/smoke/pre-split/museum/components/schemas/GetTicketCodeResponse.yaml b/__tests__/smoke/pre-split/museum/components/schemas/GetTicketCodeResponse.yaml new file mode 100644 index 0000000000..ad8aad3b6b --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/GetTicketCodeResponse.yaml @@ -0,0 +1,3 @@ +description: Image of a ticket with a QR code used for museum or event entry. +type: string +format: binary diff --git a/__tests__/smoke/pre-split/museum/components/schemas/ListSpecialEventsResponse.yaml b/__tests__/smoke/pre-split/museum/components/schemas/ListSpecialEventsResponse.yaml new file mode 100644 index 0000000000..48a926b84f --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/ListSpecialEventsResponse.yaml @@ -0,0 +1,4 @@ +description: List of upcoming special events. +type: array +items: + $ref: ./SpecialEventResponse.yaml diff --git a/__tests__/smoke/pre-split/museum/components/schemas/MuseumDailyHours.yaml b/__tests__/smoke/pre-split/museum/components/schemas/MuseumDailyHours.yaml new file mode 100644 index 0000000000..5823903e9b --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/MuseumDailyHours.yaml @@ -0,0 +1,25 @@ +description: Daily operating hours for the museum. +type: object +properties: + date: + description: Date the operating hours apply to. + $ref: ./Date.yaml + example: '2024-12-31' + timeOpen: + type: string + pattern: ^([01]\d|2[0-3]):?([0-5]\d)$ + description: >- + Time the museum opens on a specific date. Uses 24 hour time format + (`HH:mm`). + example: '09:00' + timeClose: + description: >- + Time the museum closes on a specific date. Uses 24 hour time format + (`HH:mm`). + type: string + pattern: ^([01]\d|2[0-3]):?([0-5]\d)$ + example: '18:00' +required: + - date + - timeOpen + - timeClose diff --git a/__tests__/smoke/pre-split/museum/components/schemas/Phone.yaml b/__tests__/smoke/pre-split/museum/components/schemas/Phone.yaml new file mode 100644 index 0000000000..0baf619a00 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/Phone.yaml @@ -0,0 +1,3 @@ +description: Phone number for the ticket purchaser (optional). +type: string +example: +1(234)-567-8910 diff --git a/__tests__/smoke/pre-split/museum/components/schemas/SpecialEventResponse.yaml b/__tests__/smoke/pre-split/museum/components/schemas/SpecialEventResponse.yaml new file mode 100644 index 0000000000..f340cf7758 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/SpecialEventResponse.yaml @@ -0,0 +1,22 @@ +description: Information about a special event. +type: object +properties: + eventId: + $ref: ./EventId.yaml + name: + $ref: ./EventName.yaml + location: + $ref: ./EventLocation.yaml + eventDescription: + $ref: ./EventDescription.yaml + dates: + $ref: ./EventDates.yaml + price: + $ref: ./EventPrice.yaml +required: + - eventId + - name + - location + - eventDescription + - dates + - price diff --git a/__tests__/smoke/pre-split/museum/components/schemas/TicketConfirmation.yaml b/__tests__/smoke/pre-split/museum/components/schemas/TicketConfirmation.yaml new file mode 100644 index 0000000000..c405484f3a --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/TicketConfirmation.yaml @@ -0,0 +1,3 @@ +description: Unique confirmation code used to verify ticket purchase. +type: string +example: ticket-event-a98c8f-7eb12 diff --git a/__tests__/smoke/pre-split/museum/components/schemas/TicketId.yaml b/__tests__/smoke/pre-split/museum/components/schemas/TicketId.yaml new file mode 100644 index 0000000000..260fd8afc2 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/TicketId.yaml @@ -0,0 +1,4 @@ +description: Unique identifier for museum ticket. Generated when purchased. +type: string +format: uuid +example: a54a57ca-36f8-421b-a6b4-2e8f26858a4c diff --git a/__tests__/smoke/pre-split/museum/components/schemas/TicketMessage.yaml b/__tests__/smoke/pre-split/museum/components/schemas/TicketMessage.yaml new file mode 100644 index 0000000000..8b1cad6463 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/TicketMessage.yaml @@ -0,0 +1,3 @@ +description: Confirmation message after a ticket purchase. +type: string +example: Museum general entry ticket purchased diff --git a/__tests__/smoke/pre-split/museum/components/schemas/TicketType.yaml b/__tests__/smoke/pre-split/museum/components/schemas/TicketType.yaml new file mode 100644 index 0000000000..d58b93545f --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/TicketType.yaml @@ -0,0 +1,8 @@ +description: >- + Type of ticket being purchased. Use `general` for regular museum entry and + `event` for tickets to special events. +type: string +enum: + - event + - general +example: event diff --git a/__tests__/smoke/pre-split/museum/components/schemas/UpdateSpecialEventRequest.yaml b/__tests__/smoke/pre-split/museum/components/schemas/UpdateSpecialEventRequest.yaml new file mode 100644 index 0000000000..5faeb2daa1 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/components/schemas/UpdateSpecialEventRequest.yaml @@ -0,0 +1,15 @@ +description: >- + Request payload for updating an existing special event. Only included fields + are updated in the event. +type: object +properties: + name: + $ref: ./EventName.yaml + location: + $ref: ./EventLocation.yaml + eventDescription: + $ref: ./EventDescription.yaml + dates: + $ref: ./EventDates.yaml + price: + $ref: ./EventPrice.yaml diff --git a/__tests__/smoke/pre-split/museum/openapi.yaml b/__tests__/smoke/pre-split/museum/openapi.yaml new file mode 100644 index 0000000000..0907246998 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/openapi.yaml @@ -0,0 +1,41 @@ +openapi: 3.1.0 +info: + title: Redocly Museum API + description: >- + Imaginary, but delightful Museum API for interacting with museum services + and information. Built with love by Redocly. + version: 1.1.1 + termsOfService: https://redocly.com/subscription-agreement/ + contact: + email: team@redocly.com + url: https://redocly.com/docs/cli/ + license: + name: MIT + url: https://opensource.org/license/mit/ +servers: + - url: https://redocly.com/_mock/docs/openapi/museum-api +paths: + /museum-hours: + $ref: paths/museum-hours.yaml + /special-events: + $ref: paths/special-events.yaml + /special-events/{eventId}: + $ref: paths/special-events_{eventId}.yaml + /tickets: + $ref: paths/tickets.yaml + /tickets/{ticketId}/qr: + $ref: paths/tickets_{ticketId}_qr.yaml +components: + securitySchemes: + MuseumPlaceholderAuth: + type: http + scheme: basic +tags: + - name: Operations + description: Operational information about the museum. + - name: Events + description: Special events hosted by the museum. + - name: Tickets + description: Museum tickets for general entrance or special events. +security: + - MuseumPlaceholderAuth: [] diff --git a/__tests__/smoke/pre-split/museum/paths/museum-hours.yaml b/__tests__/smoke/pre-split/museum/paths/museum-hours.yaml new file mode 100644 index 0000000000..b77c272150 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/paths/museum-hours.yaml @@ -0,0 +1,24 @@ +get: + summary: Get museum hours + description: Get upcoming museum operating hours. + operationId: getMuseumHours + tags: + - Operations + parameters: + - $ref: ../components/parameters/StartDate.yaml + - $ref: ../components/parameters/PaginationPage.yaml + - $ref: ../components/parameters/PaginationLimit.yaml + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: ../components/schemas/GetMuseumHoursResponse.yaml + examples: + default_example: + $ref: ../components/examples/GetMuseumHoursResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml diff --git a/__tests__/smoke/pre-split/museum/paths/special-events.yaml b/__tests__/smoke/pre-split/museum/paths/special-events.yaml new file mode 100644 index 0000000000..0d073656c5 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/paths/special-events.yaml @@ -0,0 +1,54 @@ +post: + summary: Create special events + description: Creates a new special event for the museum. + operationId: createSpecialEvent + tags: + - Events + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas/CreateSpecialEventRequest.yaml + examples: + default_example: + $ref: ../components/examples/CreateSpecialEventRequestExample.yaml + responses: + '201': + description: Created. + content: + application/json: + schema: + $ref: ../components/schemas/SpecialEventResponse.yaml + examples: + default_example: + $ref: ../components/examples/CreateSpecialEventResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml +get: + summary: List special events + description: Return a list of upcoming special events at the museum. + operationId: listSpecialEvents + tags: + - Events + parameters: + - $ref: ../components/parameters/StartDate.yaml + - $ref: ../components/parameters/EndDate.yaml + - $ref: ../components/parameters/PaginationPage.yaml + - $ref: ../components/parameters/PaginationLimit.yaml + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: ../components/schemas/ListSpecialEventsResponse.yaml + examples: + default_example: + $ref: ../components/examples/ListSpecialEventsResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml diff --git a/__tests__/smoke/pre-split/museum/paths/special-events_{eventId}.yaml b/__tests__/smoke/pre-split/museum/paths/special-events_{eventId}.yaml new file mode 100644 index 0000000000..36833ca98d --- /dev/null +++ b/__tests__/smoke/pre-split/museum/paths/special-events_{eventId}.yaml @@ -0,0 +1,72 @@ +get: + summary: Get special event + description: Get details about a special event. + operationId: getSpecialEvent + tags: + - Events + parameters: + - $ref: ../components/parameters/EventId.yaml + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: ../components/schemas/SpecialEventResponse.yaml + examples: + default_example: + $ref: ../components/examples/GetSpecialEventResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml +patch: + summary: Update special event + description: Update the details of a special event. + operationId: updateSpecialEvent + tags: + - Events + parameters: + - $ref: ../components/parameters/EventId.yaml + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas/UpdateSpecialEventRequest.yaml + examples: + default_example: + $ref: ../components/examples/UpdateSpecialEventRequestExample.yaml + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: ../components/schemas/SpecialEventResponse.yaml + examples: + default_example: + $ref: ../components/examples/UpdateSpecialEventResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml +delete: + summary: Delete special event + description: >- + Delete a special event from the collection. Allows museum to cancel planned + events. + operationId: deleteSpecialEvent + tags: + - Events + parameters: + - $ref: ../components/parameters/EventId.yaml + responses: + '204': + description: Success - no content. + '400': + $ref: ../components/responses/BadRequest.yaml + '401': + $ref: ../components/responses/Unauthorized.yaml + '404': + $ref: ../components/responses/NotFound.yaml diff --git a/__tests__/smoke/pre-split/museum/paths/tickets.yaml b/__tests__/smoke/pre-split/museum/paths/tickets.yaml new file mode 100644 index 0000000000..9adc683d71 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/paths/tickets.yaml @@ -0,0 +1,33 @@ +post: + summary: Buy museum tickets + description: Purchase museum tickets for general entry or special events. + operationId: buyMuseumTickets + tags: + - Tickets + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas/BuyMuseumTicketsRequest.yaml + examples: + general_entry: + $ref: ../components/examples/BuyGeneralTicketsRequestExample.yaml + event_entry: + $ref: ../components/examples/BuyEventTicketsRequestExample.yaml + responses: + '201': + description: Created. + content: + application/json: + schema: + $ref: ../components/schemas/BuyMuseumTicketsResponse.yaml + examples: + general_entry: + $ref: ../components/examples/BuyGeneralTicketsResponseExample.yaml + event_entry: + $ref: ../components/examples/BuyEventTicketsResponseExample.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml diff --git a/__tests__/smoke/pre-split/museum/paths/tickets_{ticketId}_qr.yaml b/__tests__/smoke/pre-split/museum/paths/tickets_{ticketId}_qr.yaml new file mode 100644 index 0000000000..1afd5d5b65 --- /dev/null +++ b/__tests__/smoke/pre-split/museum/paths/tickets_{ticketId}_qr.yaml @@ -0,0 +1,19 @@ +get: + summary: Get ticket QR code + description: Return an image of your ticket with scannable QR code. Used for event entry. + operationId: getTicketCode + tags: + - Tickets + parameters: + - $ref: ../components/parameters/TicketId.yaml + responses: + '200': + description: Scannable event ticket in image format. + content: + image/png: + schema: + $ref: ../components/schemas/GetTicketCodeResponse.yaml + '400': + $ref: ../components/responses/BadRequest.yaml + '404': + $ref: ../components/responses/NotFound.yaml diff --git a/__tests__/smoke/pre-split/petstore/code_samples/C_sharp/petGet/post.cs b/__tests__/smoke/pre-split/petstore/code_samples/C_sharp/petGet/post.cs new file mode 100644 index 0000000000..fde7dac75b --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/code_samples/C_sharp/petGet/post.cs @@ -0,0 +1,15 @@ +PetStore.v1.Pet pet = new PetStore.v1.Pet(); +pet.setApiKey("your api key"); +pet.petType = PetStore.v1.Pet.TYPE_DOG; +pet.name = "Rex"; +// set other fields +PetStoreResponse response = pet.create(); +if (response.statusCode == HttpStatusCode.Created) +{ + // Successfully created +} +else +{ + // Something wrong -- check response for errors + Console.WriteLine(response.getRawResponse()); +} diff --git a/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/post.php b/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/post.php new file mode 100644 index 0000000000..6be9bc1999 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/post.php @@ -0,0 +1,9 @@ +$form = new \PetStore\Entities\Pet(); +$form->setPetType("Dog"); +$form->setName("Rex"); +// set other fields +try { + $pet = $client->pets()->create($form); +} catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); +} diff --git a/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/put.php b/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/put.php new file mode 100644 index 0000000000..c3b48655d4 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/code_samples/PHP/petGet/put.php @@ -0,0 +1,10 @@ +$form = new \PetStore\Entities\Pet(); +$form->setPetId(1); +$form->setPetType("Dog"); +$form->setName("Rex"); +// set other fields +try { + $pet = $client->pets()->update($form); +} catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); +} diff --git a/__tests__/smoke/pre-split/petstore/components/examples/Order.yaml b/__tests__/smoke/pre-split/petstore/components/examples/Order.yaml new file mode 100644 index 0000000000..4867de3397 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/examples/Order.yaml @@ -0,0 +1,5 @@ +value: + quantity: 1 + shipDate: '2018-10-19T16:46:45Z' + status: placed + complete: false diff --git a/__tests__/smoke/pre-split/petstore/components/requestBodies/Pet.yaml b/__tests__/smoke/pre-split/petstore/components/requestBodies/Pet.yaml new file mode 100644 index 0000000000..97b023c69f --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/requestBodies/Pet.yaml @@ -0,0 +1,16 @@ +content: + application/json: + schema: + allOf: + - description: My Pet + title: Pettie + - $ref: ../schemas/Pet.yaml + application/xml: + schema: + type: object + properties: + name: + type: string + description: hooray +description: Pet object that needs to be added to the store +required: true diff --git a/__tests__/smoke/pre-split/petstore/components/requestBodies/UserArray.yaml b/__tests__/smoke/pre-split/petstore/components/requestBodies/UserArray.yaml new file mode 100644 index 0000000000..fc2e14ffe9 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/requestBodies/UserArray.yaml @@ -0,0 +1,8 @@ +content: + application/json: + schema: + type: array + items: + $ref: ../schemas/User.yaml +description: List of user object +required: true diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/ApiResponse.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/ApiResponse.yaml new file mode 100644 index 0000000000..ecfc66d6e2 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/ApiResponse.yaml @@ -0,0 +1,9 @@ +type: object +properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Cat.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Cat.yaml new file mode 100644 index 0000000000..a8c1236f48 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Cat.yaml @@ -0,0 +1,17 @@ +description: A representation of a cat +allOf: + - $ref: ./Pet.yaml + - type: object + properties: + huntingSkill: + type: string + description: The measured skill for hunting + default: lazy + example: adventurous + enum: + - clueless + - lazy + - adventurous + - aggressive + required: + - huntingSkill diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Category.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Category.yaml new file mode 100644 index 0000000000..f01a901ae3 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Category.yaml @@ -0,0 +1,19 @@ +type: object +properties: + id: + description: Category ID + allOf: + - $ref: ./Id.yaml + name: + description: Category name + type: string + minLength: 1 + sub: + description: Test Sub Category + type: object + properties: + prop1: + type: string + description: Dumb Property +xml: + name: Category diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Dog.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Dog.yaml new file mode 100644 index 0000000000..8a30252a36 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Dog.yaml @@ -0,0 +1,13 @@ +description: A representation of a dog +allOf: + - $ref: ./Pet.yaml + - type: object + properties: + packSize: + type: integer + format: int32 + description: The size of the pack the dog is from + default: 1 + minimum: 1 + required: + - packSize diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/HoneyBee.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/HoneyBee.yaml new file mode 100644 index 0000000000..b51a17c95a --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/HoneyBee.yaml @@ -0,0 +1,12 @@ +description: A representation of a honey bee +allOf: + - $ref: ./Pet.yaml + - type: object + properties: + honeyPerDay: + type: number + description: Average amount of honey produced per day in ounces + example: 3.14 + multipleOf: 0.01 + required: + - honeyPerDay diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Id.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Id.yaml new file mode 100644 index 0000000000..05df69cd35 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Id.yaml @@ -0,0 +1,3 @@ +type: integer +format: int64 +readOnly: true diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Order.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Order.yaml new file mode 100644 index 0000000000..08d79e3e12 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Order.yaml @@ -0,0 +1,37 @@ +type: object +properties: + id: + description: Order ID + allOf: + - $ref: ./Id.yaml + petId: + description: Pet ID + allOf: + - $ref: ./Id.yaml + quantity: + type: integer + format: int32 + minimum: 1 + default: 1 + shipDate: + description: Estimated ship date + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + description: Indicates whenever order was completed or not + type: boolean + default: false + readOnly: true + requestId: + description: Unique Request Id + type: string + writeOnly: true +xml: + name: Order diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Pet.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Pet.yaml new file mode 100644 index 0000000000..db3c9ccd77 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Pet.yaml @@ -0,0 +1,63 @@ +type: object +required: + - name + - photoUrls +discriminator: + propertyName: petType + mapping: + cat: ./Cat.yaml + dog: ./Dog.yaml + bee: ./HoneyBee.yaml + Cat: ./Cat.yaml + Dog: ./Dog.yaml + HoneyBee: ./HoneyBee.yaml +properties: + id: + externalDocs: + description: Find more info here + url: https://example.com + description: Pet ID + allOf: + - $ref: ./Id.yaml + category: + description: Categories this pet belongs to + allOf: + - $ref: ./Category.yaml + name: + description: The name given to a pet + type: string + example: Guru + photoUrls: + description: The list of URL to a cute photos featuring pet + type: array + maxItems: 20 + xml: + name: photoUrl + wrapped: true + items: + type: string + format: url + friend: + allOf: + - $ref: ./Pet.yaml + tags: + description: Tags attached to the pet + type: array + minItems: 1 + xml: + name: tag + wrapped: true + items: + $ref: ./Tag.yaml + status: + type: string + description: Pet status in the store + enum: + - available + - pending + - sold + petType: + description: Type of a pet + type: string +xml: + name: Pet diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/Tag.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/Tag.yaml new file mode 100644 index 0000000000..718e950a83 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/Tag.yaml @@ -0,0 +1,12 @@ +type: object +properties: + id: + description: Tag ID + allOf: + - $ref: ./Id.yaml + name: + description: Tag name + type: string + minLength: 1 +xml: + name: Tag diff --git a/__tests__/smoke/pre-split/petstore/components/schemas/User.yaml b/__tests__/smoke/pre-split/petstore/components/schemas/User.yaml new file mode 100644 index 0000000000..25f66fc696 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/components/schemas/User.yaml @@ -0,0 +1,48 @@ +type: object +properties: + id: + $ref: ./Id.yaml + pet: + oneOf: + - $ref: ./Pet.yaml + - $ref: ./Tag.yaml + username: + description: User supplied username + type: string + minLength: 4 + example: John78 + firstName: + description: User first name + type: string + minLength: 1 + example: John + lastName: + description: User last name + type: string + minLength: 1 + example: Smith + email: + description: User email address + type: string + format: email + example: john.smith@example.com + password: + type: string + description: >- + User password, MUST contain a mix of upper and lower case letters, as well + as digits + format: password + minLength: 8 + pattern: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ + example: drowssaP123 + phone: + description: User phone number in international format + type: string + pattern: /^\+(?:[0-9]-?){6,14}[0-9]$/ + example: +1-202-555-0192 + userStatus: + description: User status + type: integer + format: int32 +xml: + name: User diff --git a/__tests__/smoke/pre-split/petstore/openapi.yaml b/__tests__/smoke/pre-split/petstore/openapi.yaml new file mode 100644 index 0000000000..3c300100a6 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/openapi.yaml @@ -0,0 +1,175 @@ +openapi: 3.0.0 +servers: + - url: //petstore.swagger.io/v2 + description: Default server + - url: //petstore.swagger.io/sandbox + description: Sandbox server +info: + description: > + This is a sample server Petstore server. + + You can find out more about Swagger at + + [http://swagger.io](http://swagger.io) or on [irc.freenode.net, + #swagger](http://swagger.io/irc/). + + For this sample, you can use the api key `special-key` to test the + authorization filters. + + + # Introduction + + This API is documented in **OpenAPI format** and is based on + + [Petstore sample](http://petstore.swagger.io/) provided by + [swagger.io](http://swagger.io) team. + + It was **extended** to illustrate features of + [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) + + tool and [ReDoc](https://github.com/Redocly/redoc) documentation. In + addition to standard + + OpenAPI syntax we use a few [vendor + extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md). + + + # OpenAPI Specification + + This API is documented in **OpenAPI format** and is based on + + [Petstore sample](http://petstore.swagger.io/) provided by + [swagger.io](http://swagger.io) team. + + It was **extended** to illustrate features of + [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) + + tool and [ReDoc](https://github.com/Redocly/redoc) documentation. In + addition to standard + + OpenAPI syntax we use a few [vendor + extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md). + + + # Cross-Origin Resource Sharing + + This API features Cross-Origin Resource Sharing (CORS) implemented in + compliance with [W3C spec](https://www.w3.org/TR/cors/). + + And that allows cross-domain communication from the browser. + + All responses have a wildcard same-origin which makes them completely public + and accessible to everyone, including any code on any site. + + + # Authentication + + + Petstore offers two forms of authentication: + - API Key + - OAuth2 + OAuth2 - an open protocol to allow secure authorization in a simple + + and standard method from web, mobile and desktop applications. + + + + version: 1.0.0 + title: Swagger Petstore + termsOfService: http://swagger.io/terms/ + contact: + name: API Support + email: apiteam@swagger.io + url: https://github.com/Redocly/redoc + x-logo: + url: https://redocly.github.io/redoc/petstore-logo.png + altText: Petstore logo + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html +externalDocs: + description: Find out how to create Github repo for your OpenAPI spec. + url: https://github.com/Rebilly/generator-openapi-repo +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user + - name: pet_model + x-displayName: The Pet Model + description: | + + - name: store_model + x-displayName: The Order Model + description: > + +x-tagGroups: + - name: General + tags: + - pet + - store + - name: User Management + tags: + - user + - name: Models + tags: + - pet_model + - store_model +paths: + /petGet: + $ref: paths/petGet.yaml + /GETpet/{petId}: + $ref: paths/GETpet_{petId}.yaml + /pet/{petId}/uploadImage: + $ref: paths/pet_{petId}_uploadImage.yaml + /pet/findByStatusPut: + $ref: paths/pet_findByStatusPut.yaml + /GETCustomers/findByTags: + $ref: paths/GETCustomers_findByTags.yaml + /store/inventory: + $ref: paths/store_inventory.yaml + /store/order: + $ref: paths/store_order.yaml + /store/order/{orderId}: + $ref: paths/store_order_{orderId}.yaml + /store/subscribe: + $ref: paths/store_subscribe.yaml + /user: + $ref: paths/user.yaml + /user/{username}: + $ref: paths/user_{username}.yaml + /user/createWithArray: + $ref: paths/user_createWithArray.yaml + /user/createWithList: + $ref: paths/user_createWithList.yaml + /user/login: + $ref: paths/user_login.yaml + /user/logout: + $ref: paths/user_logout.yaml +components: + securitySchemes: + petstore_auth: + description: | + Get access to data while protecting your account credentials. + OAuth2 is also a safer and more secure way to give you access. + type: oauth2 + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + api_key: + description: > + For this sample, you can use the api key `special-key` to test the + authorization filters. + type: apiKey + name: api_key + in: header +x-webhooks: + newPet: + $ref: webhooks/newPet.yaml diff --git a/__tests__/smoke/pre-split/petstore/paths/GETCustomers_findByTags.yaml b/__tests__/smoke/pre-split/petstore/paths/GETCustomers_findByTags.yaml new file mode 100644 index 0000000000..5e3414ea50 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/GETCustomers_findByTags.yaml @@ -0,0 +1,39 @@ +get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, tag2, + tag3 for testing. + operationId: findPetsByTags + deprecated: true + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: array + items: + $ref: ../components/schemas/Pet.yaml + application/xml: + schema: + type: array + items: + $ref: ../components/schemas/Pet.yaml + '400': + description: Invalid tag value + security: + - petstore_auth: + - write:pets + - read:pets diff --git a/__tests__/smoke/pre-split/petstore/paths/GETpet_{petId}.yaml b/__tests__/smoke/pre-split/petstore/paths/GETpet_{petId}.yaml new file mode 100644 index 0000000000..3c6226d703 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/GETpet_{petId}.yaml @@ -0,0 +1,91 @@ +get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + deprecated: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: ../components/schemas/Pet.yaml + application/xml: + schema: + $ref: ../components/schemas/Pet.yaml + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] +post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string +delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + example: Bearer + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets diff --git a/__tests__/smoke/pre-split/petstore/paths/petGet.yaml b/__tests__/smoke/pre-split/petstore/paths/petGet.yaml new file mode 100644 index 0000000000..143791d342 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/petGet.yaml @@ -0,0 +1,63 @@ +parameters: + - name: Accept-Language + in: header + description: >- + The language you prefer for messages. Supported values are en-AU, en-CA, + en-GB, en-US + example: en-US + required: false + schema: + type: string + default: en-AU + - name: cookieParam + in: cookie + description: Some cookie + required: true + schema: + type: integer + format: int64 +post: + tags: + - pet + summary: Add a new pet to the store + description: Add new pet to the store inventory. + operationId: addPet + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + x-codeSamples: + - lang: C# + source: + $ref: ../code_samples/C_sharp/petGet/post.cs + - lang: PHP + source: + $ref: ../code_samples/PHP/petGet/post.php + requestBody: + $ref: ../components/requestBodies/Pet.yaml +put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + x-codeSamples: + - lang: PHP + source: + $ref: ../code_samples/PHP/petGet/put.php + requestBody: + $ref: ../components/requestBodies/Pet.yaml diff --git a/__tests__/smoke/pre-split/petstore/paths/pet_findByStatusPut.yaml b/__tests__/smoke/pre-split/petstore/paths/pet_findByStatusPut.yaml new file mode 100644 index 0000000000..11fda4ee20 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/pet_findByStatusPut.yaml @@ -0,0 +1,43 @@ +get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + schema: + type: array + minItems: 1 + maxItems: 3 + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: array + items: + $ref: ../components/schemas/Pet.yaml + application/xml: + schema: + type: array + items: + $ref: ../components/schemas/Pet.yaml + '400': + description: Invalid status value + security: + - petstore_auth: + - write:pets + - read:pets diff --git a/__tests__/smoke/pre-split/petstore/paths/pet_{petId}_uploadImage.yaml b/__tests__/smoke/pre-split/petstore/paths/pet_{petId}_uploadImage.yaml new file mode 100644 index 0000000000..ca64c5fc53 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/pet_{petId}_uploadImage.yaml @@ -0,0 +1,31 @@ +post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: ../components/schemas/ApiResponse.yaml + security: + - petstore_auth: + - write:pets + - read:pets + requestBody: + content: + application/octet-stream: + schema: + type: string + format: binary diff --git a/__tests__/smoke/pre-split/petstore/paths/store_inventory.yaml b/__tests__/smoke/pre-split/petstore/paths/store_inventory.yaml new file mode 100644 index 0000000000..0779d8e342 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/store_inventory.yaml @@ -0,0 +1,18 @@ +get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] diff --git a/__tests__/smoke/pre-split/petstore/paths/store_order.yaml b/__tests__/smoke/pre-split/petstore/paths/store_order.yaml new file mode 100644 index 0000000000..d8a1adc2ee --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/store_order.yaml @@ -0,0 +1,30 @@ +post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: ../components/schemas/Order.yaml + application/xml: + schema: + $ref: ../components/schemas/Order.yaml + '400': + description: Invalid Order + content: + application/json: + example: + status: 400 + message: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: ../components/schemas/Order.yaml + description: order placed for purchasing the pet + required: true diff --git a/__tests__/smoke/pre-split/petstore/paths/store_order_{orderId}.yaml b/__tests__/smoke/pre-split/petstore/paths/store_order_{orderId}.yaml new file mode 100644 index 0000000000..c61c083280 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/store_order_{orderId}.yaml @@ -0,0 +1,53 @@ +get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: ../components/schemas/Order.yaml + application/xml: + schema: + $ref: ../components/schemas/Order.yaml + '400': + description: Invalid ID supplied + '404': + description: Order not found +delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above 1000 or + nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + minimum: 1 + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found diff --git a/__tests__/smoke/pre-split/petstore/paths/store_subscribe.yaml b/__tests__/smoke/pre-split/petstore/paths/store_subscribe.yaml new file mode 100644 index 0000000000..e5a66f1666 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/store_subscribe.yaml @@ -0,0 +1,244 @@ +post: + tags: + - store + summary: Subscribe to the Store events + description: Add subscription for a store events + requestBody: + content: + application/json: + schema: + type: object + properties: + callbackUrl: + type: string + format: uri + description: >- + This URL will be called by the server when the desired event + will occur + example: https://myserver.com/send/callback/here + eventName: + type: string + description: Event name for the subscription + enum: + - orderInProgress + - orderShipped + - orderDelivered + example: orderInProgress + required: + - callbackUrl + - eventName + responses: + '201': + description: Subscription added + content: + application/json: + schema: + type: object + properties: + subscriptionId: + type: string + example: AAA-123-BBB-456 + callbacks: + orderInProgress: + '{$request.body#/callbackUrl}?event={$request.body#/eventName}': + servers: + - url: //callback-url.path-level/v1 + description: Path level server 1 + - url: //callback-url.path-level/v2 + description: Path level server 2 + post: + summary: Order in Progress (Summary) + description: >- + A callback triggered every time an Order is updated status to + "inProgress" (Description) + externalDocs: + description: Find out more + url: https://more-details.com/demo + requestBody: + content: + application/json: + schema: + type: object + properties: + orderId: + type: string + example: '123' + timestamp: + type: string + format: date-time + example: '2018-10-19T16:46:45Z' + status: + type: string + example: inProgress + application/xml: + schema: + type: object + properties: + orderId: + type: string + example: '123' + example: | + + + 123 + inProgress + 2018-10-19T16:46:45Z + + responses: + '200': + description: Callback successfully processed and no retries will be performed + content: + application/json: + schema: + type: object + properties: + someProp: + type: string + example: '123' + '299': + description: Response for cancelling subscription + '500': + description: Callback processing failed and retries will be performed + x-codeSamples: + - lang: C# + source: | + PetStore.v1.Pet pet = new PetStore.v1.Pet(); + pet.setApiKey("your api key"); + pet.petType = PetStore.v1.Pet.TYPE_DOG; + pet.name = "Rex"; + // set other fields + PetStoreResponse response = pet.create(); + if (response.statusCode == HttpStatusCode.Created) + { + // Successfully created + } + else + { + // Something wrong -- check response for errors + Console.WriteLine(response.getRawResponse()); + } + - lang: PHP + source: | + $form = new \PetStore\Entities\Pet(); + $form->setPetType("Dog"); + $form->setName("Rex"); + // set other fields + try { + $pet = $client->pets()->create($form); + } catch (UnprocessableEntityException $e) { + var_dump($e->getErrors()); + } + put: + description: Order in Progress (Only Description) + servers: + - url: //callback-url.operation-level/v1 + description: Operation level server 1 (Operation override) + - url: //callback-url.operation-level/v2 + description: Operation level server 2 (Operation override) + requestBody: + content: + application/json: + schema: + type: object + properties: + orderId: + type: string + example: '123' + timestamp: + type: string + format: date-time + example: '2018-10-19T16:46:45Z' + status: + type: string + example: inProgress + application/xml: + schema: + type: object + properties: + orderId: + type: string + example: '123' + example: | + + + 123 + inProgress + 2018-10-19T16:46:45Z + + responses: + '200': + description: Callback successfully processed and no retries will be performed + content: + application/json: + schema: + type: object + properties: + someProp: + type: string + example: '123' + orderShipped: + '{$request.body#/callbackUrl}?event={$request.body#/eventName}': + post: + description: > + Very long description + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor + + incididunt ut labore et dolore magna aliqua. Ut enim ad minim + veniam, quis + + nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. + + Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu + + fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in + + culpa qui officia deserunt mollit anim id est laborum. + requestBody: + content: + application/json: + schema: + type: object + properties: + orderId: + type: string + example: '123' + timestamp: + type: string + format: date-time + example: '2018-10-19T16:46:45Z' + estimatedDeliveryDate: + type: string + format: date-time + example: '2018-11-11T16:00:00Z' + responses: + '200': + description: Callback successfully processed and no retries will be performed + orderDelivered: + http://notificationServer.com?url={$request.body#/callbackUrl}&event={$request.body#/eventName}: + post: + deprecated: true + summary: Order delivered + description: >- + A callback triggered every time an Order is delivered to the + recipient + requestBody: + content: + application/json: + schema: + type: object + properties: + orderId: + type: string + example: '123' + timestamp: + type: string + format: date-time + example: '2018-10-19T16:46:45Z' + responses: + '200': + description: Callback successfully processed and no retries will be performed diff --git a/__tests__/smoke/pre-split/petstore/paths/user.yaml b/__tests__/smoke/pre-split/petstore/paths/user.yaml new file mode 100644 index 0000000000..a6cf9e1c7f --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user.yaml @@ -0,0 +1,16 @@ +post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: ../components/schemas/User.yaml + description: Created user object + required: true diff --git a/__tests__/smoke/pre-split/petstore/paths/user_createWithArray.yaml b/__tests__/smoke/pre-split/petstore/paths/user_createWithArray.yaml new file mode 100644 index 0000000000..b4d2715d8b --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user_createWithArray.yaml @@ -0,0 +1,11 @@ +post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: ../components/requestBodies/UserArray.yaml diff --git a/__tests__/smoke/pre-split/petstore/paths/user_createWithList.yaml b/__tests__/smoke/pre-split/petstore/paths/user_createWithList.yaml new file mode 100644 index 0000000000..42be7b0938 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user_createWithList.yaml @@ -0,0 +1,11 @@ +post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: ../components/requestBodies/UserArray.yaml diff --git a/__tests__/smoke/pre-split/petstore/paths/user_login.yaml b/__tests__/smoke/pre-split/petstore/paths/user_login.yaml new file mode 100644 index 0000000000..409ae7e65c --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user_login.yaml @@ -0,0 +1,52 @@ +get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/json: + schema: + type: string + examples: + response: + value: OK + application/xml: + schema: + type: string + examples: + response: + value: OK + text/plain: + examples: + response: + value: OK + '400': + description: Invalid username/password supplied diff --git a/__tests__/smoke/pre-split/petstore/paths/user_logout.yaml b/__tests__/smoke/pre-split/petstore/paths/user_logout.yaml new file mode 100644 index 0000000000..720bbe7188 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user_logout.yaml @@ -0,0 +1,9 @@ +get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation diff --git a/__tests__/smoke/pre-split/petstore/paths/user_{username}.yaml b/__tests__/smoke/pre-split/petstore/paths/user_{username}.yaml new file mode 100644 index 0000000000..9bed5ace5a --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/paths/user_{username}.yaml @@ -0,0 +1,70 @@ +get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing. ' + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: ../components/schemas/User.yaml + application/xml: + schema: + $ref: ../components/schemas/User.yaml + '400': + description: Invalid username supplied + '404': + description: User not found +put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: ../components/schemas/User.yaml + description: Updated user object + required: true +delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found diff --git a/__tests__/smoke/pre-split/petstore/webhooks/newPet.yaml b/__tests__/smoke/pre-split/petstore/webhooks/newPet.yaml new file mode 100644 index 0000000000..90e7966aa1 --- /dev/null +++ b/__tests__/smoke/pre-split/petstore/webhooks/newPet.yaml @@ -0,0 +1,14 @@ +post: + summary: New pet + description: Information about a new pet in the systems + operationId: newPet + tags: + - pet + requestBody: + content: + application/json: + schema: + $ref: ../components/schemas/Pet.yaml + responses: + '200': + description: Return a 200 status to indicate that the data was received successfully diff --git a/scripts/prepare-smoke.sh b/__tests__/smoke/prepare-smoke.sh similarity index 69% rename from scripts/prepare-smoke.sh rename to __tests__/smoke/prepare-smoke.sh index df79c31d89..657bb2ab6d 100644 --- a/scripts/prepare-smoke.sh +++ b/__tests__/smoke/prepare-smoke.sh @@ -6,7 +6,7 @@ npm run webpack-bundle # For npm (Mutates packages/cli/package.json) npm run pack:prepare -cp ./redocly-cli.tgz ./openapi-core.tgz ./dist/bundle.js ./__tests__/smoke/ +cp ./redocly-cli.tgz ./openapi-core.tgz ./dist/bundle.js resources/pets.yaml resources/museum.yaml ./__tests__/smoke/ echo "Current directory:" pwd diff --git a/__tests__/smoke/run-smoke.sh b/__tests__/smoke/run-smoke.sh index c1fef7c87c..d11e18013c 100644 --- a/__tests__/smoke/run-smoke.sh +++ b/__tests__/smoke/run-smoke.sh @@ -16,10 +16,14 @@ $2 redocly-version $2 redocly-lint $2 redocly-bundle $2 redocly-build-docs -# Check for broken styles (related issue: https://github.com/Redocly/redocly-cli/issues/1073) -if [[ "$(wc -l redoc-static.html)" == "324 redoc-static.html" ]]; then - echo "Docs built correctly." -else - echo "Docs built incorrectly. Received lines: $(wc -l redoc-static.html) (expected 324 lines in redoc-static.html)." - exit 1 -fi +$2 redocly-split + +# Check for broken styles when building docs (related issue: https://github.com/Redocly/redocly-cli/issues/1073) +echo "Checking docs for issues..." +diff pre-built/redoc.html redoc-static.html +echo "✅ Docs built correctly." + +# Check for broken $refs (or other issues) in the split files, especially on Windows (it will fail on a difference) +echo "Checking split files for issues..." +diff -r pre-split output/split +echo "✅ Files split correctly." diff --git a/packages/cli/src/commands/split/index.ts b/packages/cli/src/commands/split/index.ts index 2cde3c2195..8faa63c7f8 100644 --- a/packages/cli/src/commands/split/index.ts +++ b/packages/cli/src/commands/split/index.ts @@ -46,16 +46,16 @@ export type SplitOptions = { export async function handleSplit({ argv, collectSpecData }: CommandArgs) { const startedAt = performance.now(); const { api, outDir, separator } = argv; - validateDefinitionFileName(api!); + validateDefinitionFileName(api); const ext = getAndValidateFileExtension(api); - const openapi = readYaml(api!) as Oas3Definition | Oas3_1Definition; + const openapi = readYaml(api) as Oas3Definition | Oas3_1Definition; collectSpecData?.(openapi); splitDefinition(openapi, outDir, separator, ext); process.stderr.write( - `🪓 Document: ${blue(api!)} ${green('is successfully split')} + `🪓 Document: ${blue(api)} ${green('is successfully split')} and all related files are saved to the directory: ${blue(outDir)} \n` ); - printExecutionTime('split', startedAt, api!); + printExecutionTime('split', startedAt, api); } function splitDefinition( @@ -176,9 +176,9 @@ function replace$Refs(obj: unknown, relativeFrom: string, componentFiles = {} as const groupName = splittedNode[2]; const filesGroupName = componentFiles[groupName]; if (!filesGroupName || !filesGroupName[name!]) return; - let filename = path.relative(relativeFrom, filesGroupName[name!].filename); + let filename = slash(path.relative(relativeFrom, filesGroupName[name!].filename)); if (!filename.startsWith('.')) { - filename = '.' + path.sep + filename; + filename = './' + filename; } node[key] = filename; } @@ -192,11 +192,11 @@ function implicitlyReferenceDiscriminator( ) { if (!obj.discriminator) return; const defPtr = `#/${COMPONENTS}/${OPENAPI3_COMPONENT.Schemas}/${defName}`; - const implicitMapping = {} as any; + const implicitMapping: Record = {}; for (const [name, { inherits, filename: parentFilename }] of Object.entries(schemaFiles) as any) { if (inherits.indexOf(defPtr) > -1) { - const res = path.relative(path.dirname(filename), parentFilename); - implicitMapping[name] = res.startsWith('.') ? res : '.' + path.sep + res; + const res = slash(path.relative(path.dirname(filename), parentFilename)); + implicitMapping[name] = res.startsWith('.') ? res : './' + res; } }