Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert main openapi.yaml and make a overlay / generated openapi.mock.…
Browse files Browse the repository at this point in the history
…yaml
philsturgeon committed Nov 21, 2024
1 parent 4265225 commit 765262b
Showing 3 changed files with 1,502 additions and 121 deletions.
1,216 changes: 1,216 additions & 0 deletions .microcks/openapi.mock.yaml

Large diffs are not rendered by default.

204 changes: 204 additions & 0 deletions .microcks/overlays.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
overlay: 1.0.0
info:
title: Train Travel API - Microcks
description: |
This API is a mock server for the Train Travel API, which provides a way to
find and book train trips across Europe. It includes endpoints for finding
stations, getting timetables, and managing bookings.
version: 1.0.0

actions:

- target: $["x-topics"]
description: Remove x-topics, not needed for mock server.
remove: true

- target: $.paths["/stations"].get.responses["200"].content["application/json"]["example"]
description: Remove the example from get /stations.
remove: true

- target: $.paths["/stations"].get.responses["200"].content["application/json"]
description: Add Microcks examples for get /stations.
update:
examples:
stations:
summary: A list of train stations
value:
data:
- id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
name: Berlin Hauptbahnhof
address: Invalidenstraße 10557 Berlin, Germany
country_code: DE
timezone: Europe/Berlin
- id: b2e783e1-c824-4d63-b37a-d8d698862f1d
name: Paris Gare du Nord
address: 18 Rue de Dunkerque 75010 Paris, France
country_code: FR
timezone: Europe/Paris
links:
self: https://api.example.com/stations&page=2
next: https://api.example.com/stations?page=3
prev: https://api.example.com/stations?page=1

- target: $.paths["/trips"].get.parameters[?(@.name=="origin")].example
description: Remove the example from get /trips - origin parameter.
remove: true

- target: $.paths["/trips"].get.parameters[?(@.name=="origin")]
description: Add Microcks examples for get /trips - origin parameter
update:
examples:
trips:
value: b2e783e1-c824-4d63-b37a-d8d698862f1d

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

- target: $.paths["/trips"].get.parameters[?(@.name=="destination")]
update:
examples:
trips:
value: '2024-02-01T09:00:00Z'

- target: $.paths["/trips"].get.responses["200"].content["application/json"]["example"]
remove: true

- target: $.paths["/trips"].get.responses["200"].content["application/json"]
update:
examples:
trips:
summary: A list of available train trips
value:
data:
- id: ea399ba1-6d95-433f-92d1-83f67b775594
origin: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
destination: b2e783e1-c824-4d63-b37a-d8d698862f1d
departure_time: '2024-02-01T10:00:00Z'
arrival_time: '2024-02-01T16:00:00Z'
price: 50
operator: Deutsche Bahn
bicycles_allowed: true
dogs_allowed: true
- id: 4d67459c-af07-40bb-bb12-178dbb88e09f
origin: b2e783e1-c824-4d63-b37a-d8d698862f1d
destination: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
departure_time: '2024-02-01T12:00:00Z'
arrival_time: '2024-02-01T18:00:00Z'
price: 50
operator: SNCF
bicycles_allowed: true
dogs_allowed: true
links:
self: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01
next: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01&page=2

- target: $.paths["/bookings"].get.responses["200"].content["application/json"]["example"]
remove: true

- target: $.paths["/bookings"].get.responses["200"].content["application/json"]
update:
examples:
bookings:
summary: A list of bookings
value:
data:
- id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
- id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
passenger_name: Jane Smith
has_bicycle: false
has_dog: false
links:
self: https://api.example.com/bookings
next: https://api.example.com/bookings?page=2

- target: $.paths["/bookings"]["post"].responses["201"].content["application/json"]["example"]
remove: true

- target: $.paths["/bookings"]["post"].responses["201"].content["application/json"]
update:
examples:
new_booking:
summary: New Booking
value: |-
{
"id": "{{ uuid() > put(bookingId) }}",
"trip_id": "{{ request.body/trip_id }}",
"passenger_name": "{{ request.body/passenger_name }}",
"has_bicycle": {{ request.body/has_bicycle }},
"has_dog": {{ request.body/has_dog }},
"links": {
"self": "https://api.example.com/bookings/{{ bookingId }}"
}
}
- target: $.paths["/bookings/{bookingId}"].parameters[?(@.name=="bookingId")].example
remove: true

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

- target: $.paths["/bookings/{bookingId}"].get.responses["200"].content["application/json"]["example"]
remove: true

- target: $.paths["/bookings/{bookingId}"].get.responses["200"].content["application/json"]
update:
examples:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: John Doe
value:
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Billy Bikeless
value:
id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
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:
value: 1725ff48-ab45-4bb5-9d02-88745177dedb

- target: $.webhooks["newBooking"]["post"]["requestBody"].content["application/json"]["example"]
remove: true

- target: $.webhooks["newBooking"]["post"]["requestBody"].content["application/json"]
update:
examples:
new_booking:
summary: New Booking
value:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
203 changes: 82 additions & 121 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ servers:
- url: https://api.example.com
description: Production
x-internal: false

- url: https://mocks.example.com/rest
description: Mock Server
x-internal: false
@@ -121,25 +122,22 @@ paths:
allOf:
- $ref: '#/components/schemas/Links-Self'
- $ref: '#/components/schemas/Links-Pagination'
examples:
stations:
summary: A list of train stations
value:
data:
- id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
name: Berlin Hauptbahnhof
address: Invalidenstraße 10557 Berlin, Germany
country_code: DE
timezone: Europe/Berlin
- id: b2e783e1-c824-4d63-b37a-d8d698862f1d
name: Paris Gare du Nord
address: 18 Rue de Dunkerque 75010 Paris, France
country_code: FR
timezone: Europe/Paris
links:
self: https://api.example.com/stations&page=2
next: https://api.example.com/stations?page=3
prev: https://api.example.com/stations?page=1
example:
data:
- id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
name: Berlin Hauptbahnhof
address: Invalidenstraße 10557 Berlin, Germany
country_code: DE
timezone: Europe/Berlin
- id: b2e783e1-c824-4d63-b37a-d8d698862f1d
name: Paris Gare du Nord
address: 18 Rue de Dunkerque 75010 Paris, France
country_code: FR
timezone: Europe/Paris
links:
self: https://api.example.com/stations&page=2
next: https://api.example.com/stations?page=3
prev: https://api.example.com/stations?page=1
application/xml:
schema:
allOf:
@@ -195,19 +193,15 @@ paths:
schema:
type: string
format: uuid
examples:
trips:
value: b2e783e1-c824-4d63-b37a-d8d698862f1d
example: b2e783e1-c824-4d63-b37a-d8d698862f1d
- name: date
in: query
description: The date and time of the trip in ISO 8601 format in origin station's timezone.
required: true
schema:
type: string
format: date-time
examples:
trips:
value: '2024-02-01T09:00:00Z'
example: '2024-02-01T09:00:00Z'
- name: bicycles
in: query
description: Only return trips where bicycles are known to be allowed
@@ -245,32 +239,29 @@ paths:
allOf:
- $ref: '#/components/schemas/Links-Self'
- $ref: '#/components/schemas/Links-Pagination'
examples:
trips:
summary: A list of available train trips
value:
data:
- id: ea399ba1-6d95-433f-92d1-83f67b775594
origin: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
destination: b2e783e1-c824-4d63-b37a-d8d698862f1d
departure_time: '2024-02-01T10:00:00Z'
arrival_time: '2024-02-01T16:00:00Z'
price: 50
operator: Deutsche Bahn
bicycles_allowed: true
dogs_allowed: true
- id: 4d67459c-af07-40bb-bb12-178dbb88e09f
origin: b2e783e1-c824-4d63-b37a-d8d698862f1d
destination: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
departure_time: '2024-02-01T12:00:00Z'
arrival_time: '2024-02-01T18:00:00Z'
price: 50
operator: SNCF
bicycles_allowed: true
dogs_allowed: true
links:
self: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01
next: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01&page=2
example:
data:
- id: ea399ba1-6d95-433f-92d1-83f67b775594
origin: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
destination: b2e783e1-c824-4d63-b37a-d8d698862f1d
departure_time: '2024-02-01T10:00:00Z'
arrival_time: '2024-02-01T16:00:00Z'
price: 50
operator: Deutsche Bahn
bicycles_allowed: true
dogs_allowed: true
- id: 4d67459c-af07-40bb-bb12-178dbb88e09f
origin: b2e783e1-c824-4d63-b37a-d8d698862f1d
destination: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
departure_time: '2024-02-01T12:00:00Z'
arrival_time: '2024-02-01T18:00:00Z'
price: 50
operator: SNCF
bicycles_allowed: true
dogs_allowed: true
links:
self: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01
next: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01&page=2
application/xml:
schema:
allOf:
@@ -331,24 +322,21 @@ paths:
allOf:
- $ref: '#/components/schemas/Links-Self'
- $ref: '#/components/schemas/Links-Pagination'
examples:
Bookings:
summary: A list of bookings
value:
data:
- id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
- id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
passenger_name: Jane Smith
has_bicycle: false
has_dog: false
links:
self: https://api.example.com/bookings
next: https://api.example.com/bookings?page=2
example:
data:
- id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
- id: b2e783e1-c824-4d63-b37a-d8d698862f1d
trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
passenger_name: Jane Smith
has_bicycle: false
has_dog: false
links:
self: https://api.example.com/bookings
next: https://api.example.com/bookings?page=2
application/xml:
schema:
allOf:
@@ -407,21 +395,14 @@ paths:
links:
$ref: '#/components/schemas/Links-Self'

examples:
new_booking:
summary: New Booking
value: |-
{
"id": "{{ uuid() > put(bookingId) }}",
"trip_id": "{{ request.body/trip_id }}",
"passenger_name": "{{ request.body/passenger_name }}",
"has_bicycle": {{ request.body/has_bicycle }},
"has_dog": {{ request.body/has_dog }},
"links": {
"self": "https://api.example.com/bookings/{{ bookingId }}"
}
}
example:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
application/xml:
schema:
allOf:
@@ -451,11 +432,7 @@ paths:
schema:
type: string
format: uuid
examples:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
value: 1725ff48-ab45-4bb5-9d02-88745177dedb
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
value: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
example: 1725ff48-ab45-4bb5-9d02-88745177dedb
get:
summary: Get a booking
description: Returns the details of a specific booking.
@@ -478,27 +455,14 @@ paths:
- properties:
links:
$ref: '#/components/schemas/Links-Self'
examples:
booking_1725ff48-ab45-4bb5-9d02-88745177dedb:
summary: John Doe
value:
id: 1725ff48-ab45-4bb5-9d02-88745177dedb
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
booking_bfc5af2c-f477-43c4-8bdf-a00bdb939d65:
summary: Billy Bikeless
value:
id: bfc5af2c-f477-43c4-8bdf-a00bdb939d65
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: Billy Bikeless
has_bicycle: false
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
example:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
application/xml:
schema:
allOf:
@@ -678,17 +642,14 @@ webhooks:
allOf:
- $ref: '#/components/schemas/Links-Self'
- $ref: '#/components/schemas/Links-Pagination'
examples:
new_booking:
summary: New Booking
value:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
example:
id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
passenger_name: John Doe
has_bicycle: true
has_dog: true
links:
self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
responses:
'200':
description: Return a 200 status to indicate that the data was received successfully.

0 comments on commit 765262b

Please sign in to comment.