{ "swagger": "2.0", "consumes": ["application/json"], "produces": ["application/json"], "info": { "version": "1.0", "title": "Pre-Sentence Service", "description": "Pre-Sentence Service API" }, "paths": { "/api/v1/report/{reportId}": { "get": { "tags": ["report"], "summary": "Get report", "description": "Returns a report based on report ID", "parameters": [ { "in": "path", "required": true, "type": "string", "format": "uuid", "name": "reportId", "description": "Report ID" } ], "responses": { "200": { "description": "Returns a report object", "schema": { "$ref": "#/components/schemas/report" } }, "404": { "description": "Report not found" }, "401": { "description": "Authorization error. See response body for more details." } } } }, "/api/v1/report/{reportId}/pdf": { "get": { "tags": ["report"], "summary": "Get report PDF file", "description": "Returns a PDF file based on report ID", "parameters": [ { "in": "path", "required": true, "type": "string", "format": "uuid", "name": "reportId", "description": "Report ID" } ], "produces": ["application/pdf"], "responses": { "200": { "description": "Returns a PDF file", "schema": { "type": "file" } }, "404": { "description": "Report not found" }, "401": { "description": "Authorization error. See response body for more details." } } } }, "/api/v1/report": { "post": { "tags": ["report"], "summary": "Create report", "description": "Creates a new pre-sentence report. Only requires the CRN (Case Reference Number). The report type defaults to 'short-format' and an event number is auto-generated.", "parameters": [ { "in": "body", "name": "body", "required": true, "description": "Report creation request containing the defendant's CRN", "schema": { "$ref": "#/components/schemas/createReport" } } ], "responses": { "201": { "description": "Report created successfully. Returns the report ID.", "schema": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "example": "babb539f-33c3-4948-9b87-946ad9c06a42", "description": "The unique identifier for the created report" } } } }, "400": { "description": "Bad request. CRN is required." }, "401": { "description": "Authorization error. Bearer token required." } } } } }, "components": { "schemas": { "createReport": { "type": "object", "required": ["crn"], "properties": { "crn": { "type": "string", "example": "DX12340A", "description": "Defendant CRN (Case Reference Number)" } }, "example": { "crn": "DX12340A" } }, "newReport": { "type": "object", "properties": { "reportDefinitionId": { "type": "integer", "example": 1 }, "eventNumber": { "type": "string", "example": "300" }, "id": { "type": "string", "format": "uuid", "example": "babb539f-33c3-4948-9b87-946ad9c06a42" }, "status": { "type": "string", "example": "NOT_STARTED" }, "urn": { "type": "string", "format": "urn", "example": "urn:uk:gov:hmpps:pre-sentence-service:report:babb539f-33c3-4948-9b87-946ad9c06a42" } } }, "report": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid", "description": "Report ID", "example": "d97277dd-1b0a-4853-b13b-8afed046bb8a" }, "status": { "type": "string", "example": "STARTED" }, "reportDefinitionId": { "type": "integer", "example": 1 }, "eventNumber": { "type": "string", "example": "42" }, "reportDefinition": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "type": { "type": "string", "example": "record-of-oral" }, "version": { "type": "integer", "example": 1 }, "fields": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "name" }, "required": { "type": "boolean", "example": true }, "validation": { "type": "string", "example": null } } }, "example": [ { "id": 1, "name": "name", "required": true, "validation": null }, { "id": 2, "name": "dateOfBirth", "required": true, "validation": null }, { "id": 3, "name": "crn", "required": true, "validation": null } ] } } }, "fieldValues": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "fieldId": { "type": "integer", "example": 1 }, "value": { "type": "string", "example": "Lenore Marquez" }, "version": { "type": "integer", "example": 1 }, "reportId": { "type": "string", "description": "Report ID as uuid", "example": "d97277dd-1b0a-4853-b13b-8afed046bb8a" }, "field": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "name" }, "required": { "type": "boolean", "example": true }, "validation": { "type": "string", "example": null } } } } }, "example": [ { "id": 1, "fieldId": 1, "value": "Lenore Marquez", "version": 1, "reportId": "d97277dd-1b0a-4853-b13b-8afed046bb8a", "field": { "id": 1, "name": "name", "required": true, "validation": null } }, { "id": 2, "fieldId": 2, "value": "18/08/1979", "version": 1, "reportId": "d97277dd-1b0a-4853-b13b-8afed046bb8a", "field": { "id": 2, "name": "dateOfBirth", "required": true, "validation": null } }, { "id": 3, "fieldId": 3, "value": "DX12340A", "version": 1, "reportId": "d97277dd-1b0a-4853-b13b-8afed046bb8a", "field": { "id": 3, "name": "crn", "required": true, "validation": null } } ] } } } } } }