Last active
December 5, 2022 18:39
-
-
Save tcfitzgerald/1a3dfafe3c4dd56be0280f30e7f15fa9 to your computer and use it in GitHub Desktop.
Revisions
-
tcfitzgerald revised this gist
Dec 5, 2022 . 1 changed file with 145 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -313,4 +313,148 @@ To retrieve a specific litigation case, you would send a GET request to the /cas GET /cases/123456 HTTP/1.1 ``` This would return the LitigationCase object with the caseNumber of 123456, if it exists. Can you update the OpenAPI spec to include a route for updating a case and deleting a case? Yes, here is an updated version of the OpenAPI specification that includes routes for updating and deleting a litigation case: ``` openapi: 3.0.0 info: title: LitigationCase API version: 1.0.0 paths: /cases: post: summary: Create a new litigation case requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LitigationCase' get: summary: Get a list of all litigation cases responses: '200': description: A list of litigation cases content: application/json: schema: type: array items: $ref: '#/components/schemas/LitigationCase' /cases/{caseNumber}: get: summary: Get a specific litigation case parameters: - in: path name: caseNumber schema: type: string required: true responses: '200': description: A specific litigation case content: application/json: schema: $ref: '#/components/schemas/LitigationCase' put: summary: Update a specific litigation case parameters: - in: path name: caseNumber schema: type: string required: true requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LitigationCase' delete: summary: Delete a specific litigation case parameters: - in: path name: caseNumber schema: type: string required: true responses: '204': description: The litigation case was successfully deleted components: schemas: LitigationCase: type: object required: - caseNumber - plaintiff - defendant - filingDate - status properties: caseNumber: type: string plaintiff: type: string defendant: type: string filingDate: type: string format: date status: type: string ``` In this updated version, the /cases/{caseNumber} path now includes PUT and DELETE endpoints for updating and deleting a specific litigation case. The PUT endpoint takes a JSON request body that conforms to the LitigationCase schema, and the DELETE endpoint returns a 204 No Content response if the case was successfully deleted. To update a specific litigation case, you would send a PUT request to the /cases/{caseNumber} endpoint, where {caseNumber} is the case number of the litigation case you want to update. The request body should contain the updated values for the case. For example: ``` PUT /cases/123456 HTTP/1.1 Content-Type: application/json { "caseNumber": "123456", "plaintiff": "Jane Doe", "defendant": "John ``` Can you finish your PUT example? Yes, here is the complete PUT example for updating a specific litigation case: ``` PUT /cases/123456 HTTP/1.1 Content-Type: application/json { "caseNumber": "123456", "plaintiff": "Jane Doe", "defendant": "John Doe", "filingDate": "2022-12-05", "status": "pending" } ``` This request would update the LitigationCase object with the caseNumber of 123456 with the new values specified in the request body. To delete a specific litigation case, you would send a DELETE request to the /cases/{caseNumber} endpoint, where {caseNumber} is the case number of the litigation case you want to delete. For example: ``` DELETE /cases/123456 HTTP/1.1 ``` This request would delete the LitigationCase object with the caseNumber of 123456, if it exists. If the deletion is successful, the API would return a 204 No Content response. -
tcfitzgerald revised this gist
Dec 5, 2022 . 1 changed file with 179 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -135,4 +135,182 @@ components: format: date status: type: string ``` Can you annotate the PHP code with the OpenAPI spec? Yes, here is an example of the LitigationCase class with annotations that match the OpenAPI 3.0 specification: ``` /** * @OA\Schema( * schema="LitigationCase", * type="object", * required={"caseNumber", "plaintiff", "defendant", "filingDate", "status"}, * @OA\Property( * property="caseNumber", * type="string" * ), * @OA\Property( * property="plaintiff", * type="string" * ), * @OA\Property( * property="defendant", * type="string" * ), * @OA\Property( * property="filingDate", * type="string", * format="date" * ), * @OA\Property( * property="status", * type="string" * ) * ) */ class LitigationCase { private $caseNumber; private $plaintiff; private $defendant; private $filingDate; private $status; public function __construct($caseNumber, $plaintiff, $defendant, $filingDate, $status) { $this->caseNumber = $caseNumber; $this->plaintiff = $plaintiff; $this->defendant = $defendant; $this->filingDate = $filingDate; $this->status = $status; } public function getCaseNumber() { return $this->caseNumber; } public function setCaseNumber($caseNumber) { $this->caseNumber = $caseNumber; } public function getPlaintiff() { return $this->plaintiff; } public function setPlaintiff($plaintiff) { $this->plaintiff = $plaintiff; } public function getDefendant() { return $this->defendant; } public function setDefendant($defendant) { $this->defendant = $defendant; } public function getFilingDate() { return $this->filingDate; } public function setFilingDate($filingDate) { $this->filingDate = $filingDate; } public function getStatus() { return $this->status; } public function setStatus($status) { $this->status = $status; } } ``` In this example, the @OA\Schema annotation is used to define the LitigationCase schema and its properties. The type and format of each property are specified using the @OA\Property annotation. These annotations allow tools like Swagger to generate documentation and other useful information based on the OpenAPI specification. Can you adjust the OpenAPI spec to include a route for viewing an individual case? Yes, here is an updated version of the OpenAPI specification that includes a route for viewing an individual litigation case: ``` openapi: 3.0.0 info: title: LitigationCase API version: 1.0.0 paths: /cases: post: summary: Create a new litigation case requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LitigationCase' get: summary: Get a list of all litigation cases responses: '200': description: A list of litigation cases content: application/json: schema: type: array items: $ref: '#/components/schemas/LitigationCase' /cases/{caseNumber}: get: summary: Get a specific litigation case parameters: - in: path name: caseNumber schema: type: string required: true responses: '200': description: A specific litigation case content: application/json: schema: $ref: '#/components/schemas/LitigationCase' components: schemas: LitigationCase: type: object required: - caseNumber - plaintiff - defendant - filingDate - status properties: caseNumber: type: string plaintiff: type: string defendant: type: string filingDate: type: string format: date status: type: string ``` In this updated version, a new /cases/{caseNumber} path is defined that allows you to retrieve a specific litigation case by its caseNumber. The caseNumber is defined as a path parameter using the @OA\Parameter annotation, and the LitigationCase schema is used to define the response. To retrieve a specific litigation case, you would send a GET request to the /cases/{caseNumber} endpoint, where {caseNumber} is the case number of the litigation case you want to retrieve. For example: ``` GET /cases/123456 HTTP/1.1 ``` This would return the LitigationCase object with the caseNumber of 123456, if it exists. -
tcfitzgerald renamed this gist
Dec 5, 2022 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ Write a php class for a litigation case. ``` class LitigationCase { private $caseNumber; private $plaintiff; @@ -55,11 +56,13 @@ class LitigationCase { $this->status = $status; } } ``` In this example, the LitigationCase class has five properties: caseNumber, plaintiff, defendant, filingDate, and status. Each property has a corresponding getter and setter method that allows you to access and modify the property value. To use this class, you would create a new instance of the LitigationCase class and set the property values using the setter methods, like this: ``` $case = new LitigationCase(); $case->setCaseNumber('123456'); $case->setPlaintiff('Jane Doe'); @@ -74,11 +77,13 @@ $plaintiff = $case->getPlaintiff(); $defendant = $case->getDefendant(); $filingDate = $case->getFilingDate(); $status = $case->getStatus(); ``` Can you create an OpenAPI 3.0 representation of this class? Yes, here is an example of an OpenAPI 3.0 representation of the LitigationCase class: ``` openapi: 3.0.0 info: @@ -130,3 +135,4 @@ components: format: date status: type: string ``` -
tcfitzgerald created this gist
Dec 5, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,132 @@ Write a php class for a litigation case. class LitigationCase { private $caseNumber; private $plaintiff; private $defendant; private $filingDate; private $status; public function __construct($caseNumber, $plaintiff, $defendant, $filingDate, $status) { $this->caseNumber = $caseNumber; $this->plaintiff = $plaintiff; $this->defendant = $defendant; $this->filingDate = $filingDate; $this->status = $status; } public function getCaseNumber() { return $this->caseNumber; } public function setCaseNumber($caseNumber) { $this->caseNumber = $caseNumber; } public function getPlaintiff() { return $this->plaintiff; } public function setPlaintiff($plaintiff) { $this->plaintiff = $plaintiff; } public function getDefendant() { return $this->defendant; } public function setDefendant($defendant) { $this->defendant = $defendant; } public function getFilingDate() { return $this->filingDate; } public function setFilingDate($filingDate) { $this->filingDate = $filingDate; } public function getStatus() { return $this->status; } public function setStatus($status) { $this->status = $status; } } In this example, the LitigationCase class has five properties: caseNumber, plaintiff, defendant, filingDate, and status. Each property has a corresponding getter and setter method that allows you to access and modify the property value. To use this class, you would create a new instance of the LitigationCase class and set the property values using the setter methods, like this: $case = new LitigationCase(); $case->setCaseNumber('123456'); $case->setPlaintiff('Jane Doe'); $case->setDefendant('John Doe'); $case->setFilingDate('2022-12-05'); $case->setStatus('pending'); You can then access the property values using the getter methods, like this: $caseNumber = $case->getCaseNumber(); $plaintiff = $case->getPlaintiff(); $defendant = $case->getDefendant(); $filingDate = $case->getFilingDate(); $status = $case->getStatus(); Can you create an OpenAPI 3.0 representation of this class? Yes, here is an example of an OpenAPI 3.0 representation of the LitigationCase class: openapi: 3.0.0 info: title: LitigationCase API version: 1.0.0 paths: /cases: post: summary: Create a new litigation case requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LitigationCase' get: summary: Get a list of all litigation cases responses: '200': description: A list of litigation cases content: application/json: schema: type: array items: $ref: '#/components/schemas/LitigationCase' components: schemas: LitigationCase: type: object required: - caseNumber - plaintiff - defendant - filingDate - status properties: caseNumber: type: string plaintiff: type: string defendant: type: string filingDate: type: string format: date status: type: string