Skip to content

Commit 216ef50

Browse files
authored
Merge pull request #428 from codeforboston/dmalone/oas-filtering
Add additional filtering options to the OAS
2 parents 30f42d9 + 4b00b16 commit 216ef50

File tree

4 files changed

+213
-35
lines changed

4 files changed

+213
-35
lines changed

oas/2.0/agencies.yaml

Lines changed: 121 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ paths:
2727
summary: "Get Agencies"
2828
operationId: "getAgencies"
2929
description: "Get a list of all agencies"
30+
parameters:
31+
- $ref: '../common/pagination.yaml#/components/parameters/page'
32+
- $ref: '../common/pagination.yaml#/components/parameters/per_page'
33+
- $ref: '#/components/parameters/jurisdiction'
34+
- $ref: '#/components/parameters/name'
35+
- $ref: '#/components/parameters/zip_code'
36+
- $ref: '#/components/parameters/city'
37+
- $ref: '#/components/parameters/state'
3038
tags:
3139
- Agencies
3240
responses:
@@ -101,17 +109,29 @@ paths:
101109
$ref: '#/components/schemas/Agency'
102110
'400':
103111
$ref: '../common/error.yaml#/components/responses/validationError'
112+
'404':
113+
$ref: '../common/error.yaml#/components/responses/notFoundError'
104114
/agencies/{agency_uid}/officers:
105-
parameters:
106-
- name: "agency_uid"
107-
in: "path"
108-
description: "The uid of the agency you want to retrieve."
109-
required: true
110-
schema:
111-
type: "string"
112115
get:
113116
summary: "Get Officers"
114117
operationId: "getOfficers"
118+
parameters:
119+
- name: "agency_uid"
120+
in: "path"
121+
description: "The uid of the agency you want to retrieve."
122+
required: true
123+
schema:
124+
type: "string"
125+
- $ref: '../common/pagination.yaml#/components/parameters/page'
126+
- $ref: '../common/pagination.yaml#/components/parameters/per_page'
127+
- $ref: 'officers.yaml#/components/parameters/active_after'
128+
- $ref: 'officers.yaml#/components/parameters/active_before'
129+
- $ref: 'officers.yaml#/components/parameters/agency'
130+
- $ref: 'officers.yaml#/components/parameters/rank'
131+
- $ref: 'officers.yaml#/components/parameters/unit'
132+
- $ref: 'officers.yaml#/components/parameters/name'
133+
- $ref: 'officers.yaml#/components/parameters/ethnicity'
134+
- $ref: 'officers.yaml#/components/parameters/badge_number'
115135
description: >
116136
Get a list of all of the officers who have been employed
117137
by a given agency.
@@ -124,13 +144,24 @@ paths:
124144
application/json:
125145
schema:
126146
$ref: officers.yaml#/components/schemas/OfficerList
147+
'400':
148+
$ref: '../common/error.yaml#/components/responses/validationError'
149+
'404':
150+
$ref: '../common/error.yaml#/components/responses/notFoundError'
127151
put:
128152
summary: "Add Employment Records"
129153
operationId: "addOfficers"
130154
description: >
131155
Adds officer employment records to an agency. Can only
132156
add records for officers that already exist in the database.
133157
User must be a contributor.
158+
parameters:
159+
- name: "agency_uid"
160+
in: "path"
161+
description: "The uid of the agency you want to retrieve."
162+
required: true
163+
schema:
164+
type: "string"
134165
tags:
135166
- Units
136167
requestBody:
@@ -153,17 +184,23 @@ paths:
153184
'404':
154185
$ref: '../common/error.yaml#/components/responses/notFoundError'
155186
/agencies/{agency_uid}/units:
156-
parameters:
157-
- name: "agency_uid"
158-
in: "path"
159-
description: "The uid of the agency you want to retrieve."
160-
required: true
161-
schema:
162-
type: "string"
163187
get:
164188
summary: "Get Units"
165189
operationId: "getUnits"
166190
description: "Get a list of all units for a given agency."
191+
parameters:
192+
- name: "agency_uid"
193+
in: "path"
194+
description: "The uid of the agency you want to retrieve units for."
195+
required: true
196+
schema:
197+
type: "string"
198+
- $ref: '../common/pagination.yaml#/components/parameters/page'
199+
- $ref: '../common/pagination.yaml#/components/parameters/per_page'
200+
- $ref: '#/components/parameters/name'
201+
- $ref: '#/components/parameters/zip_code'
202+
- $ref: '#/components/parameters/city'
203+
- $ref: '#/components/parameters/state'
167204
tags:
168205
- Units
169206
responses:
@@ -179,6 +216,13 @@ paths:
179216
summary: "Create Unit"
180217
operationId: "createUnit"
181218
description: "Adds a unit or command to an existing agency. User must be a contributor."
219+
parameters:
220+
- name: "agency_uid"
221+
in: "path"
222+
description: "The uid of the agency you want to retrieve units for."
223+
required: true
224+
schema:
225+
type: "string"
182226
tags:
183227
- Units
184228
requestBody:
@@ -197,20 +241,9 @@ paths:
197241
$ref: "#/components/schemas/CreateUnit"
198242
'400':
199243
$ref: '../common/error.yaml#/components/responses/validationError'
244+
'404':
245+
$ref: '../common/error.yaml#/components/responses/notFoundError'
200246
/agencies/{agency_uid}/units/{unit_uid}:
201-
parameters:
202-
- name: "agency_uid"
203-
in: "path"
204-
description: "The uid of the agency you want to retrieve."
205-
required: true
206-
schema:
207-
type: "string"
208-
- name: "unit_uid"
209-
in: "path"
210-
description: "The uid of the agency you want to retrieve."
211-
required: true
212-
schema:
213-
type: "string"
214247
get:
215248
summary: "Get Unit"
216249
operationId: "getUnit"
@@ -225,17 +258,40 @@ paths:
225258
required: true
226259
schema:
227260
type: "string"
261+
- name: "unit_uid"
262+
in: "path"
263+
description: "The uid of the unit you want to retrieve."
264+
required: true
265+
schema:
266+
type: "string"
228267
responses:
229268
"200":
230269
description: "A JSON array of unit objects"
231270
content:
232271
application/json:
233272
schema:
234273
$ref: "#/components/schemas/Unit"
274+
'400':
275+
$ref: '../common/error.yaml#/components/responses/validationError'
276+
'404':
277+
$ref: '../common/error.yaml#/components/responses/notFoundError'
235278
patch:
236279
summary: "Update Unit"
237280
operationId: "updateUnit"
238281
description: "Update an existing unit. User must be a contributor."
282+
parameters:
283+
- name: "agency_uid"
284+
in: "path"
285+
description: "The uid of the agency you want to retrieve units for."
286+
required: true
287+
schema:
288+
type: "string"
289+
- name: "unit_uid"
290+
in: "path"
291+
description: "The uid of the unit you want to retrieve."
292+
required: true
293+
schema:
294+
type: "string"
239295
tags:
240296
- Units
241297
requestBody:
@@ -254,12 +310,50 @@ paths:
254310
$ref: "#/components/schemas/Unit"
255311
'400':
256312
$ref: '../common/error.yaml#/components/responses/validationError'
313+
'404':
314+
$ref: '../common/error.yaml#/components/responses/notFoundError'
257315
components:
258316
securitySchemes:
259317
bearerAuth:
260318
type: http
261319
scheme: bearer
262320
bearerFormat: JWT
321+
parameters:
322+
jurisdiction:
323+
name: "jurisdiction"
324+
in: "query"
325+
description: "Filter agencies by jurisdiction"
326+
required: false
327+
schema:
328+
type: "string"
329+
zip_code:
330+
name: "zip_code"
331+
in: "query"
332+
description: "Filter by zip code"
333+
required: false
334+
schema:
335+
type: "string"
336+
city:
337+
name: "city"
338+
in: "query"
339+
description: "Filter by city"
340+
required: false
341+
schema:
342+
type: "string"
343+
state:
344+
name: "state"
345+
in: "query"
346+
description: "Filter by state"
347+
required: false
348+
schema:
349+
type: "string"
350+
name:
351+
name: "name"
352+
in: "query"
353+
description: "Filter by name"
354+
required: false
355+
schema:
356+
type: "string"
263357
schemas:
264358
BaseAgency:
265359
type: "object"

oas/2.0/authentication.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ x-readme:
1414
explorer-enabled: true
1515
proxy-enabled: true
1616
samples-enabled: true
17-
security:
18-
- bearerAuth: []
1917
tags:
2018
- name: "Authentication"
2119
description: "API for authenticating and creating user accounts."
2220
paths:
2321
/auth/register:
2422
post:
25-
summary: "register User Account"
23+
summary: "Register New Account"
2624
operationId: "register"
2725
description: "Create a new user account."
2826
tags:
@@ -45,7 +43,7 @@ paths:
4543
$ref: '../common/error.yaml#/components/responses/conflictError'
4644
/auth/login:
4745
post:
48-
summary: "Log in"
46+
summary: "Log In"
4947
operationId: "login"
5048
description: "Log in to an existing user account."
5149
tags:
@@ -65,7 +63,9 @@ paths:
6563
'400':
6664
$ref: '../common/error.yaml#/components/responses/validationError'
6765
/auth/refresh:
68-
post:
66+
post:
67+
security:
68+
- bearerAuth: []
6969
summary: "Refresh Access Token"
7070
operationId: "refreshToken"
7171
description: >
@@ -85,7 +85,9 @@ paths:
8585
$ref: '../common/error.yaml#/components/responses/unauthorizedError'
8686
/auth/logout:
8787
post:
88-
summary: "Log out"
88+
security:
89+
- bearerAuth: []
90+
summary: "Log Out"
8991
operationId: "logout"
9092
description: "Revokes the access token used to autheticate this request."
9193
tags:
@@ -101,7 +103,9 @@ paths:
101103
$ref: '../common/error.yaml#/components/responses/unauthorizedError'
102104
/auth/whoami:
103105
get:
104-
summary: "Who Am I"
106+
security:
107+
- bearerAuth: []
108+
summary: "Current User"
105109
operationId: "whoami"
106110
description: "Returns the user that matches the access token used to authenticate the request."
107111
tags:

0 commit comments

Comments
 (0)