Paperless / rebuild
Course 2 28ef273

openapi.yaml

docs/openapi.yaml

Snapshot 28ef273Download original
1openapi: 3.0.32info:3  title: Paperless REST API4  description: |5    Document Management System REST API for the SWEN3 Paperless project.6    Provides endpoints for:7    - Document Upload: file storage, automated OCR processing, full-text indexing, and GenAI summarization.8    - Document Search: full-text and fuzzy search.9    - Document Management: document lifecycle (details, metadata update, deletion, download) and metadata (document types).10    - User and Team Management: authentication (login, me), user management (User-MM), teams, and role-based memberships (User <-- m:n (role) --> Team; roles: ADMIN, READONLY, READ_WRITE).11  version: 1.0.012  x-api-id: d0184f38-b98d-11e7-9c56-68f728c1ba7013  x-audience: company-internal14  contact:15    name: Philip Duong & Patrick Hornek16  license:17    name: Apache 2.018    url: https://www.apache.org/licenses/LICENSE-2.0.html1920servers:21  - url: http://localhost:808022    description: Local Docker / Development Server2324security:25  - bearerAuth: []2627tags:28  - name: Auth29    description: User authentication and session management (login, me).30  - name: Users31    description: User management (User-MM) and user team memberships.32  - name: Teams33    description: Team management and role assignments (User <-- m:n (role) --> Team).34  - name: Documents35    description: |36      Private documents are visible only to their uploader. Team-shared documents are visible only to current team members; an uploader who is removed from the team loses access. READONLY members can read, search, and download; READ_WRITE and ADMIN members can also upload, edit, and delete team documents.37  - name: Search38    description: Full-text and fuzzy search across document content, titles, and summaries.39  - name: Document Types40    description: Document classifications (e.g., Invoice, Contract, Receipt, Bank Statement).4142paths:43  # ============================================================================44  # AUTH45  # ============================================================================46  /api/v1/auth/login:47    post:48      tags:49        - Auth50      summary: User login51      description: Authenticates a user with login credentials and returns an opaque bearer token and user profile.52      operationId: login53      security: []54      requestBody:55        required: true56        content:57          application/json:58            schema:59              $ref: '#/components/schemas/LoginRequest'60      responses:61        '200':62          description: Successfully authenticated.63          content:64            application/json:65              schema:66                $ref: '#/components/schemas/LoginResponse'67        '400':68          $ref: '#/components/responses/BadRequestError'69        '401':70          $ref: '#/components/responses/UnauthorizedError'71        '500':72          $ref: '#/components/responses/InternalServerError'7374  /api/v1/auth/me:75    get:76      tags:77        - Auth78      summary: Get current authenticated user79      description: Returns the user profile and team memberships for the currently authenticated user.80      operationId: getCurrentUser81      responses:82        '200':83          description: Current user profile retrieved successfully.84          content:85            application/json:86              schema:87                $ref: '#/components/schemas/UserResponse'88        '401':89          $ref: '#/components/responses/UnauthorizedError'90        '500':91          $ref: '#/components/responses/InternalServerError'9293  # ============================================================================94  # USERS (USER-MM)95  # ============================================================================96  /api/v1/users:97    get:98      tags:99        - Users100      summary: List all users101      description: Returns a list of all registered users in the application.102      operationId: getUsers103      responses:104        '200':105          description: List of users retrieved successfully.106          content:107            application/json:108              schema:109                $ref: '#/components/schemas/UserListResponse'110        '401':111          $ref: '#/components/responses/UnauthorizedError'112        '500':113          $ref: '#/components/responses/InternalServerError'114115    post:116      tags:117        - Users118      summary: Create a new user119      description: Public endpoint to create/register a new user account (User-MM). Usernames must be unique; registration with an existing username returns 409.120      operationId: createUser121      security: []122      requestBody:123        required: true124        content:125          application/json:126            schema:127              $ref: '#/components/schemas/CreateUserRequest'128      responses:129        '201':130          description: User created successfully.131          headers:132            Location:133              description: URI of the newly created user resource.134              schema:135                type: string136                format: uri137                example: "/api/v1/users/550e8400-e29b-41d4-a716-446655440000"138          content:139            application/json:140              schema:141                $ref: '#/components/schemas/UserResponse'142        '400':143          $ref: '#/components/responses/BadRequestError'144        '409':145          $ref: '#/components/responses/ConflictError'146        '500':147          $ref: '#/components/responses/InternalServerError'148149  /api/v1/users/{id}:150    get:151      tags:152        - Users153      summary: Get user by ID154      description: Returns user profile by ID.155      operationId: getUserById156      parameters:157        - $ref: '#/components/parameters/PathId'158      responses:159        '200':160          description: User retrieved successfully.161          content:162            application/json:163              schema:164                $ref: '#/components/schemas/UserResponse'165        '401':166          $ref: '#/components/responses/UnauthorizedError'167        '404':168          $ref: '#/components/responses/NotFoundError'169        '500':170          $ref: '#/components/responses/InternalServerError'171172    put:173      tags:174        - Users175      summary: Update user176      description: Updates only the authenticated user's own profile; updating another user's account is forbidden. A supplied username must be unique across accounts; an already-used username returns 409 Conflict.177      operationId: updateUser178      parameters:179        - $ref: '#/components/parameters/PathId'180      requestBody:181        required: true182        content:183          application/json:184            schema:185              $ref: '#/components/schemas/UpdateUserRequest'186      responses:187        '200':188          description: User updated successfully.189          content:190            application/json:191              schema:192                $ref: '#/components/schemas/UserResponse'193        '400':194          $ref: '#/components/responses/BadRequestError'195        '401':196          $ref: '#/components/responses/UnauthorizedError'197        '403':198          $ref: '#/components/responses/ForbiddenError'199        '404':200          $ref: '#/components/responses/NotFoundError'201        '409':202          $ref: '#/components/responses/ConflictError'203        '500':204          $ref: '#/components/responses/InternalServerError'205206    delete:207      tags:208        - Users209      summary: Delete user210      description: Deletes only the authenticated user's own account; deleting another user's account is forbidden.211      operationId: deleteUser212      parameters:213        - $ref: '#/components/parameters/PathId'214      responses:215        '204':216          description: User deleted successfully.217        '401':218          $ref: '#/components/responses/UnauthorizedError'219        '403':220          $ref: '#/components/responses/ForbiddenError'221        '404':222          $ref: '#/components/responses/NotFoundError'223        '409':224          $ref: '#/components/responses/ConflictError'225        '500':226          $ref: '#/components/responses/InternalServerError'227228  /api/v1/users/{id}/teams:229    get:230      tags:231        - Users232      summary: Get teams and roles for user233      description: Returns the authenticated user's teams and roles; requesting memberships for another user is forbidden.234      operationId: getUserTeams235      parameters:236        - $ref: '#/components/parameters/PathId'237      responses:238        '200':239          description: User team memberships and roles.240          content:241            application/json:242              schema:243                $ref: '#/components/schemas/UserTeamMembershipListResponse'244        '401':245          $ref: '#/components/responses/UnauthorizedError'246        '403':247          $ref: '#/components/responses/ForbiddenError'248        '404':249          $ref: '#/components/responses/NotFoundError'250        '500':251          $ref: '#/components/responses/InternalServerError'252253  # ============================================================================254  # TEAMS & ROLES (User <-- m:n (role) --> Team)255  # ============================================================================256  /api/v1/teams:257    get:258      tags:259        - Teams260      summary: List all teams261      description: Returns only teams the authenticated user belongs to; the list is empty when the user has no team memberships.262      operationId: getTeams263      responses:264        '200':265          description: List of teams retrieved successfully; may be empty when the user has no memberships.266          content:267            application/json:268              schema:269                $ref: '#/components/schemas/TeamListResponse'270        '401':271          $ref: '#/components/responses/UnauthorizedError'272        '500':273          $ref: '#/components/responses/InternalServerError'274275    post:276      tags:277        - Teams278      summary: Create a new team279      description: Creates a new team; the authenticated creator becomes its immutable owner.280      operationId: createTeam281      requestBody:282        required: true283        content:284          application/json:285            schema:286              $ref: '#/components/schemas/CreateTeamRequest'287      responses:288        '201':289          description: Team created successfully.290          headers:291            Location:292              description: URI of the newly created team resource.293              schema:294                type: string295                format: uri296                example: "/api/v1/teams/550e8400-e29b-41d4-a716-446655440001"297          content:298            application/json:299              schema:300                $ref: '#/components/schemas/TeamResponse'301        '400':302          $ref: '#/components/responses/BadRequestError'303        '401':304          $ref: '#/components/responses/UnauthorizedError'305        '409':306          $ref: '#/components/responses/ConflictError'307        '500':308          $ref: '#/components/responses/InternalServerError'309310  /api/v1/teams/{id}:311    get:312      tags:313        - Teams314      summary: Get team by ID315      description: Returns details of a specific team; the authenticated user must be a member of the team.316      operationId: getTeamById317      parameters:318        - $ref: '#/components/parameters/PathId'319      responses:320        '200':321          description: Team retrieved successfully.322          content:323            application/json:324              schema:325                $ref: '#/components/schemas/TeamResponse'326        '401':327          $ref: '#/components/responses/UnauthorizedError'328        '403':329          $ref: '#/components/responses/ForbiddenError'330        '404':331          $ref: '#/components/responses/NotFoundError'332        '500':333          $ref: '#/components/responses/InternalServerError'334335    put:336      tags:337        - Teams338      summary: Update a team339      description: Updates a team's name and description only when the authenticated user is an ADMIN member of that team.340      operationId: updateTeam341      parameters:342        - $ref: '#/components/parameters/PathId'343      requestBody:344        required: true345        content:346          application/json:347            schema:348              $ref: '#/components/schemas/UpdateTeamRequest'349      responses:350        '200':351          description: Team updated successfully.352          content:353            application/json:354              schema:355                $ref: '#/components/schemas/TeamResponse'356        '400':357          $ref: '#/components/responses/BadRequestError'358        '401':359          $ref: '#/components/responses/UnauthorizedError'360        '403':361          $ref: '#/components/responses/ForbiddenError'362        '404':363          $ref: '#/components/responses/NotFoundError'364        '409':365          $ref: '#/components/responses/ConflictError'366        '500':367          $ref: '#/components/responses/InternalServerError'368369    delete:370      tags:371        - Teams372      summary: Delete a team373      description: Deletes a team and its memberships only when the authenticated user is the team owner; the owner cannot be removed from the team.374      operationId: deleteTeam375      parameters:376        - $ref: '#/components/parameters/PathId'377      responses:378        '204':379          description: Team deleted successfully.380        '401':381          $ref: '#/components/responses/UnauthorizedError'382        '403':383          $ref: '#/components/responses/ForbiddenError'384        '404':385          $ref: '#/components/responses/NotFoundError'386        '409':387          $ref: '#/components/responses/ConflictError'388        '500':389          $ref: '#/components/responses/InternalServerError'390391  /api/v1/teams/{id}/members:392    get:393      tags:394        - Teams395      summary: List team members and their roles396      description: Returns all users belonging to this team and their roles (ADMIN, READONLY, READ_WRITE); the authenticated user must be a member of the team.397      operationId: getTeamMembers398      parameters:399        - $ref: '#/components/parameters/PathId'400      responses:401        '200':402          description: List of team members and roles.403          content:404            application/json:405              schema:406                $ref: '#/components/schemas/TeamMemberListResponse'407        '401':408          $ref: '#/components/responses/UnauthorizedError'409        '403':410          $ref: '#/components/responses/ForbiddenError'411        '404':412          $ref: '#/components/responses/NotFoundError'413        '500':414          $ref: '#/components/responses/InternalServerError'415416    post:417      tags:418        - Teams419      summary: Add a member to a team with a role420      description: "Assigns a user to the specified team with an explicit role (ADMIN, READONLY, or READ_WRITE); the caller must be an ADMIN member of that team."421      operationId: addTeamMember422      parameters:423        - $ref: '#/components/parameters/PathId'424      requestBody:425        required: true426        content:427          application/json:428            schema:429              $ref: '#/components/schemas/AddTeamMemberRequest'430      responses:431        '201':432          description: Member added to team successfully.433          content:434            application/json:435              schema:436                $ref: '#/components/schemas/TeamMemberResponse'437        '400':438          $ref: '#/components/responses/BadRequestError'439        '401':440          $ref: '#/components/responses/UnauthorizedError'441        '403':442          $ref: '#/components/responses/ForbiddenError'443        '404':444          $ref: '#/components/responses/NotFoundError'445        '409':446          $ref: '#/components/responses/ConflictError'447        '500':448          $ref: '#/components/responses/InternalServerError'449450  /api/v1/teams/{id}/members/{user_id}:451    put:452      tags:453        - Teams454      summary: Update a team member's role455      description: Updates a user's role in the specified team (ADMIN, READONLY, or READ_WRITE); the caller must be an ADMIN member of that team and cannot change the owner's membership.456      operationId: updateTeamMemberRole457      parameters:458        - $ref: '#/components/parameters/PathId'459        - name: user_id460          in: path461          description: Unique identifier of the user.462          required: true463          schema:464            type: string465            format: uuid466            example: "550e8400-e29b-41d4-a716-446655440000"467      requestBody:468        required: true469        content:470          application/json:471            schema:472              $ref: '#/components/schemas/UpdateTeamMemberRoleRequest'473      responses:474        '200':475          description: Member role updated successfully.476          content:477            application/json:478              schema:479                $ref: '#/components/schemas/TeamMemberResponse'480        '400':481          $ref: '#/components/responses/BadRequestError'482        '401':483          $ref: '#/components/responses/UnauthorizedError'484        '403':485          $ref: '#/components/responses/ForbiddenError'486        '404':487          $ref: '#/components/responses/NotFoundError'488        '500':489          $ref: '#/components/responses/InternalServerError'490491    delete:492      tags:493        - Teams494      summary: Remove a member from a team495      description: Removes a user's membership from the specified team; the caller must be an ADMIN member of that team and cannot remove the owner.496      operationId: removeTeamMember497      parameters:498        - $ref: '#/components/parameters/PathId'499        - name: user_id500          in: path501          description: Unique identifier of the user to remove.502          required: true503          schema:504            type: string505            format: uuid506            example: "550e8400-e29b-41d4-a716-446655440000"507      responses:508        '204':509          description: Member removed from team successfully.510        '401':511          $ref: '#/components/responses/UnauthorizedError'512        '403':513          $ref: '#/components/responses/ForbiddenError'514        '404':515          $ref: '#/components/responses/NotFoundError'516        '500':517          $ref: '#/components/responses/InternalServerError'518519  # ============================================================================520  # DOCUMENTS521  # ============================================================================522  /api/v1/documents:523    get:524      tags:525        - Documents526      summary: Search and list documents527      description: Returns a paginated list of documents visible to the authenticated user, with optional metadata filtering.528      operationId: searchDocuments529      parameters:530        - name: page531          in: query532          description: Zero-based page index.533          required: false534          schema:535            type: integer536            default: 0537            minimum: 0538        - name: size539          in: query540          description: The size of the page to be returned.541          required: false542          schema:543            type: integer544            default: 10545            minimum: 1546            maximum: 100547        - name: sort548          in: query549          description: Sorting criteria in the format property,(asc|desc).550          required: false551          schema:552            type: string553            default: created_at,desc554        - name: document_type_id555          in: query556          description: Filter by Document Type ID.557          required: false558          schema:559            type: string560            format: uuid561      responses:562        '200':563          description: Successfully retrieved paged documents.564          content:565            application/json:566              schema:567                $ref: '#/components/schemas/DocumentPageResponse'568        '400':569          $ref: '#/components/responses/BadRequestError'570        '401':571          $ref: '#/components/responses/UnauthorizedError'572        '500':573          $ref: '#/components/responses/InternalServerError'574575    post:576      tags:577        - Documents578      summary: Upload a new document579      description: |580        Uploads a PDF document to file storage (MinIO). If team_id is absent, the document is private and visible only to its uploader. Sharing with a team requires current READ_WRITE or ADMIN membership in that team; insufficient access returns 403 and a nonexistent team returns 404.581        Automatically triggers asynchronous processing:582        - Performs OCR recognition to extract document text.583        - Automatically indexes extracted text for full-text search.584        - Automatically generates an AI summary using Google Gemini.585      operationId: uploadDocument586      requestBody:587        required: true588        content:589          multipart/form-data:590            schema:591              type: object592              required:593                - document594                - title595              properties:596                document:597                  type: string598                  format: binary599                  description: The binary PDF document file.600                title:601                  type: string602                  description: Required nonblank title for the uploaded document.603                  example: Electricity Invoice October 2026604                  minLength: 1605                  maxLength: 255606                document_type_id:607                  type: string608                  format: uuid609                  nullable: true610                  example: "550e8400-e29b-41d4-a716-446655440004"611                team_id:612                  type: string613                  format: uuid614                  description: Optional team to share the document with; omit to keep it private. The uploader must have READ_WRITE or ADMIN access to the team.615                  example: "550e8400-e29b-41d4-a716-446655440001"616      responses:617        '201':618          description: Document successfully uploaded and queued for processing.619          headers:620            Location:621              description: URI of the newly uploaded document resource.622              schema:623                type: string624                format: uri625                example: "/api/v1/documents/550e8400-e29b-41d4-a716-446655440002"626          content:627            application/json:628              schema:629                $ref: '#/components/schemas/DocumentResponse'630        '400':631          $ref: '#/components/responses/BadRequestError'632        '401':633          $ref: '#/components/responses/UnauthorizedError'634        '403':635          $ref: '#/components/responses/ForbiddenError'636        '404':637          $ref: '#/components/responses/NotFoundError'638        '500':639          $ref: '#/components/responses/InternalServerError'640641  /api/v1/documents/{id}:642    get:643      tags:644        - Documents645      summary: Get document details by ID646      description: Returns full document metadata only when the authenticated user can access it; private documents are uploader-only and team documents are visible only to current members. A removed uploader loses access and receives 404.647      operationId: getDocumentById648      parameters:649        - $ref: '#/components/parameters/PathId'650      responses:651        '200':652          description: Document details retrieved successfully.653          content:654            application/json:655              schema:656                $ref: '#/components/schemas/DocumentResponse'657        '401':658          $ref: '#/components/responses/UnauthorizedError'659        '404':660          $ref: '#/components/responses/NotFoundError'661        '500':662          $ref: '#/components/responses/InternalServerError'663664    put:665      tags:666        - Documents667      summary: Update document metadata668      description: |669        Any current writer may update document metadata (title and document type). Changing team_id or clearing team sharing is restricted to the uploader. Moving to another team requires write access to both the current source and destination teams; making the document private requires write access to the current source team. Omitting team_id or setting it to null does not clear sharing; set clear_team to true without team_id to make the document private. Supplying team_id together with clear_team: true is invalid and returns 400. A missing or inaccessible document, or a nonexistent destination team, returns 404; insufficient permission returns 403. A team-sharing transition that conflicts with the document's current sharing state returns 409.670      operationId: updateDocumentMetadata671      parameters:672        - $ref: '#/components/parameters/PathId'673      requestBody:674        required: true675        content:676          application/json:677            schema:678              $ref: '#/components/schemas/UpdateDocumentRequest'679      responses:680        '200':681          description: Document updated successfully.682          content:683            application/json:684              schema:685                $ref: '#/components/schemas/DocumentResponse'686        '400':687          $ref: '#/components/responses/BadRequestError'688        '401':689          $ref: '#/components/responses/UnauthorizedError'690        '403':691          $ref: '#/components/responses/ForbiddenError'692        '404':693          $ref: '#/components/responses/NotFoundError'694        '409':695          $ref: '#/components/responses/ConflictError'696        '500':697          $ref: '#/components/responses/InternalServerError'698699    delete:700      tags:701        - Documents702      summary: Delete a document703      description: Deletes a document record, file from MinIO, and search index entry; only the private uploader or a current READ_WRITE/ADMIN team member may delete it. Insufficient write access returns 403; a missing or inaccessible document returns 404.704      operationId: deleteDocument705      parameters:706        - $ref: '#/components/parameters/PathId'707      responses:708        '204':709          description: Document successfully deleted.710        '401':711          $ref: '#/components/responses/UnauthorizedError'712        '403':713          $ref: '#/components/responses/ForbiddenError'714        '404':715          $ref: '#/components/responses/NotFoundError'716        '409':717          $ref: '#/components/responses/ConflictError'718        '500':719          $ref: '#/components/responses/InternalServerError'720721  /api/v1/documents/{id}/download:722    get:723      tags:724        - Documents725      summary: Download original document file726      description: Streams the original uploaded PDF file from object storage (MinIO) when the authenticated user can access the document; private documents are uploader-only and team documents are visible only to current members. A missing or inaccessible document returns 404.727      operationId: downloadDocumentFile728      parameters:729        - $ref: '#/components/parameters/PathId'730      responses:731        '200':732          description: Binary PDF file content.733          content:734            application/pdf:735              schema:736                type: string737                format: binary738            application/octet-stream:739              schema:740                type: string741                format: binary742        '401':743          $ref: '#/components/responses/UnauthorizedError'744        '404':745          $ref: '#/components/responses/NotFoundError'746        '500':747          $ref: '#/components/responses/InternalServerError'748749  # ============================================================================750  # SEARCH751  # ============================================================================752  /api/v1/search:753    get:754      tags:755        - Search756      summary: Full-text and fuzzy search across documents757      description: Performs full-text and fuzzy queries against OCR extracted text, titles, and summaries; results include only documents visible to the authenticated user. READONLY, READ_WRITE, and ADMIN members can search team documents.758      operationId: searchDocumentsFullText759      parameters:760        - name: query761          in: query762          description: Text search query or keywords.763          required: true764          schema:765            type: string766            example: "invoice electric"767        - name: fuzzy768          in: query769          description: Enable fuzzy typo tolerance matching.770          required: false771          schema:772            type: boolean773            default: true774        - name: page775          in: query776          description: Zero-based page index.777          required: false778          schema:779            type: integer780            default: 0781            minimum: 0782        - name: size783          in: query784          description: Page size.785          required: false786          schema:787            type: integer788            default: 10789            minimum: 1790            maximum: 100791      responses:792        '200':793          description: Search results returned successfully with highlights and relevance scores.794          content:795            application/json:796              schema:797                $ref: '#/components/schemas/SearchResponse'798        '400':799          $ref: '#/components/responses/BadRequestError'800        '401':801          $ref: '#/components/responses/UnauthorizedError'802        '500':803          $ref: '#/components/responses/InternalServerError'804805  # ============================================================================806  # DOCUMENT TYPES (DOCUMENT METADATA)807  # ============================================================================808  /api/v1/document-types:809    get:810      tags:811        - Document Types812      summary: List all document types813      operationId: searchDocumentTypes814      responses:815        '200':816          description: List of document types.817          content:818            application/json:819              schema:820                $ref: '#/components/schemas/DocumentTypeListResponse'821        '401':822          $ref: '#/components/responses/UnauthorizedError'823        '500':824          $ref: '#/components/responses/InternalServerError'825826    post:827      tags:828        - Document Types829      summary: Create a new document type830      operationId: createDocumentType831      requestBody:832        required: true833        content:834          application/json:835            schema:836              $ref: '#/components/schemas/CreateDocumentTypeRequest'837      responses:838        '201':839          description: Document type created successfully.840          headers:841            Location:842              description: URI of the newly created document type resource.843              schema:844                type: string845                format: uri846                example: "/api/v1/document-types/550e8400-e29b-41d4-a716-446655440004"847          content:848            application/json:849              schema:850                $ref: '#/components/schemas/DocumentTypeResponse'851        '400':852          $ref: '#/components/responses/BadRequestError'853        '401':854          $ref: '#/components/responses/UnauthorizedError'855        '409':856          $ref: '#/components/responses/ConflictError'857        '500':858          $ref: '#/components/responses/InternalServerError'859860  /api/v1/document-types/{id}:861    get:862      tags:863        - Document Types864      summary: Get document type by ID865      operationId: getDocumentTypeById866      parameters:867        - $ref: '#/components/parameters/PathId'868      responses:869        '200':870          description: Document type retrieved successfully.871          content:872            application/json:873              schema:874                $ref: '#/components/schemas/DocumentTypeResponse'875        '401':876          $ref: '#/components/responses/UnauthorizedError'877        '404':878          $ref: '#/components/responses/NotFoundError'879        '500':880          $ref: '#/components/responses/InternalServerError'881882    put:883      tags:884        - Document Types885      summary: Update a document type886      operationId: updateDocumentType887      parameters:888        - $ref: '#/components/parameters/PathId'889      requestBody:890        required: true891        content:892          application/json:893            schema:894              $ref: '#/components/schemas/UpdateDocumentTypeRequest'895      responses:896        '200':897          description: Document type updated successfully.898          content:899            application/json:900              schema:901                $ref: '#/components/schemas/DocumentTypeResponse'902        '400':903          $ref: '#/components/responses/BadRequestError'904        '401':905          $ref: '#/components/responses/UnauthorizedError'906        '404':907          $ref: '#/components/responses/NotFoundError'908        '500':909          $ref: '#/components/responses/InternalServerError'910911    delete:912      tags:913        - Document Types914      summary: Delete a document type915      operationId: deleteDocumentType916      parameters:917        - $ref: '#/components/parameters/PathId'918      responses:919        '204':920          description: Document type deleted successfully.921        '401':922          $ref: '#/components/responses/UnauthorizedError'923        '404':924          $ref: '#/components/responses/NotFoundError'925        '500':926          $ref: '#/components/responses/InternalServerError'927928# ==============================================================================929# COMPONENTS & SCHEMAS930# ==============================================================================931components:932  securitySchemes:933    bearerAuth:934      type: http935      scheme: bearer936      bearerFormat: opaque937      description: Standard Authorization Bearer header using an opaque access token.938939  parameters:940    PathId:941      name: id942      in: path943      description: Unique identifier of the resource.944      required: true945      schema:946        type: string947        format: uuid948949  schemas:950    # --- Page Metadata Envelope ---951    PageMetadata:952      type: object953      required:954        - page955        - size956        - total_elements957        - total_pages958      properties:959        page:960          type: integer961          example: 0962        size:963          type: integer964          example: 10965        total_elements:966          type: integer967          format: int64968          example: 25969        total_pages:970          type: integer971          example: 3972973    # --- Role Enum ---974    Role:975      type: string976      description: |-977        READONLY can read, search, view, and download team documents.978        READ_WRITE can also upload, edit, and delete team documents.979        ADMIN has READ_WRITE permissions and additionally manages team memberships; the owner cannot be removed.980      enum:981        - ADMIN982        - READONLY983        - READ_WRITE984      example: ADMIN985986    # --- User Schemas (User-MM & Login) ---987    UserResponse:988      type: object989      required:990        - id991        - username992        - created_at993      properties:994        id:995          type: string996          format: uuid997          example: "550e8400-e29b-41d4-a716-446655440000"998        username:999          type: string1000          description: Unique username that the account owner may change to another unused username.1001          example: john_doe1002        created_at:1003          type: string1004          format: date-time1005          example: "2026-10-15T14:30:00Z"1006        updated_at:1007          type: string1008          format: date-time1009          example: "2026-10-15T14:32:10Z"10101011    UserListResponse:1012      type: object1013      required:1014        - items1015      properties:1016        items:1017          type: array1018          items:1019            $ref: '#/components/schemas/UserResponse'10201021    CreateUserRequest:1022      type: object1023      required:1024        - username1025        - password1026      properties:1027        username:1028          type: string1029          description: Required unique username of at least 4 characters; usernames may later be changed by the account owner to another unused username.1030          minLength: 41031          maxLength: 501032          example: john_doe1033        password:1034          type: string1035          description: Raw password of at least 8 characters.1036          format: password1037          minLength: 81038          maxLength: 1001039          example: "SecretP@ss123"10401041    UpdateUserRequest:1042      type: object1043      properties:1044        username:1045          type: string1046          description: Optional new username of at least 4 characters; it must be unique across accounts or the update returns 409 Conflict.1047          minLength: 41048          maxLength: 501049          example: john_doe1050        password:1051          type: string1052          description: Optional new raw password of at least 8 characters; omit to leave the current password unchanged.1053          format: password1054          minLength: 81055          maxLength: 1001056          example: "NewSecretP@ss123"10571058    LoginRequest:1059      type: object1060      required:1061        - username1062        - password1063      properties:1064        username:1065          type: string1066          example: john_doe1067        password:1068          type: string1069          format: password1070          example: "SecretP@ss123"10711072    LoginResponse:1073      type: object1074      required:1075        - token1076        - token_type1077        - user1078      properties:1079        token:1080          type: string1081          description: Opaque access token used as the bearer credential.1082          example: "opaque-access-token"1083        token_type:1084          type: string1085          example: Bearer1086        user:1087          $ref: '#/components/schemas/UserResponse'10881089    # --- Team Schemas (User <-- m:n (role) --> Team) ---1090    TeamResponse:1091      type: object1092      required:1093        - id1094        - name1095        - owner_id1096        - created_at1097      properties:1098        id:1099          type: string1100          format: uuid1101          example: "550e8400-e29b-41d4-a716-446655440001"1102        name:1103          type: string1104          example: Accounting1105        owner_id:1106          type: string1107          format: uuid1108          description: User ID of the team creator and immutable owner.1109          example: "550e8400-e29b-41d4-a716-446655440000"1110        description:1111          type: string1112          nullable: true1113          example: Handles invoices and bills1114        created_at:1115          type: string1116          format: date-time1117          example: "2026-10-15T14:30:00Z"1118        updated_at:1119          type: string1120          format: date-time1121          example: "2026-10-15T14:32:10Z"11221123    TeamListResponse:1124      type: object1125      required:1126        - items1127      properties:1128        items:1129          type: array1130          items:1131            $ref: '#/components/schemas/TeamResponse'11321133    CreateTeamRequest:1134      type: object1135      required:1136        - name1137      properties:1138        name:1139          type: string1140          description: Required nonblank team name.1141          minLength: 11142          maxLength: 1001143          example: Accounting1144        description:1145          type: string1146          nullable: true1147          maxLength: 2551148          example: Handles invoices and bills11491150    UpdateTeamRequest:1151      type: object1152      properties:1153        name:1154          type: string1155          description: Optional nonblank replacement team name.1156          minLength: 11157          maxLength: 1001158          example: Finance & Accounting1159        description:1160          type: string1161          nullable: true1162          maxLength: 2551163          example: Handles financial documents11641165    TeamMemberResponse:1166      type: object1167      required:1168        - user1169        - role1170      properties:1171        user:1172          $ref: '#/components/schemas/UserResponse'1173        role:1174          $ref: '#/components/schemas/Role'1175        joined_at:1176          type: string1177          format: date-time1178          example: "2026-10-15T14:30:00Z"11791180    TeamMemberListResponse:1181      type: object1182      required:1183        - items1184      properties:1185        items:1186          type: array1187          items:1188            $ref: '#/components/schemas/TeamMemberResponse'11891190    AddTeamMemberRequest:1191      type: object1192      required:1193        - user_id1194        - role1195      properties:1196        user_id:1197          type: string1198          format: uuid1199          example: "550e8400-e29b-41d4-a716-446655440000"1200        role:1201          $ref: '#/components/schemas/Role'12021203    UpdateTeamMemberRoleRequest:1204      type: object1205      required:1206        - role1207      properties:1208        role:1209          $ref: '#/components/schemas/Role'12101211    UserTeamMembershipResponse:1212      type: object1213      required:1214        - team1215        - role1216      properties:1217        team:1218          $ref: '#/components/schemas/TeamResponse'1219        role:1220          $ref: '#/components/schemas/Role'12211222    UserTeamMembershipListResponse:1223      type: object1224      required:1225        - items1226      properties:1227        items:1228          type: array1229          items:1230            $ref: '#/components/schemas/UserTeamMembershipResponse'12311232    # --- Document Schemas ---1233    ProcessingStatus:1234      type: string1235      enum:1236        - PENDING1237        - OCR_IN_PROGRESS1238        - GENAI_IN_PROGRESS1239        - COMPLETED1240        - FAILED1241      example: COMPLETED12421243    DocumentResponse:1244      type: object1245      required:1246        - id1247        - owner_id1248        - title1249        - original_filename1250        - content_type1251        - file_size1252        - status1253        - created_at1254        - updated_at1255      properties:1256        id:1257          type: string1258          format: uuid1259          example: "550e8400-e29b-41d4-a716-446655440002"1260        owner_id:1261          type: string1262          format: uuid1263          readOnly: true1264          description: User ID of the document uploader and owner.1265          example: "550e8400-e29b-41d4-a716-446655440000"1266        team_id:1267          type: string1268          format: uuid1269          nullable: true1270          description: ID of the team currently sharing this document; null when private.1271          example: "550e8400-e29b-41d4-a716-446655440001"1272        title:1273          type: string1274          example: Electricity Invoice October 20261275        original_filename:1276          type: string1277          example: invoice_oct_2026.pdf1278        content_type:1279          type: string1280          example: application/pdf1281        file_size:1282          type: integer1283          format: int641284          description: Size in bytes.1285          example: 2457601286        status:1287          $ref: '#/components/schemas/ProcessingStatus'1288        ocr_content:1289          type: string1290          nullable: true1291          description: Extracted text from OCR worker.1292          example: "INVOICE #9821\nAmount Due: 142.50 EUR\nDate: 2026-10-01"1293        summary:1294          type: string1295          nullable: true1296          description: AI summary generated by Google Gemini worker.1297          example: "Monthly utility invoice for electricity services totaling 142.50 EUR due by end of month."1298        storage_key:1299          type: string1300          description: Object key in MinIO.1301          example: "documents/2026/10/1_invoice_oct_2026.pdf"1302        document_type:1303          $ref: '#/components/schemas/DocumentTypeResponse'1304          nullable: true1305        created_at:1306          type: string1307          format: date-time1308          example: "2026-10-15T14:30:00Z"1309        updated_at:1310          type: string1311          format: date-time1312          example: "2026-10-15T14:32:10Z"13131314    DocumentPageResponse:1315      type: object1316      required:1317        - pagination1318        - items1319      properties:1320        pagination:1321          $ref: '#/components/schemas/PageMetadata'1322        items:1323          type: array1324          items:1325            $ref: '#/components/schemas/DocumentResponse'13261327    UpdateDocumentRequest:1328      type: object1329      properties:1330        team_id:1331          type: string1332          format: uuid1333          nullable: true1334          description: Destination team ID. Omitting this field or setting it to null leaves current sharing unchanged; null alone does not make the document private.1335          example: "550e8400-e29b-41d4-a716-446655440001"1336        clear_team:1337          type: boolean1338          default: false1339          description: Set true without team_id to remove team sharing and make the document private.1340        title:1341          type: string1342          description: Optional nonblank replacement document title.1343          minLength: 11344          maxLength: 2551345          example: "Updated Invoice Title"1346        document_type_id:1347          type: string1348          format: uuid1349          nullable: true1350          example: "550e8400-e29b-41d4-a716-446655440004"13511352    # --- Search Result Schemas ---1353    SearchResultItem:1354      type: object1355      required:1356        - document1357        - score1358      properties:1359        document:1360          $ref: '#/components/schemas/DocumentResponse'1361        score:1362          type: number1363          format: float1364          description: Relevance matching score.1365          example: 3.8421366        highlights:1367          type: array1368          items:1369            type: string1370          description: Snippets matching search terms with <em> highlights.1371          example:1372            - "Electricity <em>Invoice</em> for October 2026"1373            - "Total <em>amount</em> due: 142.50 EUR"13741375    SearchResponse:1376      type: object1377      required:1378        - pagination1379        - items1380      properties:1381        pagination:1382          $ref: '#/components/schemas/PageMetadata'1383        items:1384          type: array1385          items:1386            $ref: '#/components/schemas/SearchResultItem'13871388    # --- Document Type Schemas ---1389    DocumentTypeResponse:1390      type: object1391      required:1392        - id1393        - name1394      properties:1395        id:1396          type: string1397          format: uuid1398          example: "550e8400-e29b-41d4-a716-446655440004"1399        name:1400          type: string1401          example: Invoice1402        description:1403          type: string1404          nullable: true1405          example: Billing and payment invoices14061407    DocumentTypeListResponse:1408      type: object1409      required:1410        - items1411      properties:1412        items:1413          type: array1414          items:1415            $ref: '#/components/schemas/DocumentTypeResponse'14161417    CreateDocumentTypeRequest:1418      type: object1419      required:1420        - name1421      properties:1422        name:1423          type: string1424          description: Required nonblank document type name.1425          minLength: 11426          maxLength: 1001427          example: Contract1428        description:1429          type: string1430          nullable: true1431          example: Employment, tenancy, and service contracts14321433    UpdateDocumentTypeRequest:1434      type: object1435      properties:1436        name:1437          type: string1438          description: Optional nonblank replacement document type name.1439          minLength: 11440          maxLength: 1001441          example: Legal Contract1442        description:1443          type: string1444          nullable: true1445          example: Legal and financial binding contracts14461447    # --- RFC 7807 Problem JSON ---1448    Problem:1449      type: object1450      required:1451        - type1452        - title1453        - status1454      properties:1455        type:1456          type: string1457          format: uri1458          description: A URI reference that identifies the problem type.1459          example: "urn:problem-type:not-found"1460        title:1461          type: string1462          description: A short, human-readable summary of the problem type.1463          example: "Resource Not Found"1464        status:1465          type: integer1466          description: The HTTP status code generated by the origin server.1467          example: 4041468        detail:1469          type: string1470          description: A human-readable explanation specific to this occurrence of the problem.1471          example: "Document with id 550e8400-e29b-41d4-a716-446655440002 was not found."1472        instance:1473          type: string1474          format: uri1475          description: A URI reference that identifies the specific occurrence of the problem.1476          example: "/api/v1/documents/550e8400-e29b-41d4-a716-446655440002"1477        invalid_params:1478          type: array1479          description: An array of invalid parameter errors (RFC 7807 extension).1480          items:1481            $ref: '#/components/schemas/InvalidParam'14821483    InvalidParam:1484      type: object1485      required:1486        - name1487        - reason1488      properties:1489        name:1490          type: string1491          description: The name of the invalid parameter or field.1492          example: "title"1493        reason:1494          type: string1495          description: Explanation of why the parameter is invalid.1496          example: "Title must not be blank."14971498  # ============================================================================1499  # RESPONSES1500  # ============================================================================1501  responses:1502    BadRequestError:1503      description: Bad Request - Validation failure or malformed payload.1504      content:1505        application/problem+json:1506          schema:1507            $ref: '#/components/schemas/Problem'1508        application/json:1509          schema:1510            $ref: '#/components/schemas/Problem'15111512    UnauthorizedError:1513      description: Unauthorized - Authentication is required or credentials are invalid.1514      content:1515        application/problem+json:1516          schema:1517            $ref: '#/components/schemas/Problem'1518        application/json:1519          schema:1520            $ref: '#/components/schemas/Problem'15211522    ForbiddenError:1523      description: Forbidden - The authenticated user is not authorized to perform this operation.1524      content:1525        application/problem+json:1526          schema:1527            $ref: '#/components/schemas/Problem'1528        application/json:1529          schema:1530            $ref: '#/components/schemas/Problem'15311532    NotFoundError:1533      description: Not Found - The requested entity does not exist.1534      content:1535        application/problem+json:1536          schema:1537            $ref: '#/components/schemas/Problem'1538        application/json:1539          schema:1540            $ref: '#/components/schemas/Problem'15411542    ConflictError:1543      description: Conflict - A resource with the same identifier or unique constraint already exists.1544      content:1545        application/problem+json:1546          schema:1547            $ref: '#/components/schemas/Problem'1548        application/json:1549          schema:1550            $ref: '#/components/schemas/Problem'15511552    InternalServerError:1553      description: Internal Server Error - Unexpected failure on the server.1554      content:1555        application/problem+json:1556          schema:1557            $ref: '#/components/schemas/Problem'1558        application/json:1559          schema:1560            $ref: '#/components/schemas/Problem'1561

Search chapters, reference and source filenames.