-
Notifications
You must be signed in to change notification settings - Fork 0
/
customers.yaml
199 lines (199 loc) · 5.61 KB
/
customers.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# OpenAPI specification for the example API
openapi: 3.1.0
info:
title: api
# Microcks expects API versions for mock generation both in input specifications and accompanying "secondary
# artifacts" such as Postman collections with API examples. Moreover, the versions must match, which is why we rely
# on the Maven Resources Plugin to replace the term "${mocked_api.version}" with the eponymous property from the POM
# holding the desired API version.
version: "${mocked_api.version}"
paths:
/customer_kinds:
get:
operationId: customer_kinds_get
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerKindsResponse"
security:
- api_key: []
/customer_kinds/{id}:
get:
operationId: customer_kind_details_get
parameters:
- in: path
name: id
required: true
schema:
type: string
description: Customer kind ID
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerKindDetailsResponse"
security:
- api_key: [ ]
/login:
post:
operationId: login_post
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/LoginRequest"
# For illustrative purposes, we model API request and response examples both in this specification as well
# as in an accompanying Postman collection in the sense of a Microcks "secondary artifact"
examples:
some_customer:
value:
email: ${some_customer_email}
password: ${some_customer_password}
invalid_credentials:
value:
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/LoginResponse"
examples:
some_customer:
value:
customer_token: ${some_customer_token}
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/LoginResponse"
examples:
invalid_credentials:
value:
security:
- api_key: []
/customer:
get:
operationId: customer_get
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerResponse"
examples:
some_customer:
value:
email: some_customer@example.org
# For illustrative purposes, we let Microcks generate values for the following fields, thereby
# providing a "dynamic mock" (see https://microcks.io/documentation/explanations/dynamic-content for
# details)
first_name: "{{ randomFirstName() }}"
last_name: "{{ randomLastName() }}"
company_name:
address: "{{ randomStreetAddress() }}, {{ randomCity() }}, {{ randomCountry() }}"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerResponse"
examples:
invalid_credentials:
value:
security:
- api_key: []
components:
schemas:
CustomerKindsResponse:
title: CustomerKindsResponse
type: object
additionalProperties:
type: string
CustomerKindDetailsResponse:
title: CustomerKindDetailsResponse
required:
- id
- kind
- createdOn
- updatedOn
type: object
properties:
id:
title: Id
type: string
description: ID of the customer kind
kind:
title: Kind
type: string
description: Customer kind
example: Key account
createdOn:
title: Created on
type: string
description: Timestamp of customer kind's creation
updatedOn:
title: Updated on
type: string
description: Timestamp of customer kind's last update
LoginRequest:
required:
- email
- password
type: object
properties:
email:
title: Email
type: string
format: email
password:
title: Password
type: string
format: password
writeOnly: true
LoginResponse:
required:
- customer_token
type: object
properties:
customer_token:
title: Customer Token
type: string
CustomerResponse:
required:
- email
- first_name
- last_name
- company_name
- address
type: object
properties:
email:
title: Email
type: string
format: email
first_name:
title: First Name
type: string
last_name:
title: Last Name
type: string
company_name:
title: Company Name
type: string
address:
title: Address
type: string
securitySchemes:
api_key:
type: apiKey
in: header
name: api_key