Skip to content

Commit

Permalink
OAS Updates (codeforboston#409)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DMalone87 authored Sep 28, 2024
1 parent 008334f commit 63506a4
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 63 deletions.
7 changes: 2 additions & 5 deletions oas/2.0/agencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,6 @@ components:
BaseAgency:
type: "object"
properties:
uid:
type: "string"
description: "Unique identifier for the agency"
name:
type: "string"
description: "Name of the agency"
Expand Down Expand Up @@ -323,8 +320,8 @@ components:
- type: "object"
properties:
uid:
type: "string"
description: "Unique identifier for the agency"
type: string
description: Unique identifier for the agency
officers_url:
type: "string"
description: "URL to get a list of officers for this agency"
Expand Down
20 changes: 16 additions & 4 deletions oas/2.0/complaints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ components:
type: "object"
description: "Base complaint object"
properties:
record_id:
type: string
description: The ID that was given to this complaint by the orginal source of the data.
source_details:
$ref: '#/components/schemas/SourceDetails'
category:
Expand All @@ -137,7 +140,7 @@ components:
recieved_date:
type: "string"
format: "date-time"
description: "The date and time the complaint was received by the reporting partner."
description: "The date and time the complaint was received by the reporting source."
closed_date:
type: "string"
format: "date-time"
Expand Down Expand Up @@ -189,7 +192,7 @@ components:
properties:
source_uid:
type: "string"
description: "The UID of the partner that reported the complaint."
description: "The UID of the source that reported the complaint."
civilian_review_board_uid:
type: "string"
description: "The UID of the civilian review board that reviewed the complaint."
Expand Down Expand Up @@ -274,9 +277,9 @@ components:
description: "Date and time the complaint was last updated."
source:
allOf:
- $ref: partners.yaml#/components/schemas/Partner
- $ref: sources.yaml#/components/schemas/Source
- type: "object"
description: "The partner that reported the complaint."
description: "The source that reported the complaint."
civilian_review_board:
allOf:
- $ref: '#/components/schemas/ReviewBoard'
Expand Down Expand Up @@ -315,6 +318,9 @@ components:
BaseAllegation:
type: "object"
properties:
record_id:
type: string
description: The ID that was given to this allegation by the orginal source of the data.
complaintant:
allOf:
- $ref: "#/components/schemas/Civilian"
Expand All @@ -323,6 +329,12 @@ components:
allegation:
type: "string"
description: "The allegation made by the complaintant."
type:
type: string
description: The type of allegation.
sub_type:
type: string
description: The sub type of the allegation.
recomended_finding:
type: "string"
description: "The finding recomended by the review board."
Expand Down
7 changes: 5 additions & 2 deletions oas/2.0/officers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ components:
earliest_employment:
type: "string"
format: "date"
description: "The earliest date of employment"
description: "The earliest known date of employment"
latest_employment:
type: "string"
format: "date"
description: "The latest date of employment"
description: "The latest known date of employment"
badge_number:
type: "string"
description: "The badge number of the officer"
Expand Down Expand Up @@ -270,6 +270,9 @@ components:
last_name:
type: "string"
description: "Last name of the officer"
suffix:
type: "string"
description: "Suffix of the officer's name"
ethnicity:
type: "string"
description: "The ethnicity of the officer"
Expand Down
72 changes: 36 additions & 36 deletions oas/2.0/partners.yaml → oas/2.0/sources.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: "3.0.3"
info:
title: "Partners"
title: "Sources"
description: "API Description"
version: "0.1.0"
servers:
Expand All @@ -17,15 +17,15 @@ x-readme:
security:
- bearerAuth: []
tags:
- name: "Partners"
description: "Partners API"
- name: "Sources"
description: "Sources API"
paths:
/partners:
/sources:
get:
tags:
- "Partners"
summary: "Get all partners"
operationId: "getPartners"
- "Sources"
summary: "Get all sources"
operationId: "getSources"
responses:
"200":
description: "Successful operation"
Expand All @@ -37,8 +37,8 @@ paths:
$ref: "#/components/schemas/PartnerList"
post:
tags:
- "Partners"
summary: "Create a new partner"
- "Sources"
summary: "Create a new source"
operationId: "createPartner"
requestBody:
content:
Expand All @@ -51,37 +51,37 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Partner'
$ref: '#/components/schemas/Source'
'400':
$ref: '../common/error.yaml#/components/responses/validationError'
/partners/{uid}:
/sources/{uid}:
parameters:
- name: uid
in: path
description: UID of the partner
description: UID of the source
required: true
schema:
type: string
get:
tags:
- "Partners"
summary: "Get Partner"
- "Sources"
summary: "Get Source"
operationId: "getPartnerById"
description: >
Returns a single partner.
Returns a single source.
responses:
'200':
description: "Successful operation"
content:
application/json:
schema:
$ref: "#/components/schemas/Partner"
$ref: "#/components/schemas/Source"
'404':
$ref: '../common/error.yaml#/components/responses/notFoundError'
patch:
tags:
- "Partners"
summary: "Update an existing partner"
- "Sources"
summary: "Update an existing source"
operationId: "updatePartner"
requestBody:
content:
Expand All @@ -94,26 +94,26 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Partner'
$ref: '#/components/schemas/Source'
'400':
$ref: '../common/error.yaml#/components/responses/validationError'
'404':
$ref: '../common/error.yaml#/components/responses/notFoundError'
/partners/{uid}/members:
/sources/{uid}/members:
parameters:
- name: uid
in: path
description: UID of the partner
description: UID of the source
required: true
schema:
type: string
get:
tags:
- Partners
- Sources
summary: "Get all members"
operationId: "getMembers"
description: >
Returns a list of all users who are members of a partner.
Returns a list of all users who are members of a source.
responses:
'200':
description: 'Successful operation'
Expand All @@ -138,13 +138,13 @@ components:
properties:
name:
type: "string"
description: "Name of the partner organization."
description: "Name of the source organization."
url:
type: "string"
description: "Website URL of the partner."
description: "Website URL of the source."
contact_email:
type: "string"
description: "Contact email for the partner organization."
description: "Contact email for the source organization."
CreatePartner:
allOf:
- $ref: "#/components/schemas/BasePartner"
Expand All @@ -155,20 +155,20 @@ components:
UpdatePartner:
allOf:
- $ref: "#/components/schemas/BasePartner"
Partner:
Source:
allOf:
- $ref: "#/components/schemas/BasePartner"
- type: "object"
properties:
uid:
type: "string"
description: "Unique identifier for the partner."
description: "Unique identifier for the source."
members:
type: string
description: "Url to get all members of the partner."
reported_incidents:
description: "Url to get all members of the source."
reported_complaints:
type: string
description: "Url to get all incidents reported by the partner."
description: "Url to get all complaints reported by the source."
PartnerList:
allOf:
- $ref: '../common/pagination.yaml#/components/schemas/PaginatedResponse'
Expand All @@ -177,13 +177,13 @@ components:
results:
type: "array"
items:
$ref: "#/components/schemas/Partner"
$ref: "#/components/schemas/Source"
MemberBase:
type: "object"
properties:
partner_uid:
source_uid:
type: "string"
description: "Unique identifier for the partner."
description: "Unique identifier for the source."
user_uid:
type: "string"
description: "Unique identifier for the user."
Expand All @@ -210,15 +210,15 @@ components:
date_joined:
type: "string"
format: "date-time"
description: "Date the user joined the partner organizaation."
description: "Date the user joined the source organizaation."
AddMember:
allOf:
- $ref: "#/components/schemas/MemberBase"
- type: "object"
required:
- role
- user_uid
- partner_uid
- source_uid
MemberList:
allOf:
- $ref: '../common/pagination.yaml#/components/schemas/PaginatedResponse'
Expand Down
7 changes: 7 additions & 0 deletions oas/gen_pydantic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

python oas_to_pydantic.py 2.0/sources.yaml pydantic/sources.py
python oas_to_pydantic.py 2.0/complaints.yaml pydantic/complaints.py
python oas_to_pydantic.py 2.0/officers.yaml pydantic/officers.py
python oas_to_pydantic.py 2.0/agencies.yaml pydantic/agencies.py
python oas_to_pydantic.py 2.0/litigation.yaml pydantic/litigation.py
5 changes: 1 addition & 4 deletions oas/pydantic/agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


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


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


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


class Agency(BaseAgency, BaseModel):
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
name: Optional[str] = Field(None, description="Name of the agency")
hq_address: Optional[str] = Field(None, description="Address of the agency")
hq_city: Optional[str] = Field(None, description="City of the agency")
Expand All @@ -56,6 +52,7 @@ class Agency(BaseAgency, BaseModel):
phone: Optional[str] = Field(None, description="Phone number of the agency")
email: Optional[str] = Field(None, description="Email of the agency")
website_url: Optional[str] = Field(None, description="Website of the agency")
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
officers_url: Optional[str] = Field(None, description="URL to get a list of officers for this agency")
units_url: Optional[str] = Field(None, description="URL to get a list of units for this agency")

Expand Down
Loading

0 comments on commit 63506a4

Please sign in to comment.