Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Uncouple from HTTP and use data models #32

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 50 additions & 81 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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
version: 1.2.0
termsOfService: 'https://redocly.com/subscription-agreement/'
contact:
email: [email protected]
Expand Down Expand Up @@ -30,7 +30,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/GetMuseumHoursResponse"
$ref: "#/components/schemas/MuseumHours"
examples:
default_example:
$ref: "#/components/examples/GetMuseumHoursResponseExample"
Expand All @@ -50,7 +50,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateSpecialEventRequest"
$ref: "#/components/schemas/SpecialEvent"
examples:
default_example:
$ref: "#/components/examples/CreateSpecialEventRequestExample"
Expand All @@ -60,7 +60,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SpecialEventResponse"
$ref: "#/components/schemas/SpecialEvent"
examples:
default_example:
$ref: "#/components/examples/CreateSpecialEventResponseExample"
Expand All @@ -85,7 +85,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/ListSpecialEventsResponse"
$ref: "#/components/schemas/SpecialEventCollection"
examples:
default_example:
$ref: "#/components/examples/ListSpecialEventsResponseExample"
Expand All @@ -108,7 +108,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SpecialEventResponse"
$ref: "#/components/schemas/SpecialEvent"
examples:
default_example:
$ref: "#/components/examples/GetSpecialEventResponseExample"
Expand All @@ -129,7 +129,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateSpecialEventRequest"
$ref: "#/components/schemas/SpecialEventFields"
examples:
default_example:
$ref: "#/components/examples/UpdateSpecialEventRequestExample"
Expand All @@ -139,7 +139,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/SpecialEventResponse"
$ref: "#/components/schemas/SpecialEvent"
examples:
default_example:
$ref: "#/components/examples/UpdateSpecialEventResponseExample"
Expand Down Expand Up @@ -176,7 +176,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/BuyMuseumTicketsRequest"
$ref: "#/components/schemas/BuyMuseumTickets"
examples:
general_entry:
$ref: "#/components/examples/BuyGeneralTicketsRequestExample"
Expand All @@ -188,7 +188,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/BuyMuseumTicketsResponse"
$ref: "#/components/schemas/MuseumTicketsConfirmation"
examples:
general_entry:
$ref: "#/components/examples/BuyGeneralTicketsResponseExample"
Expand All @@ -213,7 +213,7 @@ paths:
content:
image/png:
schema:
$ref: "#/components/schemas/GetTicketCodeResponse"
$ref: "#/components/schemas/TicketCodeImage"
"400":
$ref: '#/components/responses/BadRequest'
"404":
Expand All @@ -236,30 +236,15 @@ components:
type: string
format: email
example: [email protected]
Phone:
description: Phone number for the ticket purchaser (optional).
type: string
example: '+1(234)-567-8910'
BuyMuseumTicketsRequest:
description: Request payload used for purchasing museum tickets.
BuyMuseumTickets:
lornajane marked this conversation as resolved.
Show resolved Hide resolved
description: Data to purchase a ticket.
type: object
properties:
ticketType:
$ref: "#/components/schemas/TicketType"
eventId:
description: Unique identifier for a special event. Required if purchasing tickets for the museum's special events.
$ref: "#/components/schemas/EventId"
ticketDate:
description: Date that the ticket is valid for.
$ref: "#/components/schemas/Date"
email:
$ref: "#/components/schemas/Email"
phone:
$ref: "#/components/schemas/Phone"
required:
- ticketType
- ticketDate
- email
allOf:
- type: object
properties:
email:
$ref: "#/components/schemas/Email"
- $ref: "#/components/schemas/Ticket"
TicketMessage:
description: Confirmation message after a ticket purchase.
type: string
Expand All @@ -273,35 +258,42 @@ components:
description: Unique confirmation code used to verify ticket purchase.
type: string
example: 'ticket-event-a98c8f-7eb12'
BuyMuseumTicketsResponse:
description: Details for a museum ticket after a successful purchase.
Ticket:
description: Ticket for museum entry, can be general admission or special event.
type: object
properties:
message:
$ref: "#/components/schemas/TicketMessage"
eventName:
$ref: "#/components/schemas/EventName"
ticketId:
$ref: "#/components/schemas/TicketId"
ticketType:
$ref: "#/components/schemas/TicketType"
ticketDate:
description: Date the ticket is valid for.
$ref: "#/components/schemas/Date"
confirmationCode:
$ref: "#/components/schemas/TicketConfirmation"
ticketType:
$ref: "#/components/schemas/TicketType"
eventId:
description: Unique identifier for a special event. Required if purchasing tickets for the museum's special events.
lornajane marked this conversation as resolved.
Show resolved Hide resolved
$ref: "#/components/schemas/EventId"
required:
- message
- ticketId
- ticketType
- ticketDate
- confirmationCode
GetTicketCodeResponse:
MuseumTicketsConfirmation:
lornajane marked this conversation as resolved.
Show resolved Hide resolved
description: Details for a museum ticket after a successful purchase.
allOf:
- $ref: "#/components/schemas/Ticket"
- type: object
properties:
message:
$ref: "#/components/schemas/TicketMessage"
confirmationCode:
$ref: "#/components/schemas/TicketConfirmation"
required:
- message
- confirmationCode
TicketCodeImage:
description: Image of a ticket with a QR code used for museum or event entry.
type: string
format: binary
GetMuseumHoursResponse:
description: List of museum operating hours for consecutive days.
MuseumHours:
description: List of museum operating hours for a date range.
type: array
items:
$ref: "#/components/schemas/MuseumDailyHours"
Expand Down Expand Up @@ -354,28 +346,7 @@ components:
type: number
format: float
example: 25
CreateSpecialEventRequest:
description: Request payload for creating new special events at the museum.
type: object
properties:
name:
$ref: "#/components/schemas/EventName"
location:
$ref: "#/components/schemas/EventLocation"
eventDescription:
$ref: "#/components/schemas/EventDescription"
dates:
$ref: "#/components/schemas/EventDates"
price:
$ref: "#/components/schemas/EventPrice"
required:
- name
- location
- eventDescription
- dates
- price
UpdateSpecialEventRequest:
description: Request payload for updating an existing special event. Only included fields are updated in the event.
SpecialEventFields:
type: object
properties:
name:
Expand All @@ -388,13 +359,7 @@ components:
$ref: "#/components/schemas/EventDates"
price:
$ref: "#/components/schemas/EventPrice"
ListSpecialEventsResponse:
description: List of upcoming special events.
type: array
items:
$ref: "#/components/schemas/SpecialEventResponse"
SpecialEventResponse:
description: Information about a special event.
SpecialEvent:
type: object
properties:
eventId:
Expand All @@ -410,12 +375,16 @@ components:
price:
$ref: "#/components/schemas/EventPrice"
required:
- eventId
- name
- location
- eventDescription
- dates
- price
SpecialEventCollection:
description: List of upcoming special events.
type: array
items:
$ref: "#/components/schemas/SpecialEvent"
Error:
type: object
properties:
Expand All @@ -440,7 +409,7 @@ components:
BuyEventTicketsRequestExample:
summary: Special event ticket
value:
ticketType: general
ticketType: event
eventId: dad4bce8-f5cb-4078-a211-995864315e39
ticketDate: '2023-09-05'
email: [email protected]
Expand Down
4 changes: 3 additions & 1 deletion redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ extends:
rules:
operation-tag-defined: error
no-invalid-schema-examples: error
no-invalid-media-type-examples: error
no-invalid-media-type-examples:
severity: error
allowAdditionalProperties: true
scalar-property-missing-example: error
rule/operation-summary-sentence-case:
subject:
Expand Down