Skip to content

Commit 63506a4

Browse files
authored
OAS Updates (#409)
* OAS Updates - Add suffix to the officer record - Add record IDs to complaints and allegations - Add type and subtype to allegations * partners->sources * Update pydantic models * Typo
1 parent 008334f commit 63506a4

File tree

9 files changed

+158
-63
lines changed

9 files changed

+158
-63
lines changed

oas/2.0/agencies.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ components:
264264
BaseAgency:
265265
type: "object"
266266
properties:
267-
uid:
268-
type: "string"
269-
description: "Unique identifier for the agency"
270267
name:
271268
type: "string"
272269
description: "Name of the agency"
@@ -323,8 +320,8 @@ components:
323320
- type: "object"
324321
properties:
325322
uid:
326-
type: "string"
327-
description: "Unique identifier for the agency"
323+
type: string
324+
description: Unique identifier for the agency
328325
officers_url:
329326
type: "string"
330327
description: "URL to get a list of officers for this agency"

oas/2.0/complaints.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ components:
125125
type: "object"
126126
description: "Base complaint object"
127127
properties:
128+
record_id:
129+
type: string
130+
description: The ID that was given to this complaint by the orginal source of the data.
128131
source_details:
129132
$ref: '#/components/schemas/SourceDetails'
130133
category:
@@ -137,7 +140,7 @@ components:
137140
recieved_date:
138141
type: "string"
139142
format: "date-time"
140-
description: "The date and time the complaint was received by the reporting partner."
143+
description: "The date and time the complaint was received by the reporting source."
141144
closed_date:
142145
type: "string"
143146
format: "date-time"
@@ -189,7 +192,7 @@ components:
189192
properties:
190193
source_uid:
191194
type: "string"
192-
description: "The UID of the partner that reported the complaint."
195+
description: "The UID of the source that reported the complaint."
193196
civilian_review_board_uid:
194197
type: "string"
195198
description: "The UID of the civilian review board that reviewed the complaint."
@@ -274,9 +277,9 @@ components:
274277
description: "Date and time the complaint was last updated."
275278
source:
276279
allOf:
277-
- $ref: partners.yaml#/components/schemas/Partner
280+
- $ref: sources.yaml#/components/schemas/Source
278281
- type: "object"
279-
description: "The partner that reported the complaint."
282+
description: "The source that reported the complaint."
280283
civilian_review_board:
281284
allOf:
282285
- $ref: '#/components/schemas/ReviewBoard'
@@ -315,6 +318,9 @@ components:
315318
BaseAllegation:
316319
type: "object"
317320
properties:
321+
record_id:
322+
type: string
323+
description: The ID that was given to this allegation by the orginal source of the data.
318324
complaintant:
319325
allOf:
320326
- $ref: "#/components/schemas/Civilian"
@@ -323,6 +329,12 @@ components:
323329
allegation:
324330
type: "string"
325331
description: "The allegation made by the complaintant."
332+
type:
333+
type: string
334+
description: The type of allegation.
335+
sub_type:
336+
type: string
337+
description: The sub type of the allegation.
326338
recomended_finding:
327339
type: "string"
328340
description: "The finding recomended by the review board."

oas/2.0/officers.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ components:
186186
earliest_employment:
187187
type: "string"
188188
format: "date"
189-
description: "The earliest date of employment"
189+
description: "The earliest known date of employment"
190190
latest_employment:
191191
type: "string"
192192
format: "date"
193-
description: "The latest date of employment"
193+
description: "The latest known date of employment"
194194
badge_number:
195195
type: "string"
196196
description: "The badge number of the officer"
@@ -270,6 +270,9 @@ components:
270270
last_name:
271271
type: "string"
272272
description: "Last name of the officer"
273+
suffix:
274+
type: "string"
275+
description: "Suffix of the officer's name"
273276
ethnicity:
274277
type: "string"
275278
description: "The ethnicity of the officer"

oas/2.0/partners.yaml renamed to oas/2.0/sources.yaml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: "3.0.3"
22
info:
3-
title: "Partners"
3+
title: "Sources"
44
description: "API Description"
55
version: "0.1.0"
66
servers:
@@ -17,15 +17,15 @@ x-readme:
1717
security:
1818
- bearerAuth: []
1919
tags:
20-
- name: "Partners"
21-
description: "Partners API"
20+
- name: "Sources"
21+
description: "Sources API"
2222
paths:
23-
/partners:
23+
/sources:
2424
get:
2525
tags:
26-
- "Partners"
27-
summary: "Get all partners"
28-
operationId: "getPartners"
26+
- "Sources"
27+
summary: "Get all sources"
28+
operationId: "getSources"
2929
responses:
3030
"200":
3131
description: "Successful operation"
@@ -37,8 +37,8 @@ paths:
3737
$ref: "#/components/schemas/PartnerList"
3838
post:
3939
tags:
40-
- "Partners"
41-
summary: "Create a new partner"
40+
- "Sources"
41+
summary: "Create a new source"
4242
operationId: "createPartner"
4343
requestBody:
4444
content:
@@ -51,37 +51,37 @@ paths:
5151
content:
5252
application/json:
5353
schema:
54-
$ref: '#/components/schemas/Partner'
54+
$ref: '#/components/schemas/Source'
5555
'400':
5656
$ref: '../common/error.yaml#/components/responses/validationError'
57-
/partners/{uid}:
57+
/sources/{uid}:
5858
parameters:
5959
- name: uid
6060
in: path
61-
description: UID of the partner
61+
description: UID of the source
6262
required: true
6363
schema:
6464
type: string
6565
get:
6666
tags:
67-
- "Partners"
68-
summary: "Get Partner"
67+
- "Sources"
68+
summary: "Get Source"
6969
operationId: "getPartnerById"
7070
description: >
71-
Returns a single partner.
71+
Returns a single source.
7272
responses:
7373
'200':
7474
description: "Successful operation"
7575
content:
7676
application/json:
7777
schema:
78-
$ref: "#/components/schemas/Partner"
78+
$ref: "#/components/schemas/Source"
7979
'404':
8080
$ref: '../common/error.yaml#/components/responses/notFoundError'
8181
patch:
8282
tags:
83-
- "Partners"
84-
summary: "Update an existing partner"
83+
- "Sources"
84+
summary: "Update an existing source"
8585
operationId: "updatePartner"
8686
requestBody:
8787
content:
@@ -94,26 +94,26 @@ paths:
9494
content:
9595
application/json:
9696
schema:
97-
$ref: '#/components/schemas/Partner'
97+
$ref: '#/components/schemas/Source'
9898
'400':
9999
$ref: '../common/error.yaml#/components/responses/validationError'
100100
'404':
101101
$ref: '../common/error.yaml#/components/responses/notFoundError'
102-
/partners/{uid}/members:
102+
/sources/{uid}/members:
103103
parameters:
104104
- name: uid
105105
in: path
106-
description: UID of the partner
106+
description: UID of the source
107107
required: true
108108
schema:
109109
type: string
110110
get:
111111
tags:
112-
- Partners
112+
- Sources
113113
summary: "Get all members"
114114
operationId: "getMembers"
115115
description: >
116-
Returns a list of all users who are members of a partner.
116+
Returns a list of all users who are members of a source.
117117
responses:
118118
'200':
119119
description: 'Successful operation'
@@ -138,13 +138,13 @@ components:
138138
properties:
139139
name:
140140
type: "string"
141-
description: "Name of the partner organization."
141+
description: "Name of the source organization."
142142
url:
143143
type: "string"
144-
description: "Website URL of the partner."
144+
description: "Website URL of the source."
145145
contact_email:
146146
type: "string"
147-
description: "Contact email for the partner organization."
147+
description: "Contact email for the source organization."
148148
CreatePartner:
149149
allOf:
150150
- $ref: "#/components/schemas/BasePartner"
@@ -155,20 +155,20 @@ components:
155155
UpdatePartner:
156156
allOf:
157157
- $ref: "#/components/schemas/BasePartner"
158-
Partner:
158+
Source:
159159
allOf:
160160
- $ref: "#/components/schemas/BasePartner"
161161
- type: "object"
162162
properties:
163163
uid:
164164
type: "string"
165-
description: "Unique identifier for the partner."
165+
description: "Unique identifier for the source."
166166
members:
167167
type: string
168-
description: "Url to get all members of the partner."
169-
reported_incidents:
168+
description: "Url to get all members of the source."
169+
reported_complaints:
170170
type: string
171-
description: "Url to get all incidents reported by the partner."
171+
description: "Url to get all complaints reported by the source."
172172
PartnerList:
173173
allOf:
174174
- $ref: '../common/pagination.yaml#/components/schemas/PaginatedResponse'
@@ -177,13 +177,13 @@ components:
177177
results:
178178
type: "array"
179179
items:
180-
$ref: "#/components/schemas/Partner"
180+
$ref: "#/components/schemas/Source"
181181
MemberBase:
182182
type: "object"
183183
properties:
184-
partner_uid:
184+
source_uid:
185185
type: "string"
186-
description: "Unique identifier for the partner."
186+
description: "Unique identifier for the source."
187187
user_uid:
188188
type: "string"
189189
description: "Unique identifier for the user."
@@ -210,15 +210,15 @@ components:
210210
date_joined:
211211
type: "string"
212212
format: "date-time"
213-
description: "Date the user joined the partner organizaation."
213+
description: "Date the user joined the source organizaation."
214214
AddMember:
215215
allOf:
216216
- $ref: "#/components/schemas/MemberBase"
217217
- type: "object"
218218
required:
219219
- role
220220
- user_uid
221-
- partner_uid
221+
- source_uid
222222
MemberList:
223223
allOf:
224224
- $ref: '../common/pagination.yaml#/components/schemas/PaginatedResponse'

oas/gen_pydantic.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
python oas_to_pydantic.py 2.0/sources.yaml pydantic/sources.py
4+
python oas_to_pydantic.py 2.0/complaints.yaml pydantic/complaints.py
5+
python oas_to_pydantic.py 2.0/officers.yaml pydantic/officers.py
6+
python oas_to_pydantic.py 2.0/agencies.yaml pydantic/agencies.py
7+
python oas_to_pydantic.py 2.0/litigation.yaml pydantic/litigation.py

oas/pydantic/agencies.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
class BaseAgency(BaseModel):
6-
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
76
name: Optional[str] = Field(None, description="Name of the agency")
87
hq_address: Optional[str] = Field(None, description="Address of the agency")
98
hq_city: Optional[str] = Field(None, description="City of the agency")
@@ -16,7 +15,6 @@ class BaseAgency(BaseModel):
1615

1716

1817
class CreateAgency(BaseAgency, BaseModel):
19-
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
2018
name: Optional[str] = Field(None, description="Name of the agency")
2119
hq_address: Optional[str] = Field(None, description="Address of the agency")
2220
hq_city: Optional[str] = Field(None, description="City of the agency")
@@ -29,7 +27,6 @@ class CreateAgency(BaseAgency, BaseModel):
2927

3028

3129
class UpdateAgency(BaseAgency, BaseModel):
32-
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
3330
name: Optional[str] = Field(None, description="Name of the agency")
3431
hq_address: Optional[str] = Field(None, description="Address of the agency")
3532
hq_city: Optional[str] = Field(None, description="City of the agency")
@@ -46,7 +43,6 @@ class AgencyList(PaginatedResponse, BaseModel):
4643

4744

4845
class Agency(BaseAgency, BaseModel):
49-
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
5046
name: Optional[str] = Field(None, description="Name of the agency")
5147
hq_address: Optional[str] = Field(None, description="Address of the agency")
5248
hq_city: Optional[str] = Field(None, description="City of the agency")
@@ -56,6 +52,7 @@ class Agency(BaseAgency, BaseModel):
5652
phone: Optional[str] = Field(None, description="Phone number of the agency")
5753
email: Optional[str] = Field(None, description="Email of the agency")
5854
website_url: Optional[str] = Field(None, description="Website of the agency")
55+
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
5956
officers_url: Optional[str] = Field(None, description="URL to get a list of officers for this agency")
6057
units_url: Optional[str] = Field(None, description="URL to get a list of units for this agency")
6158

0 commit comments

Comments
 (0)