Skip to content

Commit

Permalink
fix: example ids now should be consistent (#37)
Browse files Browse the repository at this point in the history
* fix: example ids now should be consistent

this will help make mocking interactions make more sense

* fix: improve booking payment examples to work with microcks
  • Loading branch information
philsturgeon authored Nov 25, 2024
1 parent 4dedf30 commit be2c394
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 26 deletions.
34 changes: 19 additions & 15 deletions .microcks/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ servers:
- url: 'https://api.example.com'
description: Production
x-internal: false
- url: 'https://mocks.example.com/rest'
- url: 'https://try.microcks.io/rest/Train+Travel+API/1.0.0'
description: Mock Server
x-internal: false
security:
Expand Down Expand Up @@ -190,7 +190,7 @@ paths:
format: uuid
examples:
trips:
value: b2e783e1-c824-4d63-b37a-d8d698862f1d
value: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
- name: destination
in: query
description: The ID of the destination station
Expand All @@ -200,7 +200,7 @@ paths:
format: uuid
examples:
trips:
value: '2024-02-01T09:00:00Z'
value: b2e783e1-c824-4d63-b37a-d8d698862f1d
- name: date
in: query
description: >-
Expand All @@ -210,7 +210,9 @@ paths:
schema:
type: string
format: date-time
example: '2024-02-01T09:00:00Z'
examples:
trips:
value: '2024-02-01T09:00:00Z'
- name: bicycles
in: query
description: Only return trips where bicycles are known to be allowed
Expand Down Expand Up @@ -342,12 +344,12 @@ paths:
value:
data:
- id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: 4d67459c-af07-40bb-bb12-178dbb88e09f
passenger_name: John Doe
has_bicycle: true
has_dog: true
- id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
trip_id: 4d67459c-af07-40bb-bb12-178dbb88e09f
passenger_name: Jane Smith
has_bicycle: false
has_dog: false
Expand Down Expand Up @@ -486,7 +488,7 @@ paths:
summary: John Doe
value:
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: John Doe
has_bicycle: true
has_dog: true
Expand All @@ -497,7 +499,7 @@ paths:
summary: Billy Bikeless
value:
id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: Billy Bikeless
has_bicycle: false
has_dog: true
Expand Down Expand Up @@ -557,10 +559,12 @@ paths:
type: string
format: uuid
examples:
Card:
value: 1725ff48-ab45-4bb5-9d02-88745177dedb
Bank:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: Payment by Card
value: 1725ff48-ab45-4bb5-9d02-88745177dedb
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Payment by Bank Transfer
value: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
post:
summary: Pay for a Booking
description: >-
Expand All @@ -576,7 +580,7 @@ paths:
schema:
$ref: '#/components/schemas/BookingPayment'
examples:
Card:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: Card Payment
value:
amount: 49.99
Expand All @@ -593,7 +597,7 @@ paths:
address_city: London
address_country: gb
address_post_code: N12 9XX
Bank:
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Bank Account Payment
value:
amount: 100.5
Expand Down Expand Up @@ -695,8 +699,8 @@ webhooks:
new_booking:
summary: New Booking
value:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: John Doe
has_bicycle: true
has_dog: true
Expand Down
69 changes: 58 additions & 11 deletions .microcks/overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ actions:
update:
examples:
trips:
value: 'b2e783e1-c824-4d63-b37a-d8d698862f1d'
value: 'efdbb9d1-02c2-4bc3-afb7-6788d8782b1e'

- target: $.paths["/trips"].get.parameters[?(@.name=="destination")].example
remove: true

- target: $.paths["/trips"].get.parameters[?(@.name=="destination")]
update:
examples:
trips:
value: 'b2e783e1-c824-4d63-b37a-d8d698862f1d'

- target: $.paths["/trips"].get.parameters[?(@.name=="date")].example
remove: true

- target: $.paths["/trips"].get.parameters[?(@.name=="date")]
update:
examples:
trips:
Expand Down Expand Up @@ -103,12 +112,12 @@ actions:
value:
data:
- id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: 4d67459c-af07-40bb-bb12-178dbb88e09f
passenger_name: John Doe
has_bicycle: true
has_dog: true
- id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
trip_id: 4d67459c-af07-40bb-bb12-178dbb88e09f
passenger_name: Jane Smith
has_bicycle: false
has_dog: false
Expand Down Expand Up @@ -157,7 +166,7 @@ actions:
summary: John Doe
value:
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: John Doe
has_bicycle: true
has_dog: true
Expand All @@ -167,24 +176,62 @@ actions:
summary: Billy Bikeless
value:
id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: Billy Bikeless
has_bicycle: false
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb


- target: $.paths["/bookings/{bookingId}/payment"].parameters[?(@.name=="bookingId")].example
remove: true

- target: $.paths["/bookings/{bookingId}/payment"].parameters[?(@.name=="bookingId")]
update:
examples:
Card:
value: '1725ff48-ab45-4bb5-9d02-88745177dedb'
Bank:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: Payment by Card
value: '1725ff48-ab45-4bb5-9d02-88745177dedb'
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Payment by Bank Transfer
value: 'bfc5af2c-f477-43c4-8bdf-a00bdb939d65'

- target: $.paths["/bookings/{bookingId}/payment"].post.requestBody.content["application/json"]["examples"]
remove: true

- target: $.paths["/bookings/{bookingId}/payment"].post.requestBody.content["application/json"]
update:
examples:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: Card Payment
value:
amount: 49.99
currency: gbp
source:
object: card
name: J. Doe
number: '4242424242424242'
cvc: 123
exp_month: 12
exp_year: 2025
address_line1: 123 Fake Street
address_line2: 4th Floor
address_city: London
address_country: gb
address_post_code: N12 9XX
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Bank Account Payment
value:
amount: 100.5
currency: gbp
source:
object: bank_account
name: J. Doe
number: '00012345'
sort_code: '000123'
account_type: individual
bank_name: Starling Bank
country: gb

- target: $.webhooks["newBooking"]["post"]["requestBody"].content["application/json"]["example"]
remove: true
Expand All @@ -195,8 +242,8 @@ actions:
new_booking:
summary: New Booking
value:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: ea399ba1-6d95-433f-92d1-83f67b775594
passenger_name: John Doe
has_bicycle: true
has_dog: true
Expand Down

0 comments on commit be2c394

Please sign in to comment.