Repository: api-cp-crime-caseadmin-case-document-knowledge
Purpose: This repository contains the OpenAPI specification, generated server/client stubs and test harness for the Case Documents AI Responses API — a service that accepts user queries about case documents (e.g., "Summary of witness statements"), ingests case materials, runs retrieval-augmented generation (RAG) and returns AI-generated answers with source citations and the original user question echoed back.
-
OpenAPI spec:
src/main/resources/openapi/case-admin-doc-knowledge-api.openapi.yml
-
Generated sources:
build/generated/src/main/java
(populated byopenApiGenerate
) -
Main Gradle tasks:
gradle openApiGenerate
— generate APIs & models from OpenAPIgradle clean build
— full buildgradle test
— run tests
This API exposes a small, focused set of endpoints to list queued queries and retrieve AI answers.
-
GET /queries
— list pipeline status and queuedqueries
.- Response:
QueryStatusResponse
withstatus
(UPLOADED | INGESTED | ANSWERS_AVAILABLE) and an array ofQuerySummary
(queryId
,userQuery
).
- Response:
-
GET /answers/{queryId}
— get the AI-generated answer for aqueryId
(also returns theuserQuery
).- Response:
AnswerResponse
with fields:queryId
,userQuery
,answer
,dateCreated
.
- Response:
-
POST /answers/{queryId}
— POST variant that returns the sameAnswerResponse
(supported for UI flexibility). -
GET /answers/{queryId}/integration
— integration/testing endpoint; returnsAnswerWithLlmResponse
(includesllmInput
used by the LLM). -
POST /answers/{queryId}/integration
— POST variant for the integration endpoint.
All path parameters are declared at the path level. Responses use JSON and timestamps use the format
YYYY-MM-DD HH:mm:ss
.
-
Spec file name:
case-qna-api.openapi.v1.yml
(undersrc/main/resources/openapi
). Keep this name — Gradle expects*.openapi.yml
. -
Generator configuration (recommended):
- Use OpenAPI Generator
spring
server template (seebuild.gradle
). configOptions
used in this repo intentionally setuseLombok=false
for generated models to avoid duplicate-constructor compilation errors (the generator emits explicit constructors).
- Use OpenAPI Generator
-
Avoid model name collisions: rename generic models like
Error
toApiError
in the spec if you see conflicts withjava.lang.Error
. -
Regenerate after editing the spec:
./gradlew clean openApiGenerate spotlessApply build
This project uses Spotless to format generated sources; spotlessApply
runs automatically before compileJava
.
- Build and generate sources
gradle clean openApiGenerate build
- Run tests
gradlew test
- If you hit Lombok/model constructor issues, see
build.gradle
config: ensure generated models are created without@AllArgsConstructor
/@NoArgsConstructor
annotations (this project disables Lombok on generated models).
List queries
curl -sS https://api.example.com/queries | jq '.'
Get answer (GET)
curl -sS https://api.example.com/answers/1c9d3a9a-1f1b-4a2a-9d7c-3f6b4b9d1f10 | jq '.'
Get answer (POST)
curl -sS -X POST https://api.example.com/answers/1c9d3a9a-1f1b-4a2a-9d7c-3f6b4b9d1f10 -H 'Content-Type: application/json' -d '{}' | jq '.'
Integration endpoint (GET)
curl -sS https://api.example.com/answers/1c9d3a9a-1f1b-4a2a-9d7c-3f6b4b9d1f10/integration | jq '.'
- The loader
OpenAPIConfigurationLoader
reads the YAML spec at runtime and exposes it as a Spring bean (if wired). Tests validate the expectedinfo
block and schema presence. - Tests in
src/test/java
include reflection-based checks for generated APIs and models, and example payload (de)serialization tests. - Keep
API_SPEC_VERSION
in Gradle or via-DAPI_SPEC_VERSION
during tests to control theinfo.version
used by the loader.
Follow the repository template conventions. See .github/CONTRIBUTING.md
for PR and branching rules. After creating a repository from this template, delete template-specific docs you don’t need (see repo root instructions).
This project is licensed under the MIT License. See LICENSE
for details.