openapi: 3.1.0
info:
  title: Comunidesk API — Documentos legales
  version: 1.0.0
  description: Documentos legales del edificio.
servers:
  - url: "https://gateway.comunidesk.com"
    description: Gateway producción
tags:
  - name: documentos-legales
    description: Documentos legales — Documentos legales del edificio.
paths:
  /v1/rest/DocumentosLegales:
    get:
      tags:
        - documentos-legales
      operationId: listDocumentoLegal
      summary: Listar Documentos legales
      description: Documentos legales del edificio.
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
          description: Contexto de edificio (requerido en la mayoría de módulos).
        - name: $filter
          in: query
          required: false
          schema:
            type: string
          description: "Filtro OData, p.ej. edificioId eq 'abc'"
        - name: $top
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
        - name: $skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DocumentoLegal"
                  count:
                    type: integer
        401:
          description: Token inválido
        403:
          description: Sin permiso
    post:
      tags:
        - documentos-legales
      operationId: createDocumentoLegal
      summary: Crear Documentos legales
      security:
        - OAuth2App: []
          ComunideskUser: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DocumentoLegal"
      responses:
        200:
          description: Creado
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocumentoLegal"
        403:
          description: Sin permiso
        422:
          description: Contrato inválido
  /v1/rest/DocumentosLegales/{id}:
    get:
      tags:
        - documentos-legales
      operationId: getDocumentoLegal
      summary: Obtener Documentos legales
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
          description: Contexto de edificio (requerido en la mayoría de módulos).
        - name: $filter
          in: query
          required: false
          schema:
            type: string
          description: "Filtro OData, p.ej. edificioId eq 'abc'"
        - name: $top
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
        - name: $skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/DocumentoLegal"
        404:
          description: No encontrado
    patch:
      tags:
        - documentos-legales
      operationId: updateDocumentoLegal
      summary: Actualizar Documentos legales
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DocumentoLegal"
      responses:
        200:
          description: Actualizado
        403:
          description: Sin permiso
        422:
          description: Contrato inválido
    delete:
      tags:
        - documentos-legales
      operationId: deleteDocumentoLegal
      summary: Eliminar Documentos legales
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
      responses:
        200:
          description: Eliminado
        403:
          description: Sin permiso
        404:
          description: No encontrado
components:
  securitySchemes:
    OAuth2App:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Access token OAuth2 de tu aplicación.
    ComunideskUser:
      type: apiKey
      in: header
      name: x-comunidesk-user-authorization
      description: "Bearer <JWT de la cuenta Comunidesk del usuario>."
  schemas:
    DocumentoLegal:
      type: object
      description: Documentos legales del edificio.
      properties:
        _id:
          type: string
        _rev:
          type: string
        type:
          type: string
          const: documento_legal
        edificioId:
          type: string
        titulo:
          type: string
        tipoDocumento:
          type: string
        fechaDocumento:
          type: string
        archivoUrl:
          type: string
        descripcion:
          type: string
        createdAt:
          type: string
          readOnly: true
        updatedAt:
          type: string
          readOnly: true
      required:
        - edificioId
        - titulo
        - tipoDocumento
        - fechaDocumento
    OAuthScopes:
      type: string
      enum:
        - "comunidesk:read"
        - "comunidesk:write"
        - "files:pdf"
        - "files:excel"
        - "ai:models"
        - "ai:chat"
        - "ai:extract"
        - "ai:web"
        - "flex-pro:manage"
        - "flex-pro:runtime"
        - "flex-pro:marketplace"
      description: Scopes OAuth soportados por el gateway.
security:
  - OAuth2App: []
    ComunideskUser: []